Configuration environment:
To use a language for development, we actually only need a compiler. F # is the language on the. net platform, so. net framework is required. We can find the compiler of F # on the official website of F #. Download: Compiler #.
If you install an independent installation package, pay attention to the following system requirements:
. NET Framework 2.0 or an equivelanet CLI implementation.
I believe that all windows on weekdays have been integrated with. net framework 2.0. However, through this sentence, I believe that in linux, mono will certainly have corresponding F # support.
Try
Now we have a simple program:
//hello.fsprintfn "hello world"
How can we make it run. Of course, F # is also a compilation language. We need to compile it first. Fsc.exe (F Sharp Compiler) is the compilation tool of fenders. Here we have two options:
- Call FSC through command line
- Calling fsc through VS makes no difference with compiling and running C.
But now we have a new option, F # Interactive, or fsi. In the past, we had to try some features, syntaxes, or verify an output format in C #. We often need to create a new project. We wanted to do something simple, but the process was indeed so complicated. So there is such a lightweight tool in the top ten necessary. net tools (forget the name of this tool ). Fsi is a REPL tool. REPL stands for read-evaluate-print loop. It can receive F # code and then compile and run it. Once we open fsi, there will be a context. The previously defined functions or "variables" (which should be called values and values) can be used in subsequent code. In this way, we can enter a small code segment at a time to facilitate some attempts or experiments. However, to use fsi, we need to use";;"As the input Terminator. There are two methods to call fsi:
- Use fsi.exe from the command line
- Open the F # Interactive window in VS2010
To tell fsi that this input is over. Our input will be like this:
Printfn "hello world ";;
In this way, our first F # program will run.
In the learning process, there are four ways to run F # code. I personally prefer the command line fsi. It is a waste of resources to open VS because it is just learning and does not need to write long or complex code. The process of writing, compiling, and running code is a little complicated, and fsi is simple. Because fsi is born for this demand, huh, huh.