4 ms·
I can't help but feel that all arguments defending how this Clojure solution supposedly can't be done as elegantly in other languages, use "idiomatic Clojure" a
by Jare 6y ago
I can't help but feel that all arguments defending how this Clojure solution supposedly can't be done as elegantly in other languages, use "idiomatic Clojure" as the judging criteria. Of course the conclusion writes itself.
- adamkl 6y agoWell, you can write code a lot like this in JavaScript using a library like Ramda, and get a lot of the benefits. But then everyone that you on-board to that project has to be up to speed with how the code is being written and why. With Clojure, that understanding is table-stakes. So in that respect, the conclusion does write itself.
- onetom 6y agoI've actually tried that: https://github.com/enumatech/sprites/blob/master/lib/__tests__/sprites-tests.js#L77-L82 https://github.com/enumatech/sprites/blob/master/lib/__tests... reads quite like Clojure, but looks foreign to JavaScript programmers... I even made extensions to Ramda, so you can thread a mixture of async and non-async code with it: https://github.com/enumatech/sprites/blob/master/lib/fp.js#L51-L54 https://github.com/enumatech/sprites/blob/master/lib/fp.js#L... At the end the friction was just annoying and no one else really understood the greatness of this approach, since they didn't know Clojure...
- didibus 6y agoIn my experience, it's not that you can't do these things in some other languages, it's that you won't, and if you try too, there will be more ceremony and friction. That said, this is where a lot of people who took a detour through Clojure, come out of it saying when they went back to their prior language or some other language, they felt like they had suddenly become better programmers, and it helped them even in other languages to write better programs. Clojure showed them the way, and now they can recognize it and think of doing it as such in other languages as well. Maybe a different way to think of it is that you can do OOP in Clojure if you really want, but you won't. Similarly, in Java, you could try and do FP with immutable collections and value semantics, but most likely you're not going too. And I'm using Java here because in theory, Java and Clojure have the exact same set of available features, they run on the same JVM, same runtime, compile to the same bytecode, can share libraries, etc. So it goes to show that the language itself does influence the style that is most convenient for writing your programs in.