microsoft’s-f#-6-boosts-performance,-ease

Microsoft’s F# 6 boosts performance, ease

Design goals for the new version were to make it simpler, more performant, easier to learn, and more uniform and interoperable with other .NET languages.




Microsoft’s F# 6 boosts performance, ease

Monsitj / Getty Images

F# 6, an upgrade to Microsoft’s open source, multi-paradigm, programming language, is now available. The new version promises to make it easier to write succinct, performant code, Microsoft said.

Formally announced in a bulletin on October 19, F# 6 ships with .NET 6  Release Candidate 2 and Visual Studio 2022 RC2. F# supports multiple programming models including functional, object-oriented, and imperative.

With F# 6, project developers aimed to make the language simpler and more performant in areas including language design, library, and tools. A goal of the long-term evolution of the language is to remove corner-cases that surprise users or are unnecessary hurdles to adoption.

Speed and interoperability in F# 6 are being addressed with a task {…} capability to create a task and await it. One of the most requested features for F#, and the most significant technical feature in F# 6, has been to make authoring asynchronous tasks simpler, more performant, and more interoperable with other .NET languages such as C#.

Prior to this release, creating .NET tasks required using async {…}  to create a task and then invoking Async.AwaitTask. Now task {…} can be used directly to build a task. Built-in support for task {…} is available in F# code with no need to open namespaces. Task support had been available for F# 5 through the TaskBuilder.fs and Ply libraries. These guided the design of task support in F# 6.

Elsewhere in F# 6:

  • To make F# simpler to learn, the project is allowing the syntax expr[idx] to mimic indexer/slicing syntax.
  • To make the language faster, F# 6 supports Struct representations for active patterns, allowing developers to use an attribute to constrain a partial active pattern to return a value option.
  • For speed, F# 6 offers improved performance for debugging for list and array expressions. Also for speed, a new declarative feature has been added that allows code to optionally indicate that lambda arguments should be inlined at callsites.
  • “First-class” support is offered for .NET-style implicit conversions. in F# 6, op_Implicit conversions are applied automatically for argument expressions when they are available and the types are known for the source expression and target type.
  • Pipeline debugging has been added in the F# toolchain.
  • For uniformity, F# 6 activates the “overloaded custom operations in computation expressions” feature, allowing for simpler DSLs in F#, including for validation and web programming. Also for uniformity, the right-hand side of an “as” pattern now itself can be a pattern, and a number of inconsistencies and limitations have been removed in F#’s use of indentation-aware syntax. Uniformity also has been enhanced with additional numeric types with unit annotations.
  • For performance and scalability, improvements have been made in areas such as the compiler, which now performs the parsing stage in parallel, and in analysis results, which are now performed concurrently.
  • F# developers will benefit from .NET 6 improvements such as source build, to satisfy packaging rules of commonly used Linux distributions, and profile-guided optimization, which can compile startup code at higher quality, reduce binary size, and rearrange application binaries so code used at startup is collocated near the start of the file.
  • In-memory cross-project referencing simplifies working between F# and C# projects. With this capability, C# projects now are reflected immediately in an F# project without having to recompile the C# project on disk.
  • If developers open an F# Script (.fsx) in Visual Studio, by default the script will be executed using .NET Core with 64-bit execution.
  • Use of rarely used symbolic operators has been reduced. Long-deprecated features have been removed, such as multiple generic parameters using a postfix type name.

Paul Krill is an editor at large at InfoWorld, whose coverage focuses on application development.

Copyright © 2021 IDG Communications, Inc.