Volume 26 Number 08
Editor's Note - F-Sharp Focus
By Keith Ward | August 2011
F# is a growing and increasingly important programming language. Many developers are using it every day; many more should be using it on a regular basis.
Being busy types, though, it can be difficult to find time to learn a new language—it’s hard enough getting the daily work done. That’s why I’ve asked Don Syme, the creator of F#, and his crack team to answer some common F# questions I hear folks asking.
Why was F# created? What need does it serve?
The modern enterprise has a range of software needs that don’t fit the traditional “business apps” IT model. For example, financial modeling involves quantitative finance domain experts (“quants”) who need to write and deploy models that analyze the value and risk of market positions. You can think of these people as one example of a domain-oriented programmer.
There are many similar examples in modern enterprises and start-ups, including machine-learning, statistical, parallel, scientific and algorithmic experts; these people are often at the core of modern software teams.
Domain programmers are always on a search for tools that improve productivity, performance and robustness in balance and often utilize analytical scripting languages as part of their work. Dynamically typed scripting languages are great in many ways, but can lead to real problems. For example, they can lead to problems as applications grow in size. Often, they don’t have good visual tooling—for instance, no IntelliSense—and may not be very performant when fresh code is written in the language. Finally, components don’t live in isolation, and ultimately need to be deployed as encapsulated software components in the context of larger .NET systems.
When you look at examples across the industry, the common need is for a simple, succinct, efficient and typed language that allows math-oriented and domain experts to work in their problem domain—rather than get lost in a sea of object-oriented (OO) class-oriented code—while still contributing professional software components that interoperate well. That’s where F# fits in. Ultimately, this kind of tool makes domain experts happier and more productive members of software teams.
The special thing about F# is that we manage to get most of the benefits of dynamic language (rapid development and succinctness) while also still retaining the benefits of strongly typed languages (robustness, performance and visual tooling), all in the context of a highly interoperable platform.
What are the most common scenarios for use of F#?
F# can be used for just about anything, but it excels at what we call “analytical component development.” This includes financial- and market-analysis engines (including event-driven ones), server-side machine learning components and other data-rich analyses. There are several good case study examples available on the Microsoft Web sites.
Some interesting examples outside finance are the uses of F# in energy trading, Bing advertising, Project Emporia (a personalized news-selection service based on machine learning techniques) and in the artificial intelligence engine of the “Path of Go” game. All of these show where F# excels: analytical engines in the context of professional .NET software delivery.
What are the main advantages F# has over C# and C++?
F# differs in many important ways from C#. Technically speaking, some of the things you’ll notice are the functional-first methodology and language features (such as tuples, lists and pattern-matching); the strong focus on immutable data; the inclusion of key typing features relevant to scientific and numerical programming (including F# units of measure); the increased use of expressions as a form of software re-use (including language features such as object expressions); the succinct representation of OO programming; the declarative and compositional model of asynchronous programming (a version of which is appearing in the next version of C#); and the inclusion of a dynamic interactive compiler called F# Interactive for scripting.
F# can be surprisingly intuitive for C and C++ programmers. Perhaps the thing they’ll notice most is the immediacy of programming with F# Interactive—some C++ people are surprised that it’s so easy to get your hands on data and play with it in a strongly typed language, while still getting great performance. Software becomes fun and explorative again.