5 ms·
In the X->JS transpiler space it's really only Emscripten that can take a library not written with JS in mind, and get it working. Scala.js is close, but in my
by hackcasual 10y ago
In the X->JS transpiler space it's really only Emscripten that can take a library not written with JS in mind, and get it working. Scala.js is close, but in my experience the transpilers are really only suited for projects written from scratch.
Not to say there's not value in building JS output with semantics very close to to Swift.
- spicyj 10y agojs_of_ocaml and BuckleScript both do a very good job with OCaml.
- hackcasual 10y agoBuckleScript looks very interesting. Semantic mapping and very small potential output are rare. GPLv2 would present some challenges using it commercially though.
- dangoor 10y agoMany compilers are released under the GPL license. Generally speaking[1], the output of the compiler is not subject to the license terms of the GPL, just as a document created by a GPL'ed word processor need not be licensed under the GPL. [1]: There could conceivably be GPL code linked with your code in the final output, but I don't think people would release a compiler like that without big notices unless they're specifically trying to trick people into having to buy commercial licenses or something like that.
- spicyj 10y agoOh, ClojureScript also seems nice.
- kevingadd 10y agoJSIL can run pretty much all modern .NET code with correct semantics in JS (i.e. the standard library + real enterprise apps/games), but the performance cost to match semantics is pretty significant. And then there's stuff you just can't do, like weak references :(
- kolme 10y agoI'm pretty sure that's doable now that there's WeakMap in ES2015.
- kevingadd 10y agoWeakMap isn't weak references. Easy mistake to make (most TC39 members don't understand the difference). WeakMap is a weird approximation of weak properties, where the weak relationship is in the opposite direction.
- spicyj 10y ago> most TC39 members don't understand the difference This seems unlikely.
- kevingadd 10y agoI beg to differ. Observe long threads like this one (which I started) https://esdiscuss.org/topic/what-is-the-status-of-weak-references https://esdiscuss.org/topic/what-is-the-status-of-weak-refer... It was not the only one, it crops back up periodically and the purpose/nuances of weakrefs have to be re-explained each time. To be fair, there are a lot of subtleties involved...
- dougk16 10y agoGWT's JAva->JS transpiler does a pretty good job too. As long as a library isn't too reflection-heavy it can compile without modification. And if a library is reflection-heavy odds are you're not going to have a use for it anyway.
- sjrd 10y agoExperience with the Scala.js ecosystem suggests that it is very well suited to cross-compiling existing code after the fact. All the major libraries of the Scala/JVM ecosystem have been ported to Scala.js by now, several of them only by changing the build script! And I'm talking about serious, language feature-intensive libraries like Scalaz and Shapeless.