3 ms·
You're probably a verbal thinker, and English-like code matters a lot to you I guess. Probably lots of programmers are. For me, a mostly visual thinker that en
by nnq 11y ago
You're probably a verbal thinker, and English-like code matters a lot to you I guess. Probably lots of programmers are.
For me, a mostly visual thinker that ends up building and visualizing a code tree in his head anyhow, Lisp is very readable because I can more clearly see the tree without all the noise.
And when it comes to math, staying close to standard math notation is a clear winner, and this is why all lisps have ways of writing infix for formula-heavy code, stuff like http://data-sorcery.org/2010/05/14/infix-math/ http://data-sorcery.org/2010/05/14/infix-math/ and others. But lispers don't use them that much because they simply get used to the Lisp notation more.
...oh, and Common Lisp is NOT an example of readable Lisp. It's probably the most unreadable and obsfucation-friendly of them all :)
Take a look at some Clojure code for something that's just as readable as Python after you "get you eyes used to it" (jargon for learning to ignore the parentheses and learning the special meanings of the "funny symbols" like :, ~, # and a few more): https://github.com/weavejester/compojure/blob/master/src/compojure/core.clj https://github.com/weavejester/compojure/blob/master/src/com...
- hacker_9 11y agoI agree I am a verbal thinker, but that is only because I have to read the words off the screen to begin with - once I have the english in my head my mind switches between verbal and visual images to figure out the next part to write/how to fix the bug etc. Anyway to take an example from your github: > if (and form-method (= request-method :post)) am I right in saying this is pseudo-imperative: if (form-method && (request-method == 'post')) To me the ability to read it left to right seems like a huge win. With the lisp version I seem to be holding the program in my head until the very last (= ...) just so I can work it all out. Perhaps that is just in-experience though.
- nnq 11y ago> the ability to read it left to right seems like a huge win It's only a win if your mind actually needs the "left to right representation". For me, reading that "if" is more like: 1. oh, so this condition is and-ing 2 child conditions, so they must both be true 2. now the first sub-condition... ok, so it just sees if form-method is truth-y 3. now the 2nd one... ok, so we're comparing if two things are equal... let's see what these things are 4. so request-method must be equal to post ...and the full code-to-English translation would be, for me, something like this: "if two things are truthy, the first of which being form-method, and the second being that there is equality between request-method and :post". This is how it would sound like if I translated my thoughts of this code into English :) The advantages of people who think more like you would be that: 1. you probably find it *much easier* to explain your thoughts about code to others, since translating thought to words is a piece of cake for you (I envy you verbal thinkers for this a lot! :) ) 2. you can easily map code to math formulas, and figure out differences between them (I can do this easily too, but I just need to use a more complicated algorithm in my head) The advantages of the people who think more like me would be: 1. breaking complicated stuff into smaller pieces that can be understood off-context is easier (try breaking up the sentence I just wrote above at each comas and see that they kind of make sense separately too) 2. thinking about meta-code (code that generates code like Lisp and Scala macros) is much easier: because our mind's representation is closer to the machine's AST representation, writing code that writes code that writes code etc. feel just as "natural" as everything else to us. For example, when thinking about implementing an ORM, my first thought is something like "oh god, if the language I'm working in just had *real macros*, I could write all this in a few hours and couple hundreds line of code, and not need a mind-bending hierarchy of classes to do it" :) As an example of meta-thinking in a verbal language... try reading some Kant or other such philosopher ...it's just too hard to be able to get to any result fast enough, so probably a bad idea... The whole point I'm trying to make is simply that people think very very differently! Indeed, the Lisp advocates should stop repeating the "it's awesome" mantra and understand that it's only awesome for those with the brain wired a certain way, and it's probably painful for the others. Nirvana would be to port Lisp's features to a more math-like and English-like language. But nobody has been successful at this. Both Scala macros and Template-Haskell are truly fucking hard if you try to actually use them for getting stuff done. So I count them just as failed experiments. But there's always hope :)
- lispm 11y ago> ...oh, and Common Lisp is NOT an example of readable Lisp. It's probably the most unreadable and obsfucation-friendly of them all :) Actually typical Common Lisp is much more readable than Scheme or Clojure. 'obsfucation' is built-in in Clojure, where it has to be programmed in Common Lisp. Scheme has great potential for unreadable code, given it is a Lisp-1 and it makes heavy use of recursion and higher-order functions. Common Lisp OTOH favors: long descriptive names, descriptive keyword arguments, CLOS based data structures (instead of untyped lists and vectors), explicit loops, explicit calls to variable bound functions, ...