got net?

Kevin Hazzard's Brain Spigot

About the author

Welcome to Kevin Hazzard's blog.
E-mail me Send mail

Recent posts

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Why F# is So Important to the Future of Software Development

I am a big C# fan. As a general purpose, imperative, object-oriented language, C# has begun to take on some functional language capabilities that I like very much. LINQ just rocks, for example. And LINQ is a very functionally-oriented technology. It's so easy and expressive to get set-oriented work done using LINQ and it's functional underpinnings are the reason why.

I have been thinking a lot recently about why F# might be important to the future of all software development. If you think about it, there's really little in F# that doesn't already exist in other languages like OCaml and Haskell. But F# is significant and different because Microsoft is behind it and because of the tight integration with the .NET framework. But beyond the who of F# is the why of its importance. And the why, in my mind can be summed up with these five bullet points:

  • ORMs are failing to gain mindshare not because they aren't good domain modeling tools (as some complain about). They are failing because the imperative, object-oriented languages in which we use ORMs are unfriendly to sets and tuples.The database is full of nothing but sets and tuples. So we read them into objects and wonder why there's an impedence mismatch. F# is not only set and tuple friendly. You can't really think properly in F# without these first-class constructs.
  • Domain Specific Languages (DSL) are becoming more and more important in the marketplace. And functional languages are great for building language compilers. Language parsing into discrete intermediate forms is a problem that benefits greatly from the lambda calculus and functional decomposition. F# is appearing at the right time and place in history to serve in the critical role of helping us to build new DSLs.
  • Many of our time-honored design patterns are workflow-oriented. So, why do we shoe-horn them into data structures? Workflows are, by definition, composed of functions invoking higher-order functions. Step 3 invokes on the result of Step 2 which invokes on the result of Step 1. So, why do we code the Visitor Pattern to walk a tree into a data structure like an object? It makes no sense, really. F# allows us to revisit these time-tested patterns and view them in the light of functional decomposition. And the result will allow many who have been unable to grasp those patterns though an imperative lense to "get it" for the first time.
  • Service-Oriented Architecture (SOA) is predicated on the idea that strict operation contracts exist that take discrete, strongly-typed inputs and return strongly-typed results. F# rolls like that. There's no object-orientation in SOA, per se. In fact, SOA sort of shuns OOP to a certain degree. And good service design also avoids side effects, another tenet of functional languages. So, if SOA is important, and I think it is, then languages that follow the patterns of SOA will also be important in building compliant architectures. I think good architects will recognize the pattern and find interesting ways to expose services via F#. We will code the guts of services in C# and Java in the future. No question there. But the workflow, scheduling and execution core of SOA will be based on functional languages like F# instead.
  • Moore's law is breaking down. Intel and other companies are all moving to put more computing cores into their packages because they can't scale computing power vertically beyond what modern physics will allow. So, they are scaling horizontally to meet customer demand. The problem with this concept is that the marketplace isn't really ready for this kind of change. Massive pools of threads attempting to use Many Reader, Single Writer Mutexes with Starvation Avoidance ain't gonna work, my friends. We need a new model that will make parallelism invisible. But for parallel computing to become invisible, we need to move to a model that doesn't require the programmer to be involved in locking and serializing access to their code. F# is ready to help us think that way. And it's .NET! Beauty, eh?
These ideas aren't all mine. I borrowed heavily from Amanda Laucher and Ted Neward. But, I've added my twist, ideas and opinions of course. What you do think F# means for our industry and our profession? I'd love to hear from you.

 


Posted by kevin on Wednesday, September 17, 2008 6:30 PM
Permalink | Comments (4) | Post RSSRSS comment feed

Comments

Marius Filip Romania

Friday, September 19, 2008 5:37 AM

Marius Filip

In the respect of concurrency, Erlang is king. Maybe Microsoft will extend F# to embrace the message-based threading model of Erlang, model which is not marred by the mutex problem.

In terms of high-level languages, there is one important guy missing in the group photo, and that is Prolog. Logic programming hasn't yet spoken its last word and it is surprising that Microsoft, after an initial attempt with Visual Prolog, hasn't done anything yet in this area.

And, by the way, logic programming is a closer representation of relational sets and tuples than the functional model.

Kevin Hazzard, MVP United States

Friday, September 19, 2008 9:16 AM

Kevin Hazzard, MVP

You're right Marius. Logic programming has a lot to add to the space. I am anxious to see third parties contribute in that respect.

Regarding D#, the .NET CLR is so heavily object-oriented and imperative that a lot of what Erlang shows us how to do correctly for concurrency is still difficult, even with F#. But I think F# is a compromise and as I said in part 4 of my F# tutorial series, some will say that it's not functional enough, i.e. too imperative to be a truly useful functional language. Of course, that all depends on what you decide you should use from the CLR and how you architect your own F# code. You can be purely functional in F# if you want to and I would argue that in going so, the concurrency potential of F# approaches that of Erlang.

Great comments. Mulţumesc, Marius!

Stephen Roughley United Kingdom

Thursday, May 07, 2009 7:30 AM

Stephen Roughley

I'm fairly new to the concept of functional programming and have been hearing more and more about F# of late. I have read up on it, written some examples following tutorials and have pondered it for a couple of months now. It is being hyped by more and more experts in the field of enterprise application debelopment so I am sitting up and listening. The problem is that I am trying to understand how functional programming can be useful for me as a developer who writes business software and I'm just not getting anywhere.

Taking your point about ORMs, it seems as if you are saying that F# could be a better tool for writing a business layer simply because it is better equipped to deal with sets and tupples. This doesn't seem to make much sense to me as a domain model is made of webs of related entities that have varying characteristics of behaviour and state. This is a practical and efficient means of abstracting your usual business systems.

What I am struggling to see is how functional languages could be used to define these systems. I can see from your point that perhaps functional languages could be well used to build an ORM, but, from what I have read, their ability to handle database access, structure and state is limited and would make building a business layer very complicated and even more abstract. I am very interested in the concept of functional programming, but until someone can demonstrate to me how it can be effectively used to write an LOB database application I'm just not going to be convinced by its current hype. Perhaps you could point me in the right direction?

Kevin Hazzard United States

Thursday, May 07, 2009 10:20 AM

Kevin Hazzard

Thanks, Stephen. Great comments. The bullet point regarding sets and tuples addressed the fact that while databases are generally very good at manufacturing ad hoc schema, statically-type languages aren't so adept at expressing semi-structured data. LINQ and anonymous types help C# to be more expressive in this respect. Unfortunately, anonymous types are not very transportable. Having transportable and immutable lists, maps, sets and tuples, as F# provides, makes it possible to push data through a functional pipeline without the fuss of using code generation as many ORMs require. It's not that ORMs are bad. I just don't like that there's still a lot of manual steps, usually involving the generation and recompilation of fairly brittle code, between me and my data.

Take a look at the Jalapeño technology that InterSystems developed for expressing POJOs as Caché database objects. That's the right way to think about Object Relational Mapping, in my opinion, because it eliminates the boundaries between the two systems. The EntitySpaces products also have this natural feel to them, too. The collection classes in F# don't provide everything I want but they add a level of expressiveness that's missing from the rest of the .NET ecosystem without the introduction of third-party products.

I totally agree with you concerning the lack of good examples for F# LOB applications. I am working on some of them now and hope to blog about them soon. Stay tuned.

Comments are closed