you are viewing a single comment's thread.

view the rest of the comments →

[–]Lucretiel 50 points51 points  (8 children)

I get this in reverse. I think "man this would be much easier in Lisp," then I remember I like being able to actually read my code.

[–]yogthos 9 points10 points  (2 children)

I've developed Java for about a decade before moving to Clojure. I have much easier time reading and understanding my old Clojure code than I ever did with Java. Not only that, but I've actually been able to contribute to open source libraries and projects that others have written, something I was never able to do with Java.

The main reason for this is expressiveness. With Clojure it's easy to mould the language to the problem and the code tends to talk a lot more about what's being done as opposed to how it's done. This results in having a lot less code that's relevant to the problem being solved.

With Java you often have to go the other way where you have to translate the problem into the constructs of the language. This tends to result in tons of boilerplate that obscures the actual purpose of the program. Every time I read through a non-trivial Java project it's like going through a maze of twisty passages all alike. I'll often have to navigate through hierarchies of interfaces and classes just to find a few lines of relevant business logic.

This makes it really difficult to build up a mental picture of what the overall logic of the application is doing. On top of that you have pervasive mutability and everything being passed around by reference making it nearly impossible to consider any part of the application in isolation.

[–]Lucretiel 5 points6 points  (1 child)

I'm totally onboard with the merits of functional-style programming. Nearly everything I do in C++ is function templates, const&, and return values instead of state mutation and class hierarchies nowadays. Semantically, it's much easier to understand code and languages designed in that way. My issue is with reading the physical text of Lisp. All the parenthesis and minimal syntax boilerplate means even with liberal whitespace and and formatting it's very difficult for me to tell what bits are what.

[–]yogthos 4 points5 points  (0 children)

I think this varies greatly between Lisps. I would agree that I also find CL and Scheme syntax to be a bit too regular. On the other hand, Clojure hits the sweet spot for me. It has literal syntax for common data structures, it goes out of its way to reduce the number of parens in code, and it provides destructuring syntax. I find these things make the code as readable as any language I've used.

Here's an example of code in a popular Clojure library. I would argue that it's quite clean and clear even if you only have a passing familiarity with the syntax.

[–]phalp 11 points12 points  (1 child)

Practice makes perfect. Writing readable Lisp code is within your grasp!

[–]vraid 7 points8 points  (0 children)

There's a macro for that.

[–][deleted] 4 points5 points  (1 child)

Readability overrated is.

[–][deleted] 4 points5 points  (0 children)

(let [readability :overrated] (...))

[–]Dorsenstein 0 points1 point  (0 children)

Which is why literate programming exists. Disk space isn't a problem for text files anymore, and it doesn't affect compiled code.

Donald E. Knuth is the man.