Fall in love with F #: Dose 0.1: How to install F #
Dear Habrakollegi!
Thanks for the warm welcome of my F # notes. Frankly, I did not expect so many interesting and useful comments! I apologize in advance if I do not have time to respond to everything - I will try.
Before you start falling in love with F # on these notes, I recommend that you establish yourself an appropriate programming environment. I apologize in advance to those who have already established F # and are waiting for more advanced posts from me: I try to express everything in order, so the first time can be boring.
There are several ways to install F # (currently, the latest version is 1.9.6.2):
The most correct: if you have Visual Studio 2008 (and any student can get it through the DreamSpark program ), then download F # September CTP (.msi) or newer from here to get everything you need. Please note that F # does not work with Visual Studio Express!
If you do not have Visual Studio Pro , then you can put a free Visual Studio Shell , and on top of it: F # September CTP (.msi). Then you get Visual Studio with a single language - F #!
Finally, if you have no desire to install Visual Studio and enjoy convenient contextual prompts and an editor with syntax highlighting - you can install F # September CTP (.msi or .zip) separately - and you will receive a set of command line utilities (including the compiler and interpreter) . Of course, you need the .NET Framework.
If you are working on U * # x-like systems , you can put Mono , and on top of it - F # September CTP (download the .zip file). Please note that Mono 2.0 is required for F # September CTP to work. If you have, for example, like me, Ubuntu 8.10 - then it costs Mono 1.9, and you have to either update Mono, or install an older version of F # from here (I think I put 1.9.3)
By installing F #, you will get the following language features:
The command line compiler fsc.exe - with it you can compile executable files and assemblies in command mode.
The interpreter fsi.exe (F # Interactive). By running it, you can calculate F # expressions online and get the result:
Both use cases - interpretation and compilation - are available from Visual Studio. On the one hand, you can include F # projects in Solution, on the other hand, you can open the F # Interactive interpreter window (View -> Other Windows -> F # Interactive or press Ctrl-Alt-F) for interactive work. In this case, it is enough to select a text fragment in the text box at the top and press Alt-Enter, so that this text is “calculated” in the lower window of the interpreter:
I recommend that anyone who wants to try F # begin with Visual Studio mode — write a program (or just text fragments) in the editing window, where all contextual prompts are available, and then select them and execute them in the interpreter window. In which case, you can go directly to the interpreter window and enter some expressions there (for example, to check intermediate values).
So, in interpreter mode, F # is committed to evaluating each expression entered and displaying the result. The expression must end with two “comma-points” ;;. In the simplest case, it is just an arithmetic expression (like 1 + 2 in the examples above), in a more complicated case, the whole program. What expressions and constructions exist in the language - we'll talk about this in the next, first programming lesson in F #! For now, prepare your computers and install everything you need on them.