F# is a powerful language that spans multiple paradigms of development. This chapter provides a brief introduction to the heart of F#—the F# compiler, tools, and its place in Visual Studio 2010.
In this chapter, you will create a couple of simple F# applications and then I’ll point out key Visual Studio features for F# development. I won’t cover much of Visual Studio here, so I encourage you to explore the IDE on your own to learn more, or refer to the documentation online at http://msdn.microsoft.com/en-us/vstudio/default.aspx.
If you are already familiar with Visual Studio, you should still skim through this chapter. Creating and debugging F# projects works just like C# or VB.NET; however, F# has a unique characteristic when it comes to multiple-file projects. In addition, F# has a feature called F# Interactive that will dramatically increase your productivity. Not to be missed!
As with all programming books, it is customary to write a Hello, World application, and I don’t want to deviate from tradition. Open up Notepad or your favorite text editor and create a new file named HelloWorld.fs with the following text:
// HelloWorld.fs printfn "Hello, World"
Success! You’ve just written your first F# application. To compile
this application, use the F# compiler,
fsc.exe, located in the Program
Files\Microsoft F#\v4.0 folder. (Or, if you are using the
Mono, wherever you chose to install F#.) The following
snippet shows calling the F# compiler on the command line to build and run
C:\Program Files\Microsoft F#\v4.0>
HelloWorld.fsMicrosoft F# Compiler, (c) Microsoft Corporation, All Rights Reserved F# Version 126.96.36.199, compiling for .NET Framework Version v4.0.21017 C:\Program Files\Microsoft F#\v4.0>