Fork me on GitHub
#beginners
<
2024-06-19
>
Alexwanng06:06:28

What other libraries in Clojure are developed based on the data-driven pattern? I'm watching a data-driven programming youtube from https://www.youtube.com/watch?v=8Kc55qOgGps by @rafd And get the idea that generic data structures > code (macros, functions). And the author also list many examples: • HoneySql • regal • compojure(based on macro) -> reitit (data) • JSX(text) -> Reagent (data) • SCSS(text) -> Garden (data) • GraphQL(text) -> EQL (data) • clojure.spec(macro) -> malli I did feel the interesting aspect of being data-driven. Literally speaking, what we always see starts from keywords (perhaps my conclusion is not rigorous). At the same time, I also want to know if Clojure's function libraries have generally undergone this change (besides what was mentioned above), that is, which other function libraries are also based on a data-oriented approach.

Alexwanng12:06:24

Raising this question is also to confirm whether there is a consensus in the Clojure community that Macros are not welcomed?

daveliepmann13:06:20

Clojure consensus is to use macros when necessary and otherwise avoid them. This is in contrast to Common Lisp's (over?-) enthusiasm for macros (and even changing the reader in ways Rich decided not to make possible).

daveliepmann13:06:05

Programming Clojure by Alex Miller with Stuart Holloway and Aaron Bedra has nicely memorable, systematic approach: > The first rule of Macro Club is, Don't Write Macros. Macros are complex. If you can avoid that complexity, you should. > The second rule of Macro Club is, Write Macros If That Is the Only Way to Encapsulate a Pattern....The exception to the rule is that you can write any macro that makes life easier for your callers when compared with an equivalent function. (slightly paraphrased from p187 & p199) They outline some scenarios where macros are justified: conditional evaluation, defining vars, java interop, postponing evaluation, wrapping evaluation, and avoiding a lambda.

👍 3
rafd20:06:42

Re: "what we always see starts from keywords" , in the Clojure context, "data" is Clojure vanilla data-types and structures (~EDN), so, numbers, strings, keywords, vectors, sets, etc.; in another language, say JS, it would be more restricted. Another way I think of it is, data is whatever can be easily written, serialized/deserialized, and manipulated.

👍 1