(tc/select-rows ds #(> (% "year") 2008))
instead of filter(ds, year > 2008)
They seem to ignore the existance of Spark, so even if you specifically want to use JVM it feels clearer and simpler: ds.filter(r => r.year > 2008) (tc/select-rows ds #(> (% "year") 2008))
instead of filter(ds, year > 2008)
They seem to ignore the existance of Spark, so even if you specifically want to use JVM it feels clearer and simpler: ds.filter(r => r.year > 2008) (require '[clojure.walk :refer [postwalk]])
(defmacro filter
[ds & anaphoric-pred]
(let [row-name (gensym 'row)
pred (postwalk (fn [form]
(if (and (symbol? form) (nil? (resolve form)))
`(get ~row-name ~(str form))
form))
anaphoric-pred)]
`(tc/select-rows ds (fn [~row-name] ~@pred))))
Now you can write (filter ds (> year 2008))
And it'll expand to the ts form: (pprint (macroexpand '(filter ds (> year 2008))))
=> (tc/select-rows ds (fn [row2411] (> (get row2411 "year") 2008)))The Clojure pipelining makes code much more readable. Granted dplyr has them too, but tidyverse pipes always felt like a hack on top of R (though my experience is dated here). While in Clojure I always feel like I'm playing with the fundamental language data-types/protocols. I can extend things in any way I want
And that's on top of the vastly simpler syntax compared to what's being shown here
I've been programming for decades. I've used dozens of different, at times enormously esoteric languages. At one point I built ERPs in a language where operators were abbreviated Russian terms. After just a few years of using Lisp dialects I am absolutely convinced - there's no simpler and more readable syntax than of Lisp's. Anyone who doesn't see that, in my eyes just not made the distinction between familiarity and simplicity.
They're measuring how quickly their eyes can parse something they've already seen a thousand times, and calling that readability. But readability isn't recognition speed - it's the cognitive distance between the code and the computation it describes. And on that measure, Lisp is essentially lossless. There's no syntactic residue. No ceremony the language demands for its own sake. What you write is the structure of the thing, all the way down.
"You get used to it. I don't even see the code. All I see is blonde, brunette, redhead..." I don't look at Matrix feeling puzzled anymore. I see the truth.
People who bounce off the parentheses are reacting to something real: it doesn't look like what they already know. But that's not the language failing them. That's just the last bit of the old syntax dying. Give it a few months of structural editing and a proper REPL workflow, and you won't see parentheses anymore - you'll see shape. You'll see depth. And going back to anything else will feel like someone handed you a map drawn in crayon and called it a feature.
Love this, I've never heard it put that way before.
The sell isn't about typing a few more or a few less characters, it's about doing data science functionally.