Elm - General Discussion, Blog Posts, Wiki

Elm is not necessarily bad, and TEA is not bad at all, just the Elm ‘language’ has…issues that I kept running in to repeatedly. Bucklescript is an awesome transpiler, but the language is OCaml of course. :slight_smile:

Ah still a tiny app yeah, it will compile fast still. :slight_smile:
Compile time is not linear to total code lines, the way the Elm compiler works is it tries to ‘resolve’ a lot of paths in the type system, in some cases very inefficiently, so you have have very little code and suddenly get 15 minutes compile times (I hit one of those cases once) or have 50k lines that compile in 40 seconds (which was about the best I could get it down to without breaking up the messages a great deal more). In the ‘general’ case the compile time will increase at a small exponential, but it is a great deal more than linear (I do not think any compiler could compile in linear speed short of direct assembly or something similar).

It was about 29,000 lines. And cannot test the compile time of individual files since elm compiles them in whole. Elm takes all the files and concats them into a single giant javascript file (with interestingly no optimizations performed over it). The OCaml compiler (and thus bucklescript) compiles each module by itself (after pre-generating types from dependent modules, but not compiling them) and outputs a javascript file for each module (with as many in-module optimizations possible already performed) in such a way to be trivially optimizable further by the likes of rollup or the closure compiler both). That means that by definition OCaml will always compile faster than something like Elm that output a single monolithic file.

However, elm is thinking of splitting up into multiple JS file per module like Bucklescript is doing, however they are requiring that all dependent modules are compiled first, which still makes per-file compilation linear (with in-file compilation still exponential) compared to OCaml/Bucklescript that can compile everything concurrently.

Sadly, a lot of the compile-time issues will not be able to be improved significantly in the Elm compiler because the design of the Elm language took a few very specific and VERY slow-to-compile Haskell’isms instead of the OCaml style, thus to fix those the language would have to make a couple very specific syntax changes, which are quite a radical change from what it does not.

1 Like