Re:Thinking in Clojure for Java Programmers
by mquander on Thursday December 16, 2010 @07:30PM
(#2014554)
I disagree. If car and cdr and cons are bad, it's because they don't look or sound like what they do, and they have good replacements, like first and rest. defn is a macro that makes it simpler to def, which sounds and looks like "define", a binding to a fn, which sounds and looks like "function". I don't think you get any clearer than that without writing "define-function" everywhere. And I don't want to write "define-function" everywhere.
Do you think that every index variable in a loop should be called "index"?
Re:Thinking in Clojure for Java Programmers
by mikedouglas on Thursday December 16, 2010 @07:22PM
(#2014528)
`defn' is a mnemonic for "define function".
`cons' is a mnemonic for "construct".
`car', and `cdr' and replaced in clojure with `first' and `rest'.
Once you've spent ten minutes with the language, these names aren't going to trip you up.
Re:Thinking in Clojure for Java Programmers
by mahmud on Friday December 17, 2010 @12:15AM
(#2015279)
People want to learn "new languages" without having to learn anything new.
Re:Thinking in Clojure for Java Programmers
by gruseom on Friday December 17, 2010 @12:55PM
(#2017006)
Well put. There's also a tradeoff between learning-curve and proficiency in language design: many features that aid the one detract from the other. I think this causes much of the noise in programming language discussions, especially with Lisp.
Re:Thinking in Clojure for Java Programmers
by brehaut on Thursday December 16, 2010 @07:36PM
(#2014565)
I think using defn as an example here is a poor choice for this argument. defn is not an abbreviation of `define` or 'defun', instead it is a fusion of `def` and `fn`. fn is clojure's anonymous function form and def binds a var to a value. You can see this via macroexpand:
user=> (macroexpand '(defn f [x] x))
(def f (.withMeta (clojure.core/fn f ([x] x)) (.meta (var f))))
[edit: clarified an ambiguous initial statement]
I have a hard time believing that the best choice of name for all of these operators just so happens to always be some 3 or 4 character string that's almost but not quite a word and seems to have dropped some vowels.
As for "public static void ...", that's a disease of another sort, equally as bad.