2 ms·
Have a look at OCaml. There's a project called BuckleScript that provides an OCaml to JavaScript compiler that maps OCaml quite cleanly to Javascript. Because B
by dpwm 9y ago
Have a look at OCaml. There's a project called BuckleScript that provides an OCaml to JavaScript compiler that maps OCaml quite cleanly to Javascript. Because BuckleScript is written in OCaml, it can also compile itself, resulting in the demo at [0]. Playing with that demo and looking at the output convinced me to give OCaml with BuckleScript a chance.
I was completely disillusioned with with JS. Thinking that types were the solution I tried TypeScript and found that I wanted it to be something it was never meant to be and just went back to JS. So far I've successfully used OCaml+BuckleScript with Mithril for a few personal projects and it's been really fun. I felt able to predict my productivity after only about 20 hours of use. If you do have any JS libraries that you can't write BuckleScript bindings for, or you can't figure out how to write bindings for them, you can always write a small JS shim that you can easily write bindings for.
OCaml isn't as dogmatic about purity as Haskell and unlike Haskell you're not encouraged to write type signatures for most functions. There's also far less of OCaml to learn than Haskell or Scala. All round it's a really good general purpose language.
There are two incompatible attempts at better standard libraries (core and batteries) and each encourage you to write OCaml in a style that does not have the feel of OCaml. The OCaml standard library itself is a collection of datatypes and depending on what you're doing may well be good enough.
There's also Reason [1], an alternative syntax for OCaml. Reason is undergoing heavy development at the moment and it appears that syntax changes are coming.
[0] https://bucklescript.github.io/bucklescript-playground https://bucklescript.github.io/bucklescript-playground
[1] https://reasonml.github.io/guide/what-and-why https://reasonml.github.io/guide/what-and-why