3 ms·
The thing that makes dynamic types quite easy to work with in Clojure is the fact that there's really not a whole lot of them there. In Clojure, pure data is ki
by simongray 7y ago
The thing that makes dynamic types quite easy to work with in Clojure is the fact that there's really not a whole lot of them there. In Clojure, pure data is king and creating your own types is strongly discouraged. It's possible to create types, mainly to allow for interop with Java and JS, but Clojure programmers really don't do it if it can be avoided.
The flip side here is that ALL of the core functions work on ALL of the core data types, so no matter what type of data you're working on (sets, maps, lists/stacks, vectors, even strings) you run in to the same handful of data manipulation functions. All of the persistent data structures are immutable, memory-efficient, and allow for easy value-to-value comparisons. The Clojure data structures can also be applied as functions themselves so e.g. a map is both a data structure and a mapping function from one set of values to another. Everything fits neatly together like Lego bricks, you NEVER write any adapter code in Clojure.
You do sometimes miss type information, especially when working with devs that aren't consistent in function parameter naming, but the trade-off is that you get a remarkably succinct and flexible language that really seems purpose-built to avoid the Lisp curse.