10 ms·
Java records weren't even a gleam in the eye of James Gosling when Clojure was solving these problems at its inception.
by ledauphin 3y ago
Java records weren't even a gleam in the eye of James Gosling when Clojure was solving these problems at its inception.
- lmm 3y agoStandard ML had records since the '70s. Both Clojure and Java would benefit from taking more from what came before, though Java at least had the excuse of being designed for low-powered set-top boxes.
- filoeleven 3y agoAccording to the link below, ML records are mostly handled by hash-maps in Clojure, except that there’s no canonical key/val order or strict typing by default. ML record: {first = "John", last = "Doe", age = 150, balance = 0.12} Clojure hash-map: {:first "John", :last "Doe", :age 150, :balance 0.12} Destructuring a record in an ML function: fun full_name{first:string,last:string,age:int,balance:real}:string = first ^ " " ^ last (It’s unclear from the example whether or not all of the destructured values are required in the function signature. I hope they are not, but I left them in since I don’t know. The caret positioning raises further questions.) Destructuring a map in a Clojure function: (defn full-name [{:keys [first last]}] (str first “ “ last)) I don’t know if I’m missing something that ML offers with its records aside from more strict typing, which you can also have in Clojure when it’s useful. In both cases, it looks like it’s applied at the function declaration and not the record declaration. https://www.cs.cornell.edu/courses/cs312/2008sp/recitations/rec02.html https://www.cs.cornell.edu/courses/cs312/2008sp/recitations/...
- simongray 3y agoClojure has records too.
- kaba0 3y agoIn his eyes? It definitely was a thing, records are just nominal product types, these are probably the single most used building block of programming languages. I really like Clojure, but I really don’t know what some of its fans think (also true of other lisps), like there is a healthy pollination of ideas between languages, lisps are not God’s language.