Microsoft’s F# 8 stresses simplicity, performance


F# 8, a new edition of Microsoft’s open-source, “functional-first” programming language, now is generally available, emphasizing simpler, more uniform, and more performant F# programming.

Released November 14 as part of the .NET 8 software development platform, F# 8 is available in both .NET 8 and Visual Studio 2022.

F# 8 has been made more consistent by allowing existing constructs in previously forbidden contexts, Microsoft said. This is intended to reduce beginner confusion and the need for workarounds, leading to more succinct code. Among these new language features is a shorthand for defining simple lambda functions, useful when the lambda only does an atomic expression on the lambda argument.

The shorthand works for single property access, nested property access, method calls, and indexers. It also can be used outside of a function call to define a standalone lambda for future usage.

A copy-and-update enhancement for nested records lets developers use dot-notation to reach lower levels of nested records and update them. A while! feature presents a refined approach to loops in computation expressions, minimizing boilerplate and maximizing clarity, Microsoft said.

Other new features and enhancements in F# 8:

  • For compiler performance, two areas have received special attention: incremental builds of large graphs of projects via the ReferenceAssemblies feature and CPU parallelization of the compiler process.
  • To enhance FSharp.Core standard library inlining, changes have been made to inlining for functions in the Option and ValueOption modules.
  • Quality-of-life improvements have been made such as support for trimming compiler-generated code. Discriminated unions and anonymous records now are trimmable. Code using printfn “%A” for trimmed records now is trimmable.
  • Updated and new diagnostics in F# 8 include the addition of 34 new diagnostic errors and messages since last year’s F# 7. These are errors, warnings, and information messages reported by the compiler.
  • As part of work needed to improve parser recovery, F# 8 turns on a strict indentation mode, which respects the rules of the language for indentation and reports an error in invalid scenarios where previous versions of the language only reported a warning.
  • Improved support is offered for existing interpolated strings, intended to make it easier to work with these strings. Interpolated strings provide a convenient way for developers to embed F# expressions into string literals.
  • Autocomplete improvements have been made in scenarios such as record completions in patterns, union fields in patterns, and expressions in enum values.
  • String literals have been updated for usages of built-in printing functions including printfn and sprintfn.
  • Numeric literals now can be expressed using existing operators and other literals. The compiler evaluates the expression at compile time and stores the resulting value in the produced assembly.
  • Definition of multiple intersected generic constraints using flexible types has been simplified.
  • The fixed keyword, for pinning memory in low-level programming scenarios, has been extended for use in more circumstances, such as any type ‘a when ‘a has an instance/extension method GetPinnableReference : unit -> byref<'t or GetPinnableReference : unit -> inref< >‘t>.

Copyright © 2023 IDG Communications, Inc.


Leave a Reply

Your email address will not be published. Required fields are marked *