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