BT

Your opinion matters! Please fill in the InfoQ Survey!

F# Deep Dives Review and Author Q&A

| Posted by Sergio De Simone Follow 5 Followers on Feb 18, 2015. Estimated reading time: 7 minutes |

A note to our readers: As per your request we have developed a set of features that allow you to reduce the noise, while not losing sight of anything that is important. Get email and web notifications by choosing the topics you are interested in.

 

F# Deep Dives, edited by Tomas Petricek and Phillip Trelford, is a new book aimed at showing what is the business value that using F# brings in practice. The book presentats 11 real industrial scenarios and the way F# allowed field experts to solve them using a functional-first approach.

The book covers each case study in a separate chapter written by a different author. Each chapter starts by providing a short description of the goal and the difficulties involved, then goes on describing in detail how F# allowed to reach that goal and explaining the approach chosen to solve the problem. Case studies range across diverse domains from game development to financial systems, from rich user interfaces to social network analysis, from textual parsing to agent-based programming. In many cases, where applicable, the described solutions involve the integration of multiple technologies in addition to F#, such as C#, R, and JavaScript; data formats, such as CSV, JSON, and XAML; and development practices, such as unit testing, performance analysis, acceptance testing, etc.

The book is not aimed at a begineers’ readership and it presupposes a basic knowledge of F#, although the basics of the language are covered in an appendix. Each chapter is fully self-contained and can be read on its own. Still, chapters are ordered according to the complexity of the scenarios they solve and to the breadth of technologies they encompass.

Each chapter is accompanied by a project containing the full code and related data. All projects are hosted on GitHub.

InfoQ has reached out to Tomas Petricek to ask him a few questions about the book and F#.

InfoQ: Hi Tomas, could you describe how this book was born? Why was it important to write it?

The book was born to answer one question that we’ve heard quite a lot and that is “How do I actually use F# on a larger project in production?” Both me and Phil knew a large number of people who are successfully using F# in production and so we wanted to share their experience with the broader community. This is also what makes the book different from many other F# books out there. It is based on real use cases of F# in the industry and it also illustrates numerous different approaches to adopting F#.

InfoQ: The book approaches its “deep dives” in a progressive way, starting with simpler cases and moving on to more complex ones. What criteria led you in deciding which topics to include?

We actually worked the other way round. We first collected chapter ideas from F# users in the industry we know and then grouped the chapters in logical parts and sorted them (somewhat) by complexity. So, the book is not really following a plan, but instead reflecting the areas where F# is being used.

InfoQ: Of all the scenarios presented in the book, which one could be close to a kind of “killer scenario” for a language like F#? For which kind of application do the language features really provide a valuable advantage over other languages, both functional and imperative?

We tried to cover as broad range of topics as possible - so there is no single unifying theme in the book, but one area that I find very interesting is data science. F# has type providers (Chapter 6), which is a unique feature that makes data access super easy and it lets you easily write complex algorithms (Chapter 4) and visualize and explore the results (Chapter 5). And there is an increasing number of great open-source libraries for doing data science with F#.

InfoQ: You have used F# since its early versions at Microsoft Research. Could you tell us something about your experience with F# at the time and what its value was for you?

Yes, I wrote my first blog post about F# back in 2006 (but don’t read it, because the code does not work anymore!) During my first internship in 2007, I worked on a project for translating F# to JavaScript, which later inspired tools like WebSharper and FunScript.

This was a lot of fun - I did some work on the project during the week and quite often, I wrote various crazy workarounds to make things work. Then I showed what I did to Don Syme. After the weekend, I got a new version of the F# compiler and libraries from Don and nothing worked! But the design was much nicer, so I could get rid of all the workarounds. So, the experimentation probably helped make WebSharper and FunScript much nicer.

InfoQ: F# belongs to a group of languages that have been enabling a sort of “functional renaissance” for a wide range of applications. How has F# contributed to this renewed interest for functional languages?

For me, the main thing is that F# is not strictly functional. We like to call it “functional-first”, which means that functional style is preferred, but it works really well with other paradigms too. I think this is really important as it enables using F# smoothly as part of large projects.

InfoQ: F# is tightly tied to the .NET platform. How do you see the recent step of Microsoft in the direction of open sourcing large parts of it? What could this mean for F# future?

The F# community is very open-source friendly and F# itself actually works really well on Linux and Mac using Mono and on iOS and Android using Xamarin tools. So, it is great to see Microsoft contributing to this space too!

InfoQ: F# is in constant evolution. The book uses F# 3 and F# 4 is already in the pipeline. How would you describe or synthesize F# evolution? In what sense has it become a more mature language through the years?

I think you can best see the maturity of the language if you compare how much the language changes and how the libraries evolve. Type providers in F# 3 did not require large changes in the syntax of the language, but they are adding enormous power and I think this is a good direction for the future. So, I think there is a lot more that can be done in terms of building great F# libraries or extensions like type providers.

InfoQ: What is the interplay between C# and F#? Would it be correct to say that C# is Microsoft’s flagship language while F# is a test bed to experiment with new ideas that can eventually make it into C#?

I don’t think “test bed” is quite the right word here. The C# team is obviously watching F#, but F# is really a separate language with a different background and a different programming style. This means that features like type providers fit really well with F#, but are trickier in the C# context. Even async, which first appeared in F# and was later added to C# shows this - there is quite a number of things that don’t fit as well into C#.

InfoQ: You also do F# consulting, with fsharpWorks. In which fields is the software industry adopting functional programming, and specifically F#, more and more?

I worked quite a lot with BlueMountain Capital, which is a New York based hedge fund and active contributor to the F# open-source eco system. So, finance is certainly one of the domains. But if you look at the F# Testimonials, you’ll see a lot of diversity. The most fascinating example is, no doubt, Goswin Rothenthal’s use of F# for the design of the roof of the Louvre Abu Dhabi building.

InfoQ: In last TIOBE Index (Feb 2015) F# ranked as the most used functional language, with a popularity that is slightly less than the half of Python’s. What could be some key factors for an even larger adoption of F# in the future?

The TIOBE index is fun, but you cannot really call it an objective metric. That said, I think it reflects some of the trends in F# popularity. Over the last year, there was a new user group appearing somewhere in the world almost every week. The next big thing that is certainly going to help is the newly started F# Software Foundation, which is now a non-profit organization that aims to promote and advance F# and the community around it.

Besides the two co-editors, the book is authored by known F# experts such as: Chris Ballard, Keith Battocchi, Colin Bull, Chao-Jen Chen, Yan Cui, Johann Deneux, Kit Eason, Evelina Gabasova, Dmitry Morozov, Don Syme.

About the Book Author

Tomas Petricek discovered functional programming as a student at Charles University in Prague. He has been a Microsoft C# MVP since 2004 and is one of the most active members in the F# community. In addition to his work with F#, he has been using C# 3.0 in a functional way since the early previews in 2005. He is currently a graduate student at the University of Cambridge and has worked on several projects with the F# team at Microsoft Research.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT