background

F# and the Meaning of Life

When you get older, you stop proving yourself and start to feel like something is wrong, something is missing in your life. You still lack one thing and sooner or later you understand that it’s the meaning of life. This issue isn't trivial. There are many variants of answers to the question of 'what is the meaning of life', but I think that the less metaphysical is the proper one: to take pleasure in life.

Work is a big part of most people's lives. So, one of main goals is to enjoy working. The joy of work, in its turn, hardly depends on the right working tool. For a programmer, it’s some programming language.

For a long time it seemed to me that the most pleasant language to program was Python.  It has been observed that after several years of coding in Python it's almost impossible to return to Java or C#. It definitely can be considered a proof of Python being optimal.

On the other hand, Python is far from being ideal.  Unfortunately it has several fatal flaws:

1. It is unable to natively use multiple CPU cores due to his global interpreter lock (GIL). The workarounds such as PyParallel require their own libraries (e.g. NumPy and so on).

2. It doesn't have tail recursion optimization (TCO), and it never will. But it is essential to functional programming style.

3. Python can’t distinguish between declaration and usage of a variable.

4. Python is dynamically typed, which can introduce certain classes of runtime errors.

The  most  amazing  fact  is  that  it  turns  out  that  there  is  a  programming  language  having  all the advantages of Python and nevertheless, free from its drawbacks. This programming language is F#. His powerful type inference and natural tuples handling permit to obtain almost such clear and concise code  as  in  case  of  dynamically  typed  languages,  remaining  statically  typed.  No  annoying  "self." and "return" in case of ordinary functions ("return" means in F# quite a different thing).

At the same time F# is considered to be a non-GUI programming language. Really, windows and controls in F# can be created only dynamically.  Indeed, there is even no template for F# Windows application in Visual Studio. Nevertheless, I still don’t consider this flaw to be fatal.  F# Interactive can help a lot in designing forms.  This GUI project (desktop app in the video home) written entirely in F# and you can't tell it from a C# GUI project.

So the goal of enjoying working is achievable and realistic.