132 points · by tosh · 8y ago · 66 comments
I just can't imagine many situations where you have cl/cljs capable devs yet want to reject all the benefits of the jvm and use node
The other reason is that there are lots of people who work with JavaScript and are not interested in the JVM ecosystem. I think it's good to have an option that targets this demographic.
One of the goals for Macchiato is to provide a Ring compatible API. This allows you to start projects on Node and move them to the JVM as they grow.
Slow startup of Clojure's code, it's Clojure own doing.
The (Clojure) "JVM Slow Startup Time" Myth - http://blog.ndk.io/jvm-slow-startup.html
With Clojure(Script) whole categories of complexities tend to disappear, so I'd expect that to be the case in this scenario too.
I think a lot of people are wrongly under the impression that the JVM is complicated, and annoying to use. It is not, Java is. Java is not the JVM, and in the context of Clojure and ClojureScript, the JVM is amazing.
The only reason not to use the JVM I'd say would be cases where you need sub-second start times, or you have memory and space constraints, or need full real time. Though for the latter two, there exist paid JVMs that can work for those use cases. In fact, that's another amazing thing about the JVM, its a standard, and there exist multiple fully functional implementations.
Some benefits of the JVM are its very complete standard library, as well as its gigantic set of third party libs. It runs on almost any imaginable hardware. It is extremely fast. All other VMs or even VMless GC runtimes benchmark themselves against it because its the known performance champion. It has amazing GCs, it even has more then one type of GC. It supports multiple programming languages, such as Clojure. It comes with top notch tooling support for debugging, profiling and monitoring. Finally, its backed by a lot of money, which means it keeps improving quickly. Some of its soon to be improvements are complete modularity, AOT compilation, faster startup time, smaller memory footprint, ability to call native code and use native data and finally support for first class fibers (like erlang and go threads).
But seriously completely agree with you about the jvm being awesome. However clojure var load times on top of the base jvm and memory use makes it dog slow to start a development repl(30+ seconds is normal.. queue comment about how someone only restarts their repl every couple of days LOL) and unsuitable or unusable for situations where you care about app start times of less than 10 seconds and memory constrained environments such as cli, iot, serverless, android.
The jvm is still a really good runtime. Java is a way more consistent language than javascript. Other languages running on top of the jvm are way more beautiful and sensible than javascript. The jvm can be leveraged many ways when it comes to performance and use cases, and I consider it way more stable than different javascript runtime implementations running in different browsers coded by different organizations.
Out of curiosity, why do you think the JVM is such a thing of the past and so bloated and clunky? I'm curious about what reasons people have. From my own experience, I get that javascript is easy to start things in, but damn, it can get sucky once you have to maintain and refactor a bigger codebase. It just feels like javascript and node gets a lot of mindshare since it is what the web industry pushes down everyones throat sometimes :/
One reason I might be interested in running clojurescript on node.js is because most web technologies nowadays are written for node.js/javascript first and ported as an afterthought. GraphQL servers on Clojure/Java, for example, are like 3rd class citizens compared to node.js. Google provides nice wrappers to their APIs as long as you're not using clojure. I end up writing things in-house a lot more often than I would with node where I just npm install the package I want and I get something that is maintained by the official author.
But if you're interested in one way Node is nice: single-threaded + unified way to write async code.
badum tsss
But jokes aside - the whole node environment doesn't strike me as particularly un-bloated or un-clunky, especially compared to modern JVM solutions like e.g. vertx, netty or even wildfly/undertow. Same goes for the pure runtime itself (i.e. v8 vs jvm), where v8 may be competitive at best, but hopelessly outclassed in other cases.
Like cljs ontop of node?
I guess the less than inspiring names "short black" and "long black" are available? :)
But Macchiato seems to imply that something was previously stopping us, which it solves, so I'm curious to know what that is, since I was under the impression it was already possible.
-he goal for Macchiato is...
should be:
The goal for Macchiato is...
https://clojurescript.org/guides/self-hosting
[Edit to correct: the following is no longer entirely valid: see downthread.]
That said, if you want to benefit from the Google Closure optimizations, you currently do need to use the JVM toolchain. IIRC, there's been work on the Google Closure side to run without a JVM, and if that's the case, there may be opportunities in the future to take advantage of this in the ClojureScript toolchain.
Its a ClojureScript compiler built in ClojureScript, which creates NodeJS targets.
Self-Hosted ClojureScript's current downside is that it does not support as many of the ClojureScript libs.
That said, the use of the JVM by ClojureScript is just as a build tool. Don't you already have Java installed on your computer anyways?