Live data from Hacker News

Clojure Scripting on Node.js

github.com

21–30 of 35 posts

Re: Clojure Scripting on Node.js

#21
post #20

Earlier quoted context omitted.

The main difference is that nbb lets you execute a .cljs file straight away, without a compilation step. As such, it doesn't need any JVM tooling. You can create an AWS Lambda with only a couple of lines of code: https://blog.michielborkent.nl/aws-lambda-nbb.html

What are the language differences. What's missing in SCI's subset? Just Java stuff like deftype?

Multimethods are fully supported. Protocols, defrecord and deftype are supported with some caveats.

Re: Clojure Scripting on Node.js

#22
Just as an FYI for the interested, there is a self-hosted version of clojurescript now, it enables macros in the same runtime with some caveats but the main downside (AFAIK) is increased bundle size, which is less relevant for node.js.

Re: Clojure Scripting on Node.js

#23

Just as an FYI for the interested, there is a self-hosted version of clojurescript now, it enables macros in the same runtime with some caveats but the main downside (AFAIK) is increased bundle size, which is less relevant for node.js.

There was a self-hosted CLJS project for Node.js which is now abandoned. It was called lumo. It came with a custom image of Node.js with lumo built-in for better startup times since the JS bundle of self-hosted CLJS is quite large resulting in not so great startup out of the box. Nbb is just a library that you can use with any Node.js version. That said, it might be worth revisiting the self-hosted CLJS approach at some point.

Re: Clojure Scripting on Node.js

#24
post #10
post #7

Earlier quoted context omitted.

Clojure is a lisp on the jvm. javascript compilers exist because people wanted to use clojure in web related projects.

It's not a javascript compiler as Clojure is a hosted language.

Can anyone explain what a hosted language is?

Re: Clojure Scripting on Node.js

#26

Just as an FYI for the interested, there is a self-hosted version of clojurescript now, it enables macros in the same runtime with some caveats but the main downside (AFAIK) is increased bundle size, which is less relevant for node.js.

There was a self-hosted CLJS project for Node.js which is now abandoned. It was called lumo. It came with a custom image of Node.js with lumo built-in for better startup times since the JS bundle of self-hosted CLJS is quite large resulting in not so great startup out of the box. Nbb is just a library that you can use with any Node.js version. That said, it might be worth revisiting the self-hosted CLJS approach at s…

But the slow-starting, big-bundle default one still works right? For someone developing an electron app maybe it would be a useful option.

Re: Clojure Scripting on Node.js

#28

I love babashka but always find nbb scripts hard because everything returns a promise which makes the normal REPL workflow tricky.. maybe I’m doing it wrong though

I'm not sure if this applies to nbb, but there's a command line flag for the node repl (`--experimental-repl-await`) which allows you to use await in the repl, allowing you to kind of sidestep the normal annoyance of handling promises.

Re: Clojure Scripting on Node.js

#29
post #10

Earlier quoted context omitted.

It's not a javascript compiler as Clojure is a hosted language.

Can anyone explain what a hosted language is?

Compiles/transpiles into code that runs on a "host" language execution environment (nodejs, JVM, CLR) instead of it's own VM implementation, or native code.

Re: Clojure Scripting on Node.js

#30

I love babashka but always find nbb scripts hard because everything returns a promise which makes the normal REPL workflow tricky.. maybe I’m doing it wrong though

I'm not sure if this applies to nbb, but there's a command line flag for the node repl (`--experimental-repl-await`) which allows you to use await in the repl, allowing you to kind of sidestep the normal annoyance of handling promises.

Nbb has nbb.core/await for top level await which is handy for REPL usage. Furthermore it has promesa which is a library for dealing with promises.
Post reply on HN