Software Development

Microsoft unveils the F# programming language

Tony Patton kicks the tires on the September 2008 Community Technology Preview of F#. Read his brief overview of the programming lanaguage's features and environment.

 

There has been considerable chatter about F# for some time. The programming language began its life at Microsoft Research and recently progressed to the mainstream with the release of the September 2008 Community Technology Preview.

I've read a lot of good things about F# (which is a close cousin to the Objective Caml language), and since I need to keep up with the .NET world, it was time for me to take a quick tour of the language.

Getting F#

The September CTP is available as a free download. It runs on Windows XP and Windows Vista and requires .NET Framework 2.0. Installation is as simple as downloading and running the install file. It provides Visual Studio 2008 integration, but it is not required. You may utilize the command-line tools to play with your F# code.

The Visual Studio 2008 install provides an interactive session that allows you to enter and run F# code on the fly without compilation. This interactive session window is at the bottom of the IDE interface (when working with F#). You can type in F# code and hit [Alt][Enter] to run it on the fly. It is a great way to get your feet wet with the language.

Features

Microsoft describes F# as a functional, object-oriented, imperative, and explorative programming language for .NET. While the description says object-oriented, the more important term is functional. That is, you don't have to write object-oriented code with F#; you can think in more procedural terms to solve a problem.

F# boasts the following features:

  • Strongly typed: Each data type is predefined, and all constants and variables use one of these types.
  • Succinct: You can accomplish a lot in a small amount of code. You are not burdened with a lot of the overhead of C#/VB.NET with creating classes and such.
  • Libraries: F# is .NET, so the Framework is there for you.
  • Scalable: Once again, it is .NET under the hood, so it has a scalable architecture.
  • Efficient: Microsoft proclaims it is an efficient language, but I will wait and see.

You can get F# to do what you want, but it seems to be more relevant for number crunching activities like financial/data analysis, modeling, and academic work -- at least, this is what Microsoft is saying. (I can't help but think of playing with Fortran in my college days when I read such things. Of course, there is a project for a .NET version of Fortran.)

The environment

One of the first things I noticed is the use of the let keyword to assign variables -- this took me back to my days programming with BASIC. The following F# statements assign values:

let firstname = "Tony"

let a = 12

let b = 1.5

The data assigned to the variables sets their type. Once these values have been assigned, they may not be changed -- they are immutable. So, the following lines are invalid:

let a = 12
a <- 13

The last line attempts to store the new value in the variable called a, but this is not allowed since it has already been set up with another value. Now you can use the mutable keyword to change this behavior, as this snippet demonstrates:

let mutable a = 12
let fname = "Tony"

a <- 13

printfn "My first name is '%s'" fname;;

The previous sample demonstrates output via the printfn function. Also, you may notice there are no end-of-line delimiters. You can also define types, modules, enums, and so forth. F# offers great support for pattern matching, which lends itself to data analysis.

Additional resources

I love the abundant amount of free resources available on the Web about Microsoft development (as well as other languages). F# is no different, as the following brief list demonstrates:

You can find many more resources about F# by searching Google and Amazon.

Reserving judgment

F# has potential, but I wonder how long it will take to enter the mainstream (if ever)? After all, I can't force the language on a client unless there is a situation where F# is more useful. With that said, I'll play the waiting game with F# and its future.

I also pondered why another .NET language (from Microsoft) is necessary. Are C#, VB.NET, and the available third-party languages not enough? I already must keep up with these languages, as well as HTML, JavaScript, CSS and XML to name a few. (Dare I mention the ill-fated J#?)

Do you plan on taking F# for a test drive? Do you think another .NET language is actually necessary? Share your thoughts with the Web Developer community.

Tony Patton began his professional career as an application developer earning Java, VB, Lotus, and XML certifications to bolster his knowledge.

-----------------------------------------------------------------------------------------------------------------

Get weekly development tips in your inbox Keep your developer skills sharp by signing up for TechRepublic's free Web Developer newsletter, delivered each Tuesday. Automatically subscribe today!

About

Tony Patton has worn many hats over his 15+ years in the IT industry while witnessing many technologies come and go. He currently focuses on .NET and Web Development while trying to grasp the many facets of supporting such technologies in a productio...

25 comments
mail
mail

Come on guys how many languages yo want..... learn the existing languages Expertize in that first.... www.futuretechwriters.com mail@futuretechwriters.com

motohead400
motohead400

How many freaking languages do you need!? Give me a break. Either learn how to use an existing language or leave the code writing up to the professionals. I say FU to F#.

ByteBin-20472379147970077837000261110898
ByteBin-20472379147970077837000261110898

There are so many to work with now. And don't forget that Visual Studio 2008 (even Express Editions) also come with Visual C++. I like using these 3. I only wish that there was a Visual Perl Visual PHP and Visual Classic ASP 2.0 in the mix. But I guess there's reasons for MS avoiding those. What those reasons are I never did find out.

mjames.name
mjames.name

Get the F# outta here :) LoL F# may be useful but more depdendant on web or desktop apps. The convergence? The Separation? I'm not a veteran coder but it'll be interesting to see the responses of hardcore programmers. I have to contend with my design skills, xaml, expression/blend and vb/c# so I wonder the direction F# is heading especially with newer versions of VB on the way :)

jbakaev
jbakaev

does F stands for fail?

youzer
youzer

I see F# being a likely candidate to replace VB.NET

BALTHOR
BALTHOR

Code is a dead stop on our planet.From beginning to end,show me writing a software program with code.Start by writing a program like Paint Shop Pro.

iainadams
iainadams

We all know that learning a new language is not all bad. Those of us who have been programming a long time didn't start with .NET. From whatever we started, be it Basic, Pascal even ColdFusion, we had to acquire new skills by learning new languages in order to survive. The thing is, most of us only work on a few languages day to day. Everything else is stuff we've just "checked out" and F# most likely will be just another one of those. I would still familiarize myself with it enough to at least arm myself if something comes up that I can use it or if there's something eventually existing that used it. One never knows. iainadams http://iaintech.blogspot.com

aspatton
aspatton

While I agree that learning an existing language is a given, but that doesn't mean ignoring what is going on with other languages. I've worked with numerous products and languages over the years - I currently utilize C# which was nowhere to be found 15 years ago. Furthermore, when I started in this industry, there was no .NET Framework, Java, JavaScript, and PHP to name a few. A good grounding in development principles simplifies the chore of moving from one language to another, so be a good developer and not a "insert language name" programmer.

Tony Hopkinson
Tony Hopkinson

Leave code writing up to the professionals, especially those who are have or are, or are prepared to learn existing languages such as F#. You might want to have a look at what you posted and replace F# with whatever language you do know. Then you'll realise how dumb it was....

Justin James
Justin James

Active State makes a Perl compiler for .Net (it turns Perl code into a .Net assembly, and allows the same Perl code to consume other .Net code). Sadly, the last I checked, it does not integrate with Visual Studio at all, which is a major flaw in my opinion. J.Ja

Tony Hopkinson
Tony Hopkinson

VB is a starter language, designed to be approachable for beginners and those who don't care to investigate the discipline. You'd need a sea change in IT education and then to wait about twenty years to see any result.

Justin James
Justin James

I took a look at F# about a year ago, while it has changed since then, Microsoft is not positioning it as a VB.Net alternative, nor would it be a good candidate for that. It is a *decent* (not great) scripting language, it is excellent for modelling certain types of scenarios (scientific and mathematical items, for example), and it good for when you need something akin to a "programming calculator" since it has an interactive mode. But for general purpose programming, my gut feeling is that VB.Net may or may not be better suited, and it certainly has momentum on its side. J.Ja

aspatton
aspatton

Send me an email at aspatton01 AT gmail dot com.

ByteBin-20472379147970077837000261110898
ByteBin-20472379147970077837000261110898

I was thinking of not .net but just having the same IDE and features to create Perl, PHP and ASP 2.0 code, including especially debugging and running on a browser. I do have DevPHP though. I'm sure others are out there. Just wish I had it all from one place in Visual Studio. Obviously that won't happen. LOL!

Jaqui
Jaqui

the fail track already though. 1) .NET, not available to ALL operating systems. critical flaw. 2) F# not available to all operating systems. Critical flaw. until MICROSOFT releases .NET for EVERY os, it's useless.

aspatton
aspatton

Well, it seems C# is the more dominant language (no hate mail please) with VB.NET there as well, but I agree that F# will never replace these. I just have a hard time seeing its future - developers won't switch to one language for one type of problem, or will they?

ahin4114
ahin4114

I don't think MS are pitching F# to replace any of the 'core' languages. They're attemtping to open functional programming languages up to the masses. Enabling development in a known and comfortable (sometimes) environment (eg. Visual Studio), with all the friendly intellisense etc may well allow people who wouldn't previously to explore the different methodology involved. I for one welcome F# to the fray, at least by sitting on a common framework, I can start to incorporate functional programming solutions into my work. The MSIL is gonna be the same at the end of the day, but visualising and developing certain solutions in a functional language can be a more natural fit, and I'm glad to have the choice.

buckleyc
buckleyc

There is a pretty good plugin for Visual Studio PHP development called VS.PHP. I downloaded the trial a while ago and it worked pretty well.

Justin James
Justin James

Earlier this week, Mono hit 2.0, which is a HUGE update. Keep watching this space next week for my article on it, I got to speak to the heavy hitters at Novell about it! J.Ja

buckleyc
buckleyc

Mono allows cross platform to some extent. Why should MSFT create the runtime for an OS they are less familiar with? Release the specs and let someone else port it. The Mono project is still young but I have been able to run .NET apps I have written on Linux using Mono.

leigh
leigh

As a person who has spent the last 3 years developing a web based front-end/SQL compliant db backend solution for an organisation which effectively IS the OS for the organisation, the answer is yes. We have a predominantly VBscript ASP system ( my original web design course taught this outdated language) with some C# and VB.NET aspx pages (moving stuff around the network solutions etc)[My Uni course taught this more suited language] and a linux server on a VM running some php pages ( which is what my web design course should have taught me ). And of course we have ajax and suchlike all over. Yes it is untidy, and aesthetically ugly (maybe), but it actually works really well. So either I am not a developer (you'd have a hard time convincing my employers of that) or the answer is that not only will they,they do....

Tony Hopkinson
Tony Hopkinson

with MSIL, is that you can switch to the 'best' language for the job, or even 'your' best language. Of course there are limiting factors on that. Academic, personal and business inertia. Teaching more than one language, learning more than one language and supporting more than one language. Of couse that crap exists because of the useful perception that language is programming.

Editor's Picks