6 ms·
I love functional programming. At least the functional parts of Python. However, Lisp seems better suited for computers than for humans. Which is probably a s
by peterlada 16y ago
I love functional programming. At least the functional parts of Python.
However, Lisp seems better suited for computers than for humans.
Which is probably a side effect of having been created when 64kB was a decent memory size.
- InclinedPlane 16y agoIndeed. 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 :-)
- brehaut 16y agoPlease justify your claim: In what way is Lisp (in contrast to Python) better suited for computers than for humans?
- peterlada 16y ago2 + 3, touche :)
- brehaut 16y agoThat holds water only at the most sugary syntactic level. At the most simplistic semantic level a binary addition operator is a simple mapping of what the machine wants to do (take 2 registers and put their sum in an accumulator register). Lets expand that simple piece of code. Now you have more than 2 numbers to sum: 2 + 3 + 40 you have been forced to encode both stages of summing the first pair of numbers and then the result and the third value. Contrast this with a lisp (+ 2 3 40) Lisp has takes care of all of the details for me; i merely need to supply the operands and the language worries about mapping it to the underlying operations as needed. Clearly, here is a situation where lisp notation elevates me from having to think about the machine. Touche, indeed.
- ShardPhoenix 16y agoBullshit. Everyone is taught the first way, everyone writes the first way by hand. The first way is the "human" way. The second way is the obscure theory-of-computation way. Your post seems like pure rationalization. Even if it applies to you, I can't see how you can claim with a straight face that prefix math is more "human" in general.
- technomancy 16y ago> Everyone is taught the first way Obviously neither one is more "human"; humans don't know the first thing about math until they're educated. This has everything to do with what's familiar and nothing to do with what's "natural" to the human mind.