Fork me on GitHub

Saw a post on twitter where people figured that clojure is similar to ruby :(


Having seen ruby projects that are just layers of monkeypatches all over the place with dirty states on the left and right... I think clojure is anything but that.


Given a fuzzy enough point of view, anything is similar to anything else.

😛 4

But it's dynamic! And has keywords!


Javascript is like Java, but you don't have to put types when you define variables.


I've worked at a Clojure project with more monkeypatches than any Rails project I've ever touched Similarly, Rails embraces statelessness in the http req/res cycle, and usage of instance variables (`@foo = ...`) tends to be equivalent to Clojure's let or atom


monkeypatching in Clojure?!? How'd you/they manage that??? Seriously, you would have to really work to make that happen. Not actually sure how that would be done


tldr a characterization of Rails from 10y ago doesn't help anybody involved 🙂

👍 4

I like it that you can patch a libraries function if there’s a bug in it, until your PR gets merged 😉


you can’t patch Clojure itself (anymore) though, it’s compiled with direct linking


I believe even with direct linking, you can alter-var-root Vars in clojure.core, and it affects the code run by anything that isn't direct linked with Clojure, which unless you specifically ask for it, your app code is not direct linked.


true, but it’s limited. if you alter-var-root e.g. get to throw it won’t automatically get you that behavior in all destructuring code


But calls between functions in clojure.core are direct linked with each other, and so would not be affected by such alter-var-root's. I believe some orgs build their own Clojure JARs from locally modified source code, too, which is effective even for calls between functions in core.


I have used alter-var-root as well to patch something until it’s merged. Alternatively you can overwrite an entire namespace from a library. You can get to “private” things fairly easy in Clojure. So far I’ve liked that more than hated it.


Yeah, this flexibility greatly reduces the stress of developing a solution in this language when you have a deadline. You can so easily monkey-patch, use private vars, etc. and defer truly fixing the root issues to a point in time of your choosing.