F# Compilation Speed

Just recently, I was watching the fsharpConf2023. There was a very interesting talk from the CEO of Darklang, Paul Biggar. Darklang was originally created using OCaml. Later on they decided to switch to F# and the talk is about their experience with F#. Paul Biggar specifically discussed the goods and the bads of F# as a language to use in production. One of the comments that stood out to me was the compilation speed of F#.

Darklang comparison of OCaml with F#

The dislike of the compilation speed got my attention as I never experienced problems with compilation speed. And why was that? It could be I only have been working on small projects. But the project I am currently working on has a compilation time of 16 secs, and that is not really fast. Why then is it that I never experienced this as a real problem?

Well, I obviously do not run a lot of compilation on my code while developing. What I typically do is that I just take all the code I need for development and either reference or load them to a script file and use that as a starting point to enhance/change or add to my code. I even will copy over all the code for a specific project, paste that in a single script file and start working on that. To me that is an incredible powerful way of working with F#, as it feels that I can directly communicate with my code.

I also often see youtube videos on F# that show you code in a regular “fs” code file that has to be run through compilation. I think that is not the best way of teaching or even using F#. You can do essentially all your coding in a F# script file and then later on move the working code to individual code files in your project. The one exception that I know of is the code you write for a fable project, but then again, there is no compilation, but a translation to javascript.

As an example is a rather large script file dealing with trees:

So, it seems to me that the slow compilation speed of F# might not be such a big issue when you can avoid compilation until you really want to move your code or adaptations of existing code to production. I wonder whether that would also be the case for the Darklang people.


Leave a Reply

Your email address will not be published. Required fields are marked *