Microsoft upgrades its F# functional language

Preview of F# 4.0 features runtime, compiler, and language enhancements

The F# team at Microsoft is offering a pre-release of the 4.0 version of the language, featuring core runtime and compiler improvements.

The object-oriented F# is Microsoft's entry into the burgeoning landscape of functional languages, which also features Scala, Clojure, and now even Java. Microsoft released F# code under open source license four years ago.

F# 4.0, detailed this week, has a core runtime that has been enhanced with normalized collections modules and better async stack traces.

"In F# 4.0, the collections API has been fully normalized across Array, List, and Seq," the team said. "There are now dedicated, optimized implementations of all common operations for each type, and even a few brand-new functions.  This represents the addition of a whopping 94 APIs in total."

With async stack improvements, exceptions occurring in async code now have stack traces preserved in a more user-friendly way, the team said. Also, internal tables of optimized hash-comparison implementations used by F# code have been improved, for performance gains when processing primitive types such as int and string.

Modified compiler settings, meanwhile, offer better performance by 10 percent. "Not a language feature, but surely of interest to F# language developers, is a change to the GC mode used by the F# compiler," the team said in a blog post. "fsc.exe now uses GCLatencyMode.Batch, which gives a noticeable improvement in overall throughput, something that any F# developer will welcome."

Language improvements include treating constructors as first-class functions, in which they get the same treatment as other .Net methods. Version 4.0 also features simplified use of mutable values and support for high-dimensional arrays.

"The .Net framework supports up to 32-dimensional arrays, but in the past F# only supported use of up to rank-4 arrays," the team said. "Not only were arrays of rank 5+ not possible to create and manipulate from F# code, the compiler could sometimes fail to consume external libraries which relied on high-dimensional arrays. This is now fixed.  Although there is not yet support for creating and manipulating high-rank arrays, the compiler will now properly handle these types up to rank-32."

The F# team also noted that the newly announced Visual Studio Community Edition supports F# and extensions such as Visual F# Power Tools. F# tools are included in the Visual Studio 2015 Preview download. The Visual Studio F# 4.0 Tools Preview is available for download.

Microsoft’s latest tooling strategy, rolled out this week, also features the open-sourcing of the server-side .Net stack and plans for Visual Studio 2015.

Copyright © 2014 IDG Communications, Inc.