AJ's blog

April 27, 2008

I can’t help but notice…

… that functional programming might be the next big shift in general purpose development paradigms.

The other day I realized a trend that may be decisive for the evolution of our development environment in general: Functional Programming! It is not that I did not see the symptoms. It is just that it took that long to realize the breadth of it. (I’m in good company, though.)

Yesterday…

… it started quite unobtrusive.

We got generics and with them (hardly mentioned as more than syntactic sugar) type inference.

In retrospect it even seems misleading that generics were discussed as something akin to C++ templates. The technical differences may seem superfluous at first, yet some advanced techniques with templates, orthogonal libraries such as STL (only recently available as STL/CLR for managed code) and template meta-programming have never been broadly considered for generics. Rather type inference plays a major role with generics, effectively pushing the burden of type safety from developer to compiler.

We got anonymous methods, which was at that time hardly worth the effort and not at all a justified language change — if looked at in isolation.

We got iterators, which was again a feature no one had missed, much less asked for.

Several features, seemingly unrelated, some rather tiny unmotivated additions to the language.

Today (the obvious)…

… we have LINQ.

LINQ has been introduced at the PDC 05 by Anders Hejlsberg et al. as kind of “complied SQL statements”, “type safe SQL”, and “unified query language”, thus the name of course.

The language features that make up LINQ rely on the above language features. And with LINQ those pieces suddenly fall into shape. Type inference for anonymous types and together with generics as general foundation, anonymous methods for lambdas, iterators for deferred execution. A concise system.

And this is how LINQ is seen by many people: Type safe queries. Something to replace ugly ADO.NET code over SQL strings with beautiful and compiler checked C# statements. Who can blame them, that’s how it got introduced.

What those people miss is the less obvious force behind LINQ. It’s functional programming, as Anders itself explains — not the other way round, as presented in “The Evolution Of LINQ And Its Impact On The Design Of C#”.

It’s not that the trend to functional programming is kept secretly. Matter of fact, the term is mentioned quite frequently in relation to LINQ. And there’s other evidence, like the new .NET language F#, incidentally written by Don Syme, the man who built generics for .NET. And there’s enough bloggers out there, talking about the topic.
It’s more that the average corporate developer, the kind that has more than enough to do getting his job done, is not directly exposed to this information. Therefore he picks up only occasional hints at best, not connected, not nearly enough to identify a larger trend. Many of them may not even be aware about the degree to which they have already exposed to functional programming bits and pieces.

Today (the not so obvious)…

… there is a lot of talk around functional programming going on in the blog sphere. Some examples:

Regarding lambdas have a look at Wes’ blog to learn about currying, continuations, monads. Other bloggers have written about other language features (e.g. extension methods). Luca tries to bring F# features to C#.

Also there has been a lot of noise around one of the tenets of functional programming: immutable data types. Just as we got new collection classes with generics, we may get immutable ones sometime in the future.

If you like to read up on immutable data types, Roy has compiled a list of related blog posts; I found Erics series to be the best, as he addresses not only the purpose but also the feasibility (consider the insolence, a list that does not change, how can that be feasible?). And he addresses null values (not exactly part of the functional universe) better than the others.

Another interesting application is MoQ (if not by itself, then as an example for the functional approach), a LINQ based mock framework. It may serve as indication that even stuff that is not directly related to functional programming may come in a functional shape.

Tomorrow…

… — and this is strictly a personal guess — the trend will continue. If anything it will diverge in different areas. Functional programming in general and F# idioms in particular may contribute to our languages, the patterns we use, and the libraries. F# may not only be the first functional language to decisively enter the .NET environment, it may be the very first functional language with at least the potential to become a mainstream language

The driving force behind this is something that Anders hinted at it in his interview above, and that Pat Helland pointed out quite clearly at the TechEd: The future is parallel. And functional programming is so much more suited to parallel processing than imperative programming. Matter of fact, Parallel LINQ (PLINQ) is already working in that direction.

Right now…

… that’s enough gazing in the crystal ball. What’s the consequence (provided you share my view)? Today probably nothing. None of my daily work is affected, beyond using LINQ as a nice tool. Tomorrow perhaps still nothing, as I may be totally wrong. All I can recommend is this: Try to see the bigger picture behind LINQ and keep watching for the trend. For if it’s the other way round, you may be tomorrows next VB guy, like the one in the next cubicle that never mastered inheritance and exceptions.

As an afterthought: I’m not aware that this functional programming trend happened somewhere outside the Microsoft space. This is contrary to the dynamic languages trend. And I’m honestly not sure what the implication is.

That’s all for now folks,
AJ.NET

kick it on DotNetKicks.com

Advertisement

9 Comments »

  1. see also http://nemerle.org/Main_Page

    Comment by dot — April 28, 2008 @ 4:17 pm

  2. Interesting but I’m not sure that functional programming solves the problem of the sequential nature of many algorithms i.e. a previous step must be checked before the next step can be completed. Some algorithms can only be parrallelized so much regardless of the programming paradigm. Superior parrallel performance probably will come from quantum computing instead since it allows for the bit state to be in the 0 and 1 state all at once…

    Comment by ton — April 28, 2008 @ 5:32 pm

  3. […] I can’t help but notice… […]

    Pingback by Wöchentliche Rundablage: ASP.NET MVC, Silverlight 2, jQuery, CSS, C#… | Code-Inside Blog — April 28, 2008 @ 9:25 pm

  4. […] I can’t help but notice… […]

    Pingback by Weekly Links: ASP.NET MVC, Silverlight 2, jQuery, CSS, C#… | Code-Inside Blog International — April 28, 2008 @ 9:25 pm

  5. @ton: you state that FP isn’t the solution to sequential algorithms then immediately state that superior performance will come from Quantum Computing?!

    Riiiiight 😉

    Comment by OJ — April 29, 2008 @ 1:54 am

  6. Concept-oriented programming:
    http://www.jot.fm/issues/issue_2008_03/article2/
    http://conceptoriented.org/papers/CopInformalIntroduction.html

    Comment by the_next_big_shift — April 29, 2008 @ 2:42 pm

  7. I found this post, and especially the interview with Anders very interesting!
    As for the fp trend beeing ms exclusive: java is lacking LINQ but i am sure that this will change. Regarding F# there is Scala and i have high hopes for that.

    Comment by reader — April 29, 2008 @ 9:16 pm

  8. Nice article with good links to other articles.

    What I think is revolutionary is that programmings starts to get Set-based with Linq. With databases I still wrote stored procedure “loop-like”. While participating in SQLTeam.com forums I learned to think set-based. With Linq writing vb.net code is now more set-based.

    In retrospect this is so trivial (moving to set-based or functional programming), IMHO this is the future.

    Thx.

    Henri Koppen

    Comment by Henri Koppen — October 22, 2008 @ 10:50 am

  9. […] Mit C# 3.0 hielten die fehlenden Bestandteile und LINQ als Begriff Einzug in die Sprache. Iteratoren und andere vorher vorhandene Features wurden in einen größeren Zusammenhang gestellt, und funktionale Programmierung als konzeptioneller Unterbau wurde sichtbar. […]

    Pingback by Imperativ oder funktional – praktische Auswirkungen - SDX AG — November 27, 2017 @ 10:02 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: