clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
Yair Taboch 2021-06-08T11:18:31.133300Z

hey all, i have a question about macros in clojure script. why do i need to declare the macros in a clj file first?

borkdude 2021-06-08T11:22:06.133800Z

macros are executed in Clojure (unless you are using self-hosted)

quoll 2021-06-08T12:29:04.139200Z

Expanding on that… The ClojureScript->JavaScript compiler is a Clojure program. It’s this program that executes the macros that generate ClojureScript output. Once all the macro output has been created, then the combination of the original ClojureScript sources and the macro output can be converted together.

sova-soars-the-sora 2021-06-09T23:36:35.166400Z

i found this back and forth quite insightful! thank you @quoll

👍 1
quoll 2021-06-08T12:30:55.140900Z

Come to think of it, I just assumed that it was a Clojure program. It runs on the JVM. I guess it could have been written using Java, but I presumed not

quoll 2021-06-08T12:31:10.141500Z

I need to look now, don’t I? 😊

quoll 2021-06-08T12:35:55.142200Z

Yes, it’s written in Clojure 🙂

🤓 2
sansarip 2021-06-08T14:01:14.143200Z

And if you are thinking about using macros in a self-hosted way, the source code for Klangmeister really helped me out 🎵 https://github.com/ctford/klangmeister/blob/a9cdae2c3d0b71e458576fb693f5cf4654ba73e9/src/klangmeister/compile/eval.cljs

Yair Taboch 2021-06-08T14:15:27.143600Z

it's the same as other compileres. most of the compilers (if not all of them) are written in their language

quoll 2021-06-08T14:38:50.144100Z

Clojure is not!

😲 1
Yair Taboch 2021-06-08T15:28:43.144400Z

any idea why?

dnolen 2021-06-08T15:57:05.145400Z

@yairt there is no ClojureScript runtime - thus the compiler is not available in the execution environment

dnolen 2021-06-08T15:57:52.146500Z

the reason for this design is that the web is desirable target - and including the compiler in the runtime is quite heavy

dnolen 2021-06-08T15:58:10.147100Z

and simply useless for a very large number of applications

👍 1
🤘 1
quoll 2021-06-08T18:04:14.148Z

Well, Clojure didn’t exist when Rich was writing Clojure 🙂 Rich then https://download.clojure.org/papers/clojure-hopl-iv-final.pdf: > Multimethods are quite flexible, and performance is good enough for many applications, e.g., multimethods are used for Clojure’s polymorphic printing. But they cannot be made as fast as Java method dispatch. Thus the initial release of Clojure lacked a sufficient polymorphic dispatch system to define something like Clojure in Clojure. Once Clojure had elements that allowed for the sort of performance necessary, this happened… insofar as ClojureScript was written in Clojure/ClojureScript. A separate project was created, called “https://github.com/remleduff/CinC”. This was then moved into contrib as tools.analyzer, tools.analyzer.jvm and tools.emitter.jvm. But for now Clojure is still in Java, and there hasn’t been pressure to change that.

2
ange 2021-06-08T20:44:06.149Z

Cljs.main question - How to run cljs.main on a remote cloud server, for example a Digital Ocean linux droplet, and connect to browser on local PC?

ange 2021-06-10T21:49:49.176Z

I was able to get it to work with figwheel.main but not cljs.main. "$ clojure -m figwheel.main" on the remote machine, ssh port forward tunnel for browser connection from PC to remote machine, browser loaded the page and connected to the remote repl. With cljs.main the browser connected but the repl would hang at that point and not get to prompt for input. Thanks.

sova-soars-the-sora 2021-06-11T18:24:59.184900Z

hmmmm. can you access the repl via ssh?

ange 2021-06-16T15:19:38.278400Z

Yes, no issues editing files or running repl on the remote machine via ssh session.

Donnie West 2021-06-08T23:03:35.150500Z

Does anyone have an example of exporting a default ESM module from a ClojureScript file in any tooling? (shadow-cljs, figwheel, etc)