Learning F # (1): programming environment

Source: Internet
Author: User

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:

  1. Call FSC through command line

  2. 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:

  1. Use fsi.exe from the command line
  2. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.