3 ms·
And it shows. Some of the more impressive and powerful libraries have incredibly ergonomic and clear interfaces, because the language let’s you simply do more w
by dgb23 4y ago
And it shows. Some of the more impressive and powerful libraries have incredibly ergonomic and clear interfaces, because the language let’s you simply do more with it.
- matheusmoreira 4y agoI'm not familiar with clojure or its libraries. Can you post some examples of well designed interfaces?
- capableweb 4y agoIf you're not familiar with lisps in general, it might be hard to grok the differences between lisp-macros (as used in Clojure) and "normal" macros you see in other (non-lisp [sans Elixir I think]) languages. But, if you are familiar already, and just wanna see examples of neat macros that makes the API nicer than what a function could provide, here are a few: - https://github.com/clojure/core.async/blob/master/examples/walkthrough.clj https://github.com/clojure/core.async/blob/master/examples/w... - https://github.com/weavejester/compojure https://github.com/weavejester/compojure - https://github.com/ptaoussanis/timbre https://github.com/ptaoussanis/timbre - https://github.com/krisajenkins/yesql https://github.com/krisajenkins/yesql Furthermore, macros enables APIs like this, that would be impossible to have in JavaScript for example: (spy :info (* 5 4 3 2 1)) => 120 %> 15-Jun-13 19:19:13 localhost INFO [my-app.core] - (* 5 4 3 2 1) => 120 `spy` here doesn't just print what the `` form is returning, but the form itself too. You wouldn't be able to achieve this without macros, as the evaluation of the `` form would happen before it gets passed to `spy`, so the initial form is already gone. Instead, a macro received the very code you pass into it, so you can print it, inspect it, rewrite it or whatever.