An Overview of Functional Programming

 

Obscure syntax, missing looping constructs, unknown programming patterns, the lack of libraries or documentation, there are a lot of reasons discouraging imperative programmers to start learning and using functional programming languages.

Microsoft released in 2002 F#, a multi-paradigm programming language, targeting the .NET Framework, that encompasses functional programming as well as imperative and object-oriented programming disciplines to help address these issues.

F# is first class .NET language, it has a complete access to the .NET Framework, can consume and generate classes, can be either interpreted or compiled to .NET assemblies, and it is well integrated to the Visual Studio Microsoft IDE.

Through a series of articles I would like to introduce some of the powerful F# features and features common to functional languages:

  1. Recursion - Where are my for/while loops?
    Discussion about recursion and why loops are rarely used in functional programming.
  2. List – Cons, Car, Cdr & Co
    Showing the importance and the power of list processing in functional languages.
  3. Pattern Matching – Be Explicit
    A great feature to write clear and concise code.
  4. 1st Class Functions – Power is in simplicity
    What does it mean to have first class functions, partial application, how to build abstraction with functions.
  5. Generic Parameters – Static typing without typing
    Presentation of generic parameters which will help you to make generalist and reusable algorithms.
  6. Sequences – Being lazy is allowed
    Usage of laziness to create on demand computations, and infinite streams of data.
  7. Workflows – A Monad alias
    Introduction to the concept of monads, how they can be built in F# and what the power they provide. 
  8. Quotations – Say “your name”
    An overview of meta-programming in F#.
  9. Continuations – Future is yours
    Continuations allow non lexical escapes, it is then possible to get coroutines , exception handling, recursion optimizations and more.
  10. Macros – Do you like parenthesis?
    This article will presents IronScheme, a Scheme implementation for the .NET, in order to speak about macros in functional programming

Learning functional programming when coming from the imperative world is not something easy, it takes time, but I encourage all of you to try it, since this mind shift will not only help you become better programmers by mastering new concepts, but it will also bring you a lot of fun!

Comments

  • Anonymous
    January 08, 2012
    That's a great article as functional programming (preferably F#), is on my list of things to learn after C# and Python/Iron Python.  

  • Anonymous
    January 08, 2012
    One of the very next things I've to learn this year. Could you suggest us where we can find more reources?

  • Anonymous
    January 09, 2012
    The comment has been removed

  • Anonymous
    January 09, 2012
    The comment has been removed

  • Anonymous
    January 09, 2012
    @cron22: Yes, there is IronScheme, I have been watching this project for more than one year, I developed several personal projects with it, it is a nice implementation of scheme. Some .NET integration features are still lacking (you can consum but can't create .NET compatible classes, and you cannot use .NET generics), however leppie, (IronScheme author alias) is taking any feedbacks and is really reactive when it is about improving his project. I will introduce Ironscheme in my article about macros.

  • Anonymous
    January 10, 2012
    That would be great.  You really should.  It seems that out of all the iron you guys have forged (no pun intended),

  • Anonymous
    January 13, 2012
    Thank you.  One of the most well written and easy to understand introductions to Functional Programming that I have come across; great job!

  • Anonymous
    January 15, 2012
    I agree very much with that statement.