News for hackers. Stuff that matters.
Re:Clojure Scripting on Node.js by solardev on Friday August 05, 2022 @02:29AM (#32352491)
What is this? What is Clojure and why do you need it in node?
Re:Clojure Scripting on Node.js by St_Alfonzo on Friday August 05, 2022 @02:53AM (#32352639)
Clojure/Clojurescript is a functional lisp dialect and therefore brings you more and other ways to write programs, since it defers much from javascript/typescript. But I think another question would be "why do you need nbb for clojurescript?". The minimal answer is: clojure has slow startup time, and clojurescript need some tooling to produce runnable code. With nbb (or bb for clojure) you can run Clojurescript as a scripting language in the terminal, like python or shell, and still use some libraries both from the nodejs or clojure(-script) ecosystem.
Re:Clojure Scripting on Node.js by Borkdude on Friday August 05, 2022 @04:32AM (#32353293)
Author here. Nbb is a scripting environment for Clojure running on Node.js. Clojure is a Lisp that emphasises functional and data oriented programming. Scripts are executed using an interpreter, so there is no build/compile step necessary, which is convenient for small applications.

If you're more curious, check out the README which has a list of videos and articles on this.

Re:Clojure Scripting on Node.js by reil_convnet on Friday August 05, 2022 @02:43AM (#32352578)
Clojure is a lisp dialect (One of the most loved languages according to surveys). You can use nbb to write clojure instead of js in Node.
Re:Clojure Scripting on Node.js by elias94 on Friday August 05, 2022 @07:02AM (#32354370)
https://tryclojure.org/ in case you want to try it!
Re:Clojure Scripting on Node.js by Barrin92 on Friday August 05, 2022 @02:47AM (#32352603)
Clojure is a lisp on the jvm. javascript compilers exist because people wanted to use clojure in web related projects.
Re:Clojure Scripting on Node.js by smcn on Friday August 05, 2022 @04:23AM (#32353223)
It's not a javascript compiler as Clojure is a hosted language.
Re:Clojure Scripting on Node.js by Borkdude on Friday August 05, 2022 @04:55AM (#32353453)
Nbb isn't a compiler, but a Clojure interpreter. Clojure is a hosted language, but can be compiled or interpreted. The ClojureScript compiler compiles Clojure to JavaScript, but nbb only interprets Clojure.
Re:Clojure Scripting on Node.js by kretaceous on Friday August 05, 2022 @06:22AM (#32354068)
Can anyone explain what a hosted language is?
Re:Clojure Scripting on Node.js by iLemming on Friday August 05, 2022 @04:02PM (#32361272)
Basically, you take a programming language and make it work on a platform that meant to be programmed using a different PL. Clojure is hosted by design - it's not Java, but can be used to program for JVM. It ain't Javascript, yet can be used to target nodejs and browser; not an [official] CLR language, but you can write .Net programs. You can use Clojure to make Flutter apps with ClojureDart. You can integrate Python into Clojure with libpython-clj. Or write Clojure to target Erlang/OTP; or Rust; or R; There's even a clojure-like language for Lua - Fennel.

There's something about Clojure people like so much, they want it to work atop any platform.

https://github.com/Tensegritics/ClojureDart

https://github.com/clj-python/libpython-clj

https://github.com/clojerl/clojerl

https://github.com/clojure-rs/ClojureRS

https://github.com/scicloj/clojisr

https://fennel-lang.org

Re:Clojure Scripting on Node.js by ahungry on Friday August 05, 2022 @10:49AM (#32356924)
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 by Barrin92 on Friday August 05, 2022 @04:50AM (#32353410)
clojurescript absolutely compiles to javascript, as per the official docs:

https://clojure.org/about/clojurescript

Re:Clojure Scripting on Node.js by smcn on Friday August 05, 2022 @04:52AM (#32353424)
But that's not what nbb is.
Re:Clojure Scripting on Node.js by mping on Friday August 05, 2022 @02:45AM (#32352590)
Clojure is a lisp like language hosted on top of the JVM. By running on top of node you get a faster startup which is desirable for short lived apps.