logoalt Hacker News

Zaklast Tuesday at 11:11 PM1 replyview on HN

Is it? I saw macros and went mad with power. I wrote a macro that could have been a function today.

But seriously, I think Clojure has a particularly strong tradition of writing clean, readable code.


Replies

iLemmingyesterday at 2:14 PM

Clojure is actually an interesting case here, because it is hosted. So, you can write a Clojurescript macro that runs at compile time on the JVM, but emits code that runs at runtime in Javascript, e.g. instead of blindly loading and executing some JS lib code, your macro can first parse it, analyze it, and conditionally emit Cljs that changes the runtime behavior.

Use-cases for code that writes code across a host boundary are rare, yet enormously useful and really difficult to achieve without homoiconic nature of the language.

Hyperfiddle/Electric is a nice project that effectively utilizes the idea.