News for hackers. Stuff that matters.
Re:Cherry: ClojureScript to ES6 Compiler by nerpderp82 on Tuesday November 01, 2022 @02:36PM (#33425467)
Is anyone doing Clojure to Wasm?
Re:Cherry: ClojureScript to ES6 Compiler by Mikeb85 on Tuesday November 01, 2022 @02:44PM (#33425625)
How would you do that? Compile a JVM to WASM? A GraalVM to WASM image? Seems like it'd be too heavy for the web.
Re:Cherry: ClojureScript to ES6 Compiler by pjmlp on Tuesday November 01, 2022 @06:14PM (#33428358)
Clojure always builds on their host platform, that is why even its reader has conditionals for each platform.

A WebAssembly implementation would target the WebAssembly bytecode, and everything beyond the core forms would be based on WebAssembly ecosystem.

Re:Cherry: ClojureScript to ES6 Compiler by fulafel on Tuesday November 01, 2022 @03:31PM (#33426245)
JS is a much better compile target. WebAssembly doesn't have GC and it's just not geared towards dynamic languages.
Re:Cherry: ClojureScript to ES6 Compiler by the-alchemist on Tuesday November 01, 2022 @04:48PM (#33427282)
Everyone is waiting for WASM to support garbage-collection (GC) officially. =)

Clojure has Javascript, JVM, .NET, LLVM, Arduino, GraalVM, etc. targets, so rest assured, a WASM version will come out as soon as it makes sense!

Re:Cherry: ClojureScript to ES6 Compiler by pjmlp on Tuesday November 01, 2022 @06:11PM (#33428309)
Not everyone, anyone that cares is shipping their own GC implementation just as they have to in regular CPUs.

GC is "coming" since WebAssembly was announced.

Re:Cherry: ClojureScript to ES6 Compiler by nerpderp82 on Tuesday November 08, 2022 @06:12PM (#33525552)
I'd love a Clojure(Script) that ran on Wasm, even if it bundled its own GC. One path through this would be the Gambit Scheme ClojureScript compiler.
Re:Cherry: ClojureScript to ES6 Compiler by leidenfrost on Tuesday November 01, 2022 @02:46PM (#33425643)
Genuine question: Why ES6?

As for the compilation target, It may be better compile to CommonJS as well, so you can base your entire project in Clojure and leave the target as the production build, like Babel does.

Re:Cherry: ClojureScript to ES6 Compiler by Mikeb85 on Tuesday November 01, 2022 @03:24PM (#33426145)
> Genuine question: Why ES6?

Because CommonJS is dead and only continues to be supported because of all the old NodeJS stuff written in it.

The whole point of ClojureScript is to target the browser since Clojure itself targets the backened; well every browser supports ES6.

Re:Cherry: ClojureScript to ES6 Compiler by leidenfrost on Tuesday November 01, 2022 @03:33PM (#33426273)
That's true.

Maybe not CommonJS but a version of JS compatible with LTS Node. That way you can develop with ClojureJS also on the Back End.

Re:Cherry: ClojureScript to ES6 Compiler by askonomm on Tuesday November 01, 2022 @03:42PM (#33426418)
You can already develop with ClojureScript on the back-end. A popular ClojureScript compiler, Shadow-CLJS (https://github.com/thheller/shadow-cljs) has a target for Node among many others.
Re:Cherry: ClojureScript to ES6 Compiler by wiredearp on Tuesday November 01, 2022 @03:55PM (#33426603)
ES6 is compatible with Node out of the box.

You can `import` and `export` just like in the browser (and in TypeScript) as long as your files come with the `.mjs` extension. Cherry adds this extension by default, so I imagine it comes with the server in mind.

You can also keep the `.js` extension and configure this behavior in the `package.json` to run the same files both client- and serverside.

Some libraries still expect to run as CommonJS, but then you might find an "es" version if you poke around in their repositories.

Re:Cherry: ClojureScript to ES6 Compiler by kitten_mittens_ on Tuesday November 01, 2022 @04:48PM (#33427279)
The LTS version of node is now 18, which supports its special flavor of ESM.
Re:Cherry: ClojureScript to ES6 Compiler by cgdub on Tuesday November 01, 2022 @04:24PM (#33426996)
ClojureScript already compiles to CommonJS with the built-in :target :bundle option.
Re:Cherry: ClojureScript to ES6 Compiler by brundolf on Tuesday November 01, 2022 @04:49PM (#33427287)
I'm imagining they don't want to deal with transpiling for maximum browser compatibility, or with bundling; there are existing tools that do those things really well and you can always feed the output of this through those if you want those qualities

Targeting ES6 will yield simpler, more readable compilation output (which is a stated goal of the project). It can also preserve module boundaries while keeping client-side support, which is not something you could do with CommonJS. And they mention other things like async/await support, which would be a huge pain to try and implement yourself instead of leaning on the target language

Re:Cherry: ClojureScript to ES6 Compiler by newdaycap on Tuesday November 01, 2022 @04:10PM (#33426787)
I don't quite get how this differs from existing tooling such as shadow-cljs... is it the non-dependence on Google Closure?
Re:Cherry: ClojureScript to ES6 Compiler by user5678 on Tuesday November 01, 2022 @04:17PM (#33426883)
There’s no runtime. Also shadow-cljs is not a compiler, it uses the main ClojureScript compiler.
Re:Cherry: ClojureScript to ES6 Compiler by fulafel on Thursday November 03, 2022 @01:31AM (#33447385)
There's a core library like with current ClojureScript, no?

> Compiled JS files are linked to one shared NPM module "cherry-cljs" which contains cljs.core.js, cljs.string