This article is more than 1 year old

We're making F# more normal as a language, says its creator

Loved by users, impenetrable to others, but 6.0 update aims to change that

F# designer Don Syme said this week that the new version, 6.0, aims to be "more normal as a language" in order to improve take-up.

There was a telling moment in the .NET Conf virtual event, just after the presentation of F# 6 from Syme and his colleague, principal program manager Kathleen Dollard. A developer asked: "What is the best way to do optional values in records in F#?"

Tireless .NET evangelist Scott Hanselman, with commendable honesty, acknowledged that "I know how to say the words but I don't know what they mean," while even Dollard was uncertain how to answer. "Just use the F# option value," said Syme. "Then you can create a helper method to create the record where you can take optional arguments."

'I know how to say the words, but I don't know what they mean'

'I know how to say the words, but I don't know what they mean'

The problem is that while those who know F# love the language, it is somewhat impenetrable to others. Several features in F# 6.0 are intended to address this. One is the indexing syntax. Until now, an array element was accessed by expr.[idx] with a dot between the expression and the index. Now, in F# 6, developers can write expr[idx] as they can in C#, Java or C.

"We made the revision for F# to be more normal as a language," said Syme in the presentation. "That dot was losing people for no reason. If you show F# machine learning code for example, to particular kinds of audiences, where you do a lot of indexing, a lot of slicing, the first thing they see is the dot." They say, 'I'm not going to listen any more'."

Along similar lines, there is a new task keyword. Prior to version 6.0, "async programming in F# is extremely nice, it has lots of lovely properties, but it differs from .NET tasks in some crucial ways. They are ways which created a lot of dissonance between async programming and .NET libraries which were using Tasks," said Syme.

The F# Async module includes methods like StartAsTask and AwaitTask to enable interoperability. Now in F# 6.0, "we decided to also let you do Task programming directly," said Syme. According to the official list of new features, "the performance of task {...} is much better" than using async.

"The themes of F# 6 are the same as the themes of F# all the way through," said Syme, these being "succinct, robust and performant." That said, Syme added that "we have changed the way we talk about F#," no longer as a functional language but "we let the properties of the kind of programming you can do with F#, which includes functional programming, and many other kinds of programming."

Other new features in F# 6.0 include resolved inconsistencies in indentation-aware syntax, more support for implicit conversions, new collection functions, and support for consuming interfaces with default implementations (a C# feature).

Tooling improvements include pipeline debugging, where pipelining is the passing of the output of one function to be the input to another. Pipeline debugging lets developers set breakpoints for intermediate stages in the pipeline.

The debugger will also now show the value of shadowed variables, meaning variables whose values are not visible because a new variable with the same name has been declared later.

There is also what Dollard calls "dramatic improvements to Compiler/IDE-tooling perf/scalability." In addition, F# 6.0 benefits from performance improvements in the .NET runtime.

F# emerged from Microsoft Research in Cambridge, starting with a post from Syme on the Caml mailing list in 2001 asking whether "there are people with some time to spare who would be keen to work with me toward a .NET version of OCaml?"

The full early history can be found here [PDF]. Does the F in F# stand for "functional"? "Sort of," Syme told us. "F is partly for 'System F', a core lambda calculus – but of course that calculus was named after Function. The F# community say 'F# is for fun' which is a cute pun on the keyword 'fun' too."

F# 1.0 appeared in 2005, and Syme made an impact in programming communities with demonstrations of how concise it was compared to most languages, in certain scenarios, for code that did the same thing. It soon won favour in the financial community because of its efficiency and because functional programming is less error-prone, avoiding potentially expensive bugs.

Barriers to wide adoption will remain, not least because F# project types in Visual Studio are limited to console, library, and web applications, compared to a full range of project types for C# or Visual Basic. There is support for .NET interactive notebooks, though, and typing dotnet fsi opens an interactive session anywhere the .NET SDK is installed.

F# is also notable for its good standing in the open-source community. The F# Foundation has a clear legal structure and the language evolves via RFCs, a well-established open process. F# also has excellent support for the cross-platform Visual Studio Code, via a set of crowdfunded tools called Ionide.

The language remains niche – although with an enthusiastic following. StackOverflow's annual survey puts usage at just 0.97 per cent of respondents, but turn to the "most loved" section and it scores 62.44 per cent, just above C#. Boosting its usage is a challenge, though the changes in F# 6.0 show that the community would love for .NET's best-kept secret to be better known. ®

More about

TIP US OFF

Send us news


Other stories you might like