4 ms·
Indeed. For example, retaining a method name like "defn" seems more than a little suspect in an era of gigabyte memories, terabyte hard drives, and auto-complet
by InclinedPlane 16y ago
Indeed. For example, retaining a method name like "defn" seems more than a little suspect in an era of gigabyte memories, terabyte hard drives, and auto-complete IDEs.
- zephjc 16y ago'defn' is hardly old-school; Python uses 'def' to define functions. Now 'car' and 'cdr' on the other hand... This is far preferable to typing e.g. "public static void ..." all the time
- InclinedPlane 16y agodefn harkens back to an era when using a computer meant using a teletype, putting an extreme premium on terseness in naming. And it's just an example, car, cdr, cons, etc. are just as bad. It's easy to memorize these but that doesn't mean they are the best choices for readability, writability, etc. 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.
- mikedouglas 16y ago`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.
- mahmud 16y agoPeople want to learn "new languages" without having to learn anything new.
- gruseom 16y agoWell 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.
- mquander 16y agoI 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"?
- brehaut 16y agoI 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]
- rbanffy 16y agoThat's the point: you need auto-complete IDEs, terabyte hard-drives and gigabyte memories to program in Java. You don't need any of that to program with Lisp (although Emacs and SLIME can help)
- weavejester 16y agoBut we still read with the Mark I Eyeball. A commonly-used keyword should be short, and in a functional language, using "fn" instead of "function" seems a perfectly sensible idea. Mathematics and natural languages take the same approach, assigning the most commonly used bits of the language the smallest words/symbols. It makes the document easier to parse, when done within reason.
- jshen 16y agoi prefer short names for methods you use so often that there is no chance of forgetting what it means.
- mquander 16y agodefn is not retained from anywhere. It was coined by Clojure. I don't find it particularly shocking. I also consider the ability to write code effectively outside of an autocompleting IDE a feature, not a bug.
- jmatt 16y agoAutocomplete and debugging with clojure works. The problem is most clojure developers don't use common java IDEs. So it appears like it doesn't work or exist. But recently there has been an explosion of plugins to help everyone that isn't familiar with emacs & slime. Autocomplete: http://stackoverflow.com/questions/4289480/how-to-do-automatic-expansion-or-autocomplete-of-functions-and-variables-in-a-clo http://stackoverflow.com/questions/4289480/how-to-do-automat... Debugging: http://clojure.org/getting_started http://clojure.org/getting_started Plugins: https://github.com/swannodette/textmate-clojure https://github.com/swannodette/textmate-clojure http://code.google.com/p/counterclockwise/ http://code.google.com/p/counterclockwise/ http://plugins.intellij.net/plugin/?id=4050 http://plugins.intellij.net/plugin/?id=4050 Options: [emacs is too hard on windows] http://clojure.bighugh.com/ http://clojure.bighugh.com/ [but I use a mac] http://aquamacs.org/ http://aquamacs.org/ [but I write ###.NET] https://github.com/richhickey/clojure-clr https://github.com/richhickey/clojure-clr https://github.com/jmis/vsClojure https://github.com/jmis/vsClojure
- cjenkins 16y agoI like it for screen real estate purposes. The shorter stuff is, the more text I can view in a single window. I wish monitor real estate progressed at the rate of Moore's law, but I suppose we'd need bigger rooms to put them in before too long.
- cabalamat 16y agoI quite agree. And we can extend this priciple, so that a * b would be replaced by: multiply(a, b) which is much more self-documenting :-)