JSCaml: A compile-time transformation from JavaScript to OCaml
github.com
github.com
And I sure hope Parallel OCaml gets done
I believe I saw a video for Yaron Minsky (jane street, real world ocaml), where he said that two areas where ocaml can improve is parallelism and having a nice GUI Library
Not sure of the full time line but they hired Andrei Alexandrescu after he started working on D, and he was pretty open about using D at Facebook.
Or you could just write Reason I suppose. :) There's a crazy permutation of ways to write code that can run in a browser or server run time these days!
Unfortunately the state of tooling and runtime support is far behind the idealized closure of the transpilation graph.
Would they support this scenario?
praise science.
It won't be a cakewalk like when we first began to learn imperative programming - learn through osmosis and unstructured play.
It would be more like learning maths, or playing an instrument from the very basics. You have to work through basic problems, read a lot, practice a lot, and slowly build up your intuition. Over time a -> b -> c will feel natural to you, you'll be able to write pattern match expressions without thinking about it, and will be astounded by your own cleverness when you're able to express things elegantly using types.
I've been trying to learn Typed FP for the last six months, and it is opening up slowly but surely. I'd recommend this path to anyone who's been programming for a while (I've been at it for 10 years now), and wondered whether this was all there was to it. Beyond these ever-changing APIs and fads and thought-leaderships, there is a whole new world of programming out there in the Typed FP community.
You should check it out. It'll make you confident to tackle larger and harder problems and maybe bring the fun back into programming. OCaml and Reason and BuckleScript is a great starting point - the community is nice and welcoming. Real World OCaml by Minsky, Madhavapeddy, and Hickey is a text with a lot of insights. You can also go straight to Haskell, but its web-browser story is not as good as OCaml's (thanks to BuckleScript). Or there is PureScript - for which IMHO you'd probably need to already know some Haskell.
(Wrote this and realized I was talking to people who'd think that OCaml is hard, not the parent)
> I've been trying to learn Typed FP for the last six months, and it is opening up slowly but surely.
Yes, exactly. Every kind of programming is just programming and if you already succeeded in learning one kind you should be able to learn any other kind of programming with enough effort.
The problem is in convincing enough people that a) the effort required is not that great or b) that the particular kind of programming is worth knowing despite the effort required or both.
Sure. The main reason is a substandard (and I'm being very generous here) way FP - and more generally, programming - is taught. Take a look at http://fsharpforfunandprofit.com/ - it describes all the "hard" FP concepts in an interesting and easily digestible fashion.
Seamless memory lifetime interop without leaked cycles is essential for incrementally moving a code base from one language to the other. In browsers, that means your only hope is to target semi-idiomatic JavaScript if you want to incrementally move a large JavaScript system to another language. Wasm is currently great for whole-program rewrites from scratch, not incrementally moving over. That's why BuckleScript has been so helpful.
When not running in the browser, you have many more options, and if given the choice between running Reason/OCaml in a JavaScript VM, vs. running JavaScript in an ocamlopt runtime, the later offers many compelling advantages.
1. The ocamlopt runtime allows languages with sound static guarantees to take advantage of those guarantees to emit more efficient machine code, reaching the language's full potential. JavaScript will have to go through all the same dynamic (costly) checks due to its language complexity - at least for object property/method dispatch, but why should that mean that OCaml should have to as well? By running inside of the ocamlopt runtime, it can share one memory system without being limited by an unrelated dynamic language's weaknesses.
2. Depending on the approach, the emitted JavaScript might be able to take advantage of many of ocamlopt's ahead of time optimizations to reduce allocations, and inline function calls (F-lambda for example) without having to wait for the JIT to reach many of the same conclusions (which slows down startup time).
3. Even if the JavaScript compiled to ocamlopt runtime doesn't demonstrate as much throughput as it would with a JIT (once you wait for it to warm up of course), the approach of JSCaml allows you to seamlessly break off bottlenecks and write them in Reason/OCaml which could end up running even faster than JS with a JIT once warmed up (and without having to wait for the slow JS VM's startup initialization).
I'm sure there's a ton of work left on JSCaml until you can one-click deploy your JS programs and see performance wins, but I'm very interested in this general direction, as it has many uniquely compelling advantages that stand to help move the JavaScript ecosystem forward.
https://github.com/chenglou/reason-react-example/tree/master...
This code is both very pretty and very terse, in my eyes.
Can you talk about what FB uses Reason to develop, and what kind of services are being built with it?
https://news.ycombinator.com/item?id=12400397
that React bindings for Reason would be published on HN in a few days. I know there has been a lot of work in the repos for Reason for JSX support etc, but is there a public story about this yet anywhere that I've missed?
Thanks for any more info.
You can check out the development here: https://github.com/chenglou/reason-react-example
Cheng also gave a talk at ReactConf about our efforts.
Things are still quite in flux, but you're welcome to contribute and help improve things.
On the other hand, cool to see the investment in OCaml, and such a popular language able to run on its runtime! I hope that with all this newfound interest from the industry and the community more OCaml resources and more development in the compiler start to happen!
> So why would you use JCaml at all? Two reasons come to mind:"
> You want to run your JavaScript code on small devices where JIT compilers are not available or do a bad job. > If you are actually writing your code in Reason but you want to make use of JavaScript libraries and you also want to run on small devices.
So is this aimed at use in react native? Or IOT?
It's amazing how this kind of language interoperability can enable new development and deployment approaches.