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. ®

Similar topics

Other stories you might like

  • India reveals home-grown server that won't worry the leading edge

    And a National Blockchain Strategy that calls for gov to host BaaS

    India's government has revealed a home-grown server design that is unlikely to threaten the pacesetters of high tech, but (it hopes) will attract domestic buyers and manufacturers and help to kickstart the nation's hardware industry.

    The "Rudra" design is a two-socket server that can run Intel's Cascade Lake Xeons. The machines are offered in 1U or 2U form factors, each at half-width. A pair of GPUs can be equipped, as can DDR4 RAM.

    Cascade Lake emerged in 2019 and has since been superseded by the Ice Lake architecture launched in April 2021. Indian authorities know Rudra is off the pace, and said a new design capable of supporting four GPUs is already in the works with a reveal planned for June 2022.

    Continue reading
  • Prisons transcribe private phone calls with inmates using speech-to-text AI

    Plus: A drug designed by machine learning algorithms to treat liver disease reaches human clinical trials and more

    In brief Prisons around the US are installing AI speech-to-text models to automatically transcribe conversations with inmates during their phone calls.

    A series of contracts and emails from eight different states revealed how Verus, an AI application developed by LEO Technologies and based on a speech-to-text system offered by Amazon, was used to eavesdrop on prisoners’ phone calls.

    In a sales pitch, LEO’s CEO James Sexton told officials working for a jail in Cook County, Illinois, that one of its customers in Calhoun County, Alabama, uses the software to protect prisons from getting sued, according to an investigation by the Thomson Reuters Foundation.

    Continue reading
  • Battlefield 2042: Please don't be the death knell of the franchise, please don't be the death knell of the franchise

    Another terrible launch, but DICE is already working on improvements

    The RPG Greetings, traveller, and welcome back to The Register Plays Games, our monthly gaming column. Since the last edition on New World, we hit level cap and the "endgame". Around this time, item duping exploits became rife and every attempt Amazon Games made to fix it just broke something else. The post-level 60 "watermark" system for gear drops is also infuriating and tedious, but not something we were able to address in the column. So bear these things in mind if you were ever tempted. On that note, it's time to look at another newly released shit show – Battlefield 2042.

    I wanted to love Battlefield 2042, I really did. After the bum note of the first-person shooter (FPS) franchise's return to Second World War theatres with Battlefield V (2018), I stupidly assumed the next entry from EA-owned Swedish developer DICE would be a return to form. I was wrong.

    The multiplayer military FPS market is dominated by two forces: Activision's Call of Duty (COD) series and EA's Battlefield. Fans of each franchise are loyal to the point of zealotry with little crossover between player bases. Here's where I stand: COD jumped the shark with Modern Warfare 2 in 2009. It's flip-flopped from WW2 to present-day combat and back again, tried sci-fi, and even the Battle Royale trend with the free-to-play Call of Duty: Warzone (2020), which has been thoroughly ruined by hackers and developer inaction.

    Continue reading

Biting the hand that feeds IT © 1998–2021