7 ms·
"Some good concepts"? It was the first language to add "if/else" constructs, GC, closures, first class functions, reference semantics, and recursion. It took
by coldtea 7y ago
"Some good concepts"?
It was the first language to add "if/else" constructs, GC, closures, first class functions, reference semantics, and recursion.
It took between 5 to 40 years before these became available in mainstream languages (conditionals like if/else were adopted early, GC not so much, closures took even more). Add to that macros and the flexibility of runtime evaluation / code creation, which most mainstream languages still lack.
And of course, Lisp's rules remain (and will always be) the most succinct way to define a full blown programming language with meta-programming facilities to boot -- as opposed to a mere Turing machine like thing or assembler.
>IMO Lisp is just overrated, it lacks visual clues, reads right to left with horrible nesting etc..
This doesn't make any sense...
The nesting is the same as in almost any language.
"reads right to left" - huh?
You know that Lisp code can be indented right?
- Joker_vD 7y ago> It was the first language to add "if/else" constructs, GC, closures, first class functions, reference semantics, and recursion. "Lisp is still #1 for key algorithmic techniques, such as recursion and condescension."
- lkschubert8 7y agoI think they are referring to the nested nature of lisp function calls. (second-fn (first-fn val)) I think that is really just personal preference/what you were taught as opposed to good or bad language design. But it really doesn't matter as one of the big benefits of lisp is it's ability to be metaprogrammed. That same example could be rewritten in clojure as (-> val first-fn second-fn) thanks to macros and doesn't suffer from the right->left reading.
- coldtea 7y ago> I think they are referring to the nested nature of lisp function calls. (second-fn (first-fn val)) How's this different than: secondFn(firstFn(val)) other than the placement of parenthesis, the two cases read exactly the same, left to right.
- lkschubert8 7y agoI've seen a lot of breaking that out into the following in imperative languages. var intermediaryVal = firstFn(val); var result = secondFn(intermediaryVal);
- slifin 7y ago(let [intermediary-val (first-fn val) result (second-fn intermediary-val)]) Or as one of the parents said (-> val first-fn second-fn)
- phyrex 7y agoI'm on the side of lisp here, but in OOP you'd usually write something like val.firstFn().secondFn()
- jecel 7y agoOne small detail - though COND and IF/ELSE are very closely related, they aren't quite the same thing. Early Smalltalk also started out with COND (a right arrow which made code look like modern switch/case) and later evolved to #ifTrue:ifFalse: which is still postfix, so feels backwards compared to other languages. Lisp and Scheme got more conventional if/else eventually.
- LandR 7y agoSomething I discovered about Clojure's cond recently. It usually looks likethis: (cond (< a b) (println "a < b") (> a b) (println "a > b") :else (println "a = b")) I thought the :else had to be :else, but it only needs to be truthy, so it can be anything that isn't false or nil (which makes sense as you want it to always execute that form if no others match). So this is just the same: (cond (< a b) (println "a < b") (> a b) (println "a > b") :hotdog (println "a = b")) Probably obvious to everyone else but it was a bit of a "duh, of course!" moment for me.
- sparkie 7y agoIt's conventional in Scheme and Lisp to just use `#t` directly to match anything.
- lispm 7y agoIn Lisp usually all non-nil values mean true. CL-USER 13 > (let ((a 1) (b 2)) (cond ((> a b) 'foo) (:hello :there))) :THERE In some early Lisp dialects not all objects (other than lists and symbols) would be self-evaluating, so one would have to quote them.
- kazinator 7y agoIn traditional Lisp and common Lisp, and similar dialects, the symbol t is customarily used as the catch all last case. There is an interesting situation is in the case family of constructs which match an input value against keys, in Common Lisp. Inspired by cond, the t symbol also serves as the fallback in case when the key doesn't match the other cases. So that is to say: (case (expr) (a ...) (b ...) (42 ...) (t ...)) ;; <-- this isn't matching on the t symbol! Common Lisp also supports the symbol otherwise in place of t. But the programmer may also sometimes have the t symbol as a specific key value; or likewise the otherwise symbol. That requirement is handled by putting the key into a list: (case (expr) (a ...) ... ((t) ...)) ;; <- match on t
- LandR 7y agoNesting can be sorted via macros, e.g. closures threading macros (defn unique [str] (->> (str/split str #"\s+") (map #(Integer/parseInt %)) (partition-by even?) (take-while #(not= (count %) 1)) (first) (count) (inc))) (unique "2 4 6 8 7 10 12") => 5
- tabtab 7y agoAs far as "Lisp lacks visual clues", after many heated debates on this, I've concluded that the ugliness and rigidness of "production" languages enforces certain visual and syntactic standards that makes reading others' code easier. Indentation of Lisp won't "solve" this because production languages also can be indented. It's not a difference maker. Parameter lists are wrapped in parenthesis and separated with commas, while code blocks are wrapped in curly braces and separated with semi-colons. Lisp won't do this because it's then harder to blur/merge/change the distinction between code and data, which is the very power of Lisp. Building architectural eyesores is probably not a rational plan for a city, but dammit, those eyesores help you know and remember where you are. Some people have a certain kind of eye and/or brain that allows them to read Lisp quickly, but this may not be universal. Some say "with enough time you'll get used to it", but the fact Lisp has been around for 60 odd years without catching on in the mainstream is evidence of this. Somebody would be rich by now off its alleged advantages if they were real (beyond a "write-only" startup language). Functional languages are better at expressing ideas but slower at communicating them to other readers, on average. I also personally find them difficult to debug because they don't have enough "intermediate state" to x-ray for debugging purposes. Here's a conceptual illustration: // imperative: a = af(param); b = bf(a); c = cf(b); // functional c = cf(bf(af(param))); In a debugger and/or Write statements I can readily examine intermediate values "a" and "b". Not so with functional. SQL presents a similar issue. Its new WITH statements help out, but only partly. Divide-and-conquer works better if you can examine the divisions.
- armitron 7y agoYou know your brain adapts so you can read something easier/faster the more you are exposed to it. For me, Lisp code couldn't be easier/faster to read and comprehend. I'm convinced most of the people making jokes about parentheses or Lisp code being hard to read are superficially dismissing it without putting in even a minimal effort of working with it. Things that don't immediately click are discarded. Individual curiosity ("Really smart people say great things about this, I wonder why that is..") leading to individual effort leading to deep understanding is not the prevailing attitude. Sad state of affairs.
- deleted 7y ago[deleted]