jordwalke / CommonML

Simple OCaml Development Workflow on CommonJS
MIT License
96 stars 11 forks source link

make ocaml a typed javascript #4

Open bobzhang opened 8 years ago

bobzhang commented 8 years ago

Hi, this is a nice piece of work. Actually I am doing something that you might find interesting, I am adding a new javascript backend to ocaml https://github.com/bobzhang/ocaml/tree/master Unlike js_of_ocaml, here I aim to produce readable javascript code, the output looks very promising: http://zhanghongbo.me/js-demo It already support most of the language(except missing some primitives, tailcall, currying, none of them is a blocking issue). I think ocaml has a great potential to produce javascript code as good as typescript while having a sane type system.

jordwalke commented 8 years ago

That sounds great! There seems to be area for improvement right now in how CommonML uses js_of_ocaml and debugability/sourcemape. If you can create a backend that produces readable/debuggable JS, that's truly awesome and I'd be really excited about it.

There doesn't appear to be any way to file issues on your branch. (I noticed one critical "optimization" is not yet performed that should probably be prioritized). Can you state how you'd like people to file issues?

Can you explain your general approach for generating JS? If someone were to make a new js backend, it would be really great if someone were able to benefit from the new f-lambda optimizations that are coming. In order for OCaml to be considered a first class player on the web, performance should be a top priority, as well as debugability (I know those can sometimes be at odds with each other but having flags control which side of the spectrum you fall would be ideal). I would guess that it's possible to create JS compilation targets that run much faster than equivalent hand-written JS. There are a couple of issues right now making that more difficult with js_of_ocaml: The record fields are turned into numeric indices because it uses the ocamlc output which has erased the label names by that point. In some JS engines this is good for perf and in others it may be bad. Either way, it makes debugging more difficult.

jordwalke commented 8 years ago

I see a couple of interesting things in your fork:

I'd definitely like to hear more about your general approach and goals.