In general, we try to preserve the ML type system as much as we can.
We only remove (or not support) those features under such conditions:
- It does not translate well to existing JS semantics.
- The maintenance overhead is nontrivial compared with the benefit (we are a small team, we want the development to be focused)
If some features meet both the two requirement, it will be dropped. In the foreseeable future(in the next two years), here are two
type system features that we plan to remove
- OCaml style classes
OCaml style OO was never translated well into JS, the maintenance overhead is non-trivial since we did lots of modification to the runtime encoding, while in the native compiler, the Class backend uses lots Obj.magic style code, these invariants are hard to be preserved when using our own patches. Worse, such kind of bugs don’t always show up, it will only show up when you actually hit that code path in some niche cases.
Note the good news is we adopted a subset of OCaml style classes which can be compiled to both JS and native code (it is there but not explored yet), so we can still get structural typing for free.
This removal is on the way and is delivered in the next major release. (Thanks to the clean up, the structural typing experience will be even better, we will cover this in the release note)
- Format/Printf
When you use Printf for a hello world
, the generated code size is huge. The underlying encoding of Format is fairly complex, it is interesting from type system point of view, but it it is not pragmatic when you have to pay so much for a type safe “hello world” on the JS backend. I made a demo here to show the cost, it is around 128KB for a hello world.
The other part is that some complex ad-hoc logic is employed to make the type checking happy, so it is a language feature instead of a library. It makes cross-compiling difficult when the internal of Format changes.
Since removal of such module would cause some breakage (if you do use it today, remove such usage and check the bundle size, you will gain a lot), we are going to add a warning first and remove it in a few releases.
These above two are the main ML type system features we are not going to support, your feedback is welcome!