News

F# 4.5 Arrives with Span Support, Aligning with .NET Core 2.1

Microsoft shipped an update to its functional programming language, incorporating Span support in the new F# 4.5.

Described as "the largest piece of F# 4.5," Span support aligns the open source language with the Span feature in .NET Core 2.1, which shipped in May.

That System.Span<T> feature, Microsoft explained, "is a new value type at the heart of .NET. It enables the representation of contiguous regions of arbitrary memory, regardless of whether that memory is associated with a managed object, is provided by native code via interop, or is on the stack. And it does so while still providing safe access with performance characteristics like that of arrays."

In announcing F# 4.5 this week, Microsoft said the main goals of the new Span feature set are:

  • Offer ways to interoperate with and produce high-performance code in F#.
  • Full parity with .NET Core performance innovations.
  • Better code generation, especially for byref-like constructs.

"What this boils down into is a feature set that allows for safe use of performance-oriented constructs in a very restrictive manner," said Microsoft's Phillip Carter. "When programming with these features, you will find that they are far more restrictive than you might initially anticipate. For example, you cannot define an F# record type that has a Span inside of it. This is because a Span is a 'byref-like' type, and byref-like types can only contained in other byref-like types. Allowing such a thing would result in unsound F# code that would fail at runtime! Because of this, we implement strict safety checks in the F# compiler to prevent you from writing code that is unsound."

Another new feature in F# 4.5 is the new match! keyword that Carter says somewhat shortens a lot of common boilerplate code. That, Carter said, comes entirely from John Wostenberg, one of the many developers in the open source community who helps shape F#.

In fact, all F# development is based on an open RFC (requests for comments) process, and developers can inspect all those RFCs for F# 4.5 and FSharp.Core 4.5.0.

Other new features highlighted by Carter include:

  • Relaxed upcast requirements with yield in F# sequence, list and array expressions
  • Relaxed indentation rules for list and array expressions
  • F# enumeration cases emitted as public
  • Better async stack traces
  • Additional FSharp.Core improvements
  • F# tools updates
  • New Visual Studio features

The Microsoft team has recently been focused on shipping F# 4.5 and related tooling for Visual Studio 2017 15.8 (which was just released this week), but it has also been planning future work on the functional programming language.

Developers interested in seeing in what directions the community will be driving the language going forward can check out the F# Suggestions site on GitHub.

However, note that there is currently a backlog of approved ideas, and the top five suggestions that boast the most "thumbs up" reactions all stem from 2016.

As far as a roadmap for the language going forward, Microsoft says the closest approximation is the list of approved-in-principle items.

One primary area of focus for the F# team, Carter said, is better positioning in the machine learning space.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus

Featured

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube