What is the F# interactive window good for? - visual-studio

Am I able to script macros here? Maybe process some text? I may be interest in learning F# if this window provided the ability to process the current document, etc.
I have googled and found tutorials on learning F#, writing programs in F#, but nothing on what the F# interactive window is good for in VS.
EDIT:
Sounds like a rant yes. Is it? No. I love scripting. I just wrote a ruby script to implement an interface on a bunch of existing POCO's, that I couldn't easily figure out how to do with with ReSharper. I was thinking that if there was an interactive ruby console that could work with the current document(s) it would have made that task much easier. Then I got thinking that maybe that the F# console was what I was looking for, and it would be learning F# for.

F# Interactive is a Read-Eval-Print-Loop (REPL), which is an ad-hoc environment that enables you to experiment with F# code. Many Functional programming languages come with a REPL.
You can highlight a piece of F# code in the normal editor and send it to F# Interactive with Alt+Enter. You can also write code directly in the F# Interactive. In order to focus in the window, you can use Ctrl+Alt+F.
F# Interactive is also available as the command-line program fsi.exe, independent of Visual Studio. This makes F# accessible to people without access to Visual Studio.
There are various other ways to experiment with code and APIs. My personal preference is to use Test-Driven Development (TDD), which is one alternative to using a REPL. With TDD, I leave behind a suite of tests, which can often be beneficial. However, unit testing is a somewhat 'heavier' process, because I have to pull in a unit testing framework, and write assertions. Sometimes, I just need to experiment with various syntax alternatives or ways to model a concept, and the REPL provides more lightweight alternative to that. However, when I use F# Interactive, no test artefacts are left behind.

As others have pointed out, the main purpose of the F# Interactive windows is as a REPL for F# development. I find it useful for other tasks though too - you can use it as a sophisticated calculator, you can open files and process text and do many of the kinds of things you might use a bash window for on unix.
I have experimented a bit with accessing the Visual Studio Automation APIs from F# Interactive as described in this blog post. This is clearly not what FSI was originally intended for but it does make some of the things you seem to be interested in possible. I think it would be useful if this was directly supported in FSI but as it is I've found it a bit clunky to be really useful so far.

Related

Quick GUI for your own utilities

What do you guys use if you want to make a quick and dirty Windows GUI as a utility helper for your coding? I had been using AHK but since I do a lot of work in C# I wondered if it were more convenience.
Basically I'm looking for the simplest way to pop a window with some fields and do a little text processing in a Windows desktop environment.
Python and tkinter, or tcl/tk is what I use.
I like to use Linqpad for code prototyping and small tests. Even though its meant for more database stuff, I'm sure you could punch out a GUI really fast in there and save it for future testing. It has a lot of support for C#, but also quite a few other languages. Not sure if this is what you're looking for, but that's what I would use.

Is Visual Studio also a good IDE for non .NET languages?

I'm a bit in IDE trouble, and I'm not alone I have noticed, still I haven't found an answer on many of my questions.
I would very much stop using different editors and become very good at one (on windows), adhering the pragmatic adage : "Learn one editor (ide) well". I' m willing to put in a lot of effort, to gain on the long term.
I have programmed (java) with Intellij and Eclipse, and am progamming c# now. (VS08 was at first very disappoing for me, till so at SOF mentioned Resharper and now I'm very happy with it, especially since I started writing macros for further adjustments)
For all purpose editors, VIM and EMACS come to mind, but I'm afraid they just cannot compete against VS08/Resharper when it comes to C#, which I'm using a lot on this moment. Further, it isn't clear to me if they support refactoring (after installing packages for the language in question?)
But since VS08/Resharper is so powerfull for c#, I would like to give VS a serious chance. But for that it should have support for langauges that don't compile to CIL.
hence my question : Is Visual Studio a good tool for non .NET languages?
(and like asked on the side : how about refactoring in VIM/EMACS?)
VS is IMO, better then average editor but not something you can't live without.
If you like your editor to open as fast as Notepad with bunch of features, try EditPlus (on the down side it uses older RegExp implementation but on the plus side it can be made to be portable.
If you would like total extensibility, fast startup, inovative fatures, integrated reposity etc.. try E-Editor, windows port of Mac TextMate.
VIM is ofc superb, but ... long learning curve may be a problem and some people can't find themselves in 2 mode editors.
About Resharper... mhm... almost all of its non-code analytic features may be integrated in mentioned editors. For its suggestive features I doubt there is alternative. I disabled it for the moment because I tend to let Resharper fill in my holes so it can be a double bladed sword - sonner or latter I will totally stop thinking about some things like, can this variable be null or can I move its declaration. I run resharper once I finished some working procedure or at the very end to polish the code.
I personaly use EditPlus for all of the NON MS languages, but E-Editor got my attention recently.
I tend to avoid using IDEs outside of the languages they are designed. A dedicated IDE can include class libraries, function references, code completion utilities, etc. out of the box.
Once you step outside that, however, you have a clunky and resource hungry text-editor. You might as well use a text editor in that case just to keep your workstation nimble.
It might be better not to learn one IDE well, but rather a text editor. I've used jEdit for years for several reasons: It's multiplatform, includes syntax highlighting for lots of languages, and can be feature-extended with plugins. It's become one of my standard tools, but it's only one in the box.
How about VI mode for VS? I think Eclipse has one too.
You'll just have to learn vi-related commands, but will be able to work in, C# (with VS), Java (with Eclipse), C++ (with VS or Eclipse), scripting languages (with vi), ...
"I would very much stop using different editors and become very good at one (on windows),"
Why?
"adhering the pragmatic adage : "Learn one editor (ide) well". " Really? How is this pragmatic?
After 30 years in this business, my lesson learned is "tools come and go."
Once upon a time we had big fights over vi vs emacs. Not vim with syntax coloring, but plain-text-vi on black-and-white monitors.
Why narrow your world to one tool? How will you cope with innovation if your tool is not the new state-of-the-art?
As far as C/C++ goes, Visual Studio is considered the gold standard (well, Visual Studio + VAX if you really want to get specific). It's not perfect, and it's certainly not as good as the C# tools it has, but it's still a damn sight better than anything else out there, on any platform. (Assuming you didn't want C99 support.)
Of course it doesn't really do non-.NET other than those two.
I think that there is good specialization at the moment. VS is the clear candidate for .Net, with Resharper and DevExpress as great augmentation for increased productivity.
Currently we use Aptana for the "Web 2.0" stuff - CSS/jQuery/MooTools, and that has been a great environment as well. I have avoided the Intellisense in VS 08 for jQuery and do prototyping in HTML/CSS/JS in Apatana, then do all the Domain design in VS. Works for us pretty well.
It is good for C/C++ but it is not comparable with what you get for C# or VB.Net ( i don't think it support other languages )
for javascript intelisense is still limited

Easier than Visual Basic 6?

Some years ago I used to program in VB6, I really liked it because it was very simply and fast, when VB.net came out, I abandoned it because they changed a lot of things.
I wonder if after all this years there's a new language or IDE that helps programming in an easier and faster way than VB6.
I'm not very interested in academic/personal issues like, very high performance, great movility through OSs, open source, etc. I would like to know if there's is something to program small and medium desktop apps. in an very easy and fast way.
Excuse me if my english isn't very clear.
Edit answering Nicholas:
Well, I must admit that I didn't try VB.Net too much, I was a little disappointed because I would had to learn a lot of new things and I've had learned VB6 not so long before (in that moment).
VB.Net is the natural progression of VB6, and has a lot of free tools and resources online to get started. Microsoft even provides a free development environment as well as a free database for development/bundling in your applications.
Check out this website for information and download links on all the free Microsoft software.
Also, you said you tried VB.Net and didn't like it-- I'd be curious to know why? Yes, there's a little learning curve, but the abundance of getting started information on the internet surely can help that. I was a bit overwhelmed by .NET at first (particularly ASP.Net) not seeing the value in switching/learning a new language.
I always felt Microsoft Access was far and away the best for this kind of requirement.
edit - I realize this isn't a politically correct answer. But the total package of a built in DB, a great GUI development package, a great report generator (far superior to crystal reports, for example), the easy development of tables and queries, all put in one friendly package, make it nearly trivial to develop with. For rapid development, it's the best I've used.
FWIW, I do Java, C++, C, VB4/6, ASP, JSP, Perl, PHP, CSS/ DHTML, JavaScript, Pascal, Fortran, Kenemy and Kurtz Basic, BAL, unix shell scripting, Oracle, mySql, RPG III, COBOL, some proprietary stuff, various macros, various distributed technology, Job control language, CPL, etc. etc. I got out of developing in Access because of scalability limitations.
Powerbasic may be to your liking -
http://www.powerbasic.com/
One of the easiest languages to learn and use is Python.
FLEX / AS3 / MXML / AIR (tnx le dorfier) comes very close to that VB6 feel from many years ago. But understands stuff like CSS and produces output that works in browsers on any platform (or desktop with AIR). You write code and run it, the coding cycle is very fast. And AS3 is at least as powerful as VB6 ever was, plus there are myriad add-ons and libraries to support all sorts of applications, all the major web-services, database interface, animation, video, 3D, auto-generation of PHP code, etc.etc.etc...
And Flex Builder 3 is free for students and educators.
alt text http://www.infoworld.com/infoworld/img/17TC-adobe-flex-builder.jpg
Python or Ruby.
Dynamic languages has a number of advantages (and disadvantages) but for what you propose they seem perfect.
I would recommend python or ruby bindings of a high level toolkit as a perfect environment. For instance Qt library gives most functionality you would need and dynamic languages let you easy experimentation
Microsoft has a new dialect of BASIC called Small Basic. From the website:
Small Basic is ... a small and easy to learn
programming language in a friendly and
inviting development environment,
Small Basic makes programming a
breeze. ...
Small Basic derives its inspiration
from the original BASIC programming
language, and is based on the
Microsoft .NET platform. It is really
small with just 15 keywords ...
The Small Basic development
environment ...provides
powerful modern environment features
like Intellisenseā„¢ ...
The first two versions of VB.NET had serious shortcomings compared to Visual Basic 6. However most of these issues has been fixed since Visual Studio 2005. Today, for new projects, I feel that everything that made VB6 so easy to use is available with VB.NET plus you get new language constructs, and the .NET framework. There also refactoring, and the VB Power Pak which brings back the older simple to use print engine.
Of course there is a learning curve involved. But no more than the leap from QuickBASIC/PDS to VB 1. If you have to maintain or transfer an older project then the differences between VB6 and VB.NET are much more serious.
Finally there is the Mono Project which support the VB compiler. This provides a degree of relative immunity from Microsoft deciding to break backwards again.
You could try FreeBASIC.
It's syntax is very similar to that of VB and it is an actively worked on open-source project, it is also portable across different platforms.
You can grab a download here and there are several exemplary works that can be found here.
If it already wasn't done I'd recommend python. It's one of the easiest languages to learn.
My first language was Pascal and I think it's also one of the easiest languages and with Delphi getting popular again I think it's a very good alternative to VB6.
I've always found Delphi to be easier than VB despite popular belief.
take a look at Lua
very small core language, the whole documentation is a single (very readable) webpage. you can easily learn the basics in a weekend.
very good (small) books with good tips.
very helpful community.
very fast, both with the standard bytecode VM, and the JIT.
used a lot in games, both because it's fast and easy to embed in the application, and because it's easy to explain to players interested in extending the game.
readable sources.
MIT license, use for whatever you like, no strings attached.
Perhaps Clarion is what you're looking for? Personally, I don't have much experience with it, but you can build some nice apps with virtually no coding skills.
I think C# is a very good language to program GUI apps quick and easy.
While this might not be a complete answer to your question, I would recommend spending some time learning a more complex language (Objective-C, Java, C#, etc). With the experience you learn with OOP design patters etc, in the future you won't have to shop around for the "easiest" language to program with.
visual basic.NET is much more easier and have complete features than VB6 as I've experienced.
I recently messed around with Microsoft Lightswitch and found it extremely VB like. Very fast for binding to a database and generating forms, grids, etc.
More than 10 years after this question was asked, the best answer is...
...to continue using the VB6 programming language.
VB6 still works on Windows 10 and Windows Server 2019. Just as it has since Windows 98.
Microsoft's support policy for VB6 is here VB6 support policy

How do I set up Visual Studio 2008 to program in Perl?

My company gave me VS2008 for web development in C#/ASP.NET. I do a lot of Perl programming too and I'd like to start using VS for that so I can have a consistent work environment... but am having real trouble figuring out how to do so.
VS has a lot of nice features but seems pretty hostile towards languages it doesn't support out of the box. Is it really or do I just not "get" the VS way of doing things?
I usually write Perl scripts using TextPad and the features I'm used to having are pretty basic.
line numbering
soft line wrapping
syntax highlighting
auto-indenting in/out after open/close brace
auto-indenting to the same starting point as the previous line
brace matching
run scripts from within the editor
capture script output in an editor pane
dbl-click on error message jumps to the line where the error occurred
How do I at least get the above features in VS2008?
How can I get advanced features like:
code folding
intellisense
code-completion
integrated perldoc
VS-style debugging and code tracing
on-the-fly error detection
etc
(I see one possibly relevant online discussion in an ASPN mod-perl mailing list , but don't understand what, if anything, it means to a guy like me.)
-- added --
I'm aware of other editors and IDEs out there: vi, perlmode-emacs, Komodo, E, TextMate, etc. This question is not about what other editor or IDE I should try.
While I appreciate your suggestions, I'd rather read them in a thread like "What editor should I use for Perl" and not "How do I set up VS to accomplish my goal"
-- added --
After doing some additional research I've concluded that you just can't get there from here. The only option would be to write my own language plugin. Considering the time commitment to make something usable I think I'm just better off using a different editor. Thanks anyway guys
I use VS2008 for .NET stuff, but I'm completely sold on Komodo for Perl editing. The full Komodo IDE is worth the money if this is your job and like/need to use a debugger, but even the free Komodo Edit is a terrific Perl editor.
I agree, I really like Komodo as well for an IDE. Its solid and easy to use. I tend to use Vim a lot instead of an IDE, but that's just personal preference.
Check out Komodo though, its worth the look.
Regards,
Jeff
I heard rumors of there being a .NET implementation of Perl, called IronPerl, but except for that, I don't think there is any sort of plugin for Visual Studio. I would suggest just using one of the many tools out there that are designed for Perl.
There was something called "Visual Perl" wich worked with Visual Studio.net 2002 and was needed Perl Dev kit tool, but I don't how comatible is with VS.net 2010.
Looks like you can do this via the Managed Package Framework if you are willing to put the time in.
You can decrease the amount of work required by just setting up syntax coloring

Any real world experience debugging a production functional program?

I'm interested in what tools and methods are used for diagnosing flaws in large scale functional programs. What tools are useful? My current understanding is that 'printf' debugging (e.g. add logging and redeploy) is what is typically used.
If you've done debugging of a functional system what was different about it then debugging a system built with an OO or procedural language?
Sadly, printf debugging seems to be the state of practice for Standard ML, Objective Caml, and Haskell. There's a little bit of debugging at the interactive read-eval-print loop, but once your app hits 25,000 or 50,000 lines that's less useful.
If you're lucky enough to be using Haskell, there's an exception: QuickCheck is indispensible for testing and deubgging. QuickCheck can be used even on combinations of Haskell and C code, as demonstrated by experience with the Xmonad window manager.
It's worth noting that around 1990 Andrew Tolmach built a very nice time-travel debugger for Standard ML of New Jersey, but that it was not considered worth maintaining. It's also worth noting that at one point the OCaml debugger (also a time-travel debugger) worked only on bytecode, which was inconvneient, and refused to violate abstraction barriers, which made it useless. This was around release 3.07 or so; perhaps things have improved.
Also in the early 1990s, Henrik Nilsson built an interesting debugger for Haskell, but mostly what it did was prevent the debugger from accidentally changing the evaluation behavior of the program. This was interesting, but only to lavzy-evaluation weenies.
As someone who has built or worked on large applications in all three of these languages, I find the state of play depressing.
The main tools we use at work (a Haskell shop) are:
QuickCheck
HPC: visual Haskell program coverage tool (we developed this in house)
Logging/printf/trace
Sometimes, the GHCi debugger
My current job is to implement new features and support a large system implemented in ocaml and C#. Most of the "logic" is implemented in caml and the GUI and data access is in C#. The debugging techniques are pretty much as you describe lots of logging and assert to work out what's gone wrong.
Additionally we have a large number of unit tests, which are just caml scripts for testing the logic and help to spot any regression errors.
We also use continuous integration to check the build and run nightly test scripts, including some automated testing of the GUI though our "automation" style scripting interface.
I quite often use the C# debugger for debugging the C# portion of the application, the ocaml debugger does yet work under windows so we don't use it. Although we hope one day we may fix this but it isn't top of our priority list. I have occasionally used windbg to investigate managed and unmanaged memory problems, though this turned out to be caused by a third party component implemented in C#.
So overall, nothing out of the ordinary but it seems to work okay, we don't see too many production problems.
Thanks,
Rob
F# has Visual Studio integration, so you can attach the debugger to your program and set breakpoints, watches, etc, just like with any other .NET language.
However, I prefer to avoid debugging as much as possible, by writing short functions that I can unit-test individually.
A couple of years ago when I did this I had to use a combination of printf debugging and QuickCheck. These days I would also use the ghci built-in debugger.
The biggest headache was actually laziness causing space-time leaks. There still doesn't seem to be a good answer to these: just do lots of profiling and keep trying to figure it out.
OCaml and F# both have excellent debuggers. OCaml's is time reversible. F#'s has excellent IDE and multithreading support.

Resources