Live data from Hacker News

Why I love Common Lisp and hate Java (2012)

kuomarc.wordpress.com

81–90 of 171 posts

Re: Why I love Common Lisp and hate Java (2012)

#81
post #48

Earlier quoted context omitted.

I would say that Java has ~50% more code than Python due to types and braces. But I agree with you that it's worth it, because the compiler can check that a programmer satisfied a constraint, instead of relying on informal conventions or comments. You can have a statically typed language without verbosity, via type inference (Haskell, newer Java, etc.). I wouldn't say I enjoy Java's verbosity, but I would take this o…

Most Haskellers write out the types even though they can be inferred. In a pure language, signatures are extremely close to documentation (you know exactly what a function will do by its signature). Java requires more code than Python or Haskell because it's extremely imperative and statement based. Python on the other hand includes a lot of functional, more expressive idioms like concise list comprehensions.

> Most Haskellers write out the types even though they can be inferred.

I don't think that's true. Idiomatic Haskell has explicit declarations only for top level functions and uses type inference for everything else.

Re: Why I love Common Lisp and hate Java (2012)

#83
post #72
post #52

Earlier quoted context omitted.

>I find a debugger just slows me down 1st you have to add the useless print statements and after decades of programming a debugger is vastly superios in terms of 'debugging' when compared to printing. (Back in time basic had no debugger even) Also printing is utterly useless for high concurrent code, as printing alters memory visibility, usually adds global sync, etc..

Attaching a debugger will also change the behavior of concurrent code.

So does repl, to be fair.

Re: Why I love Common Lisp and hate Java (2012)

#84
The issues mentioned are largely addressed by jshell and lambdas.

Regardless, his issues mostly boil down to "Java is not a REPL-first and Lambda-first language". This is like me "hating" my cat because it's not a dog.

I find many beginner programmers like REPL langs. When I talk to them, though, it becomes apparent that they've never worked on a code base with 100k+ lines with tens of colleagues.

One guy actually suggested that systems should never be that big! What do you say to that? I just smiled.

Re: Why I love Common Lisp and hate Java (2012)

#85
post #82

My biggest gripe with Java is it's insane backslash-enhanced regular expressions. No other language seems to require this ridiculous butchering of what brought me into programming.

Java 12 is going to add raw string literals which will fix this problem. https://openjdk.java.net/jeps/326

Re: Why I love Common Lisp and hate Java (2012)

#86
post #7

It is a recurring theme for people to point out how verbose a hello world program is in Java: class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); } } For argument sake, let's compare it not to Lisp but to Python instead: print("Hello World!") Once you get proficient in a language and start writing larger programs, your perspective can change entirely. What appears to be…

IMO, it’s a balance of entropy with maintainability. The amount of info I a line of java is likely lower than lisp, so the cognitive load is likely lower and the code reviews of diffs are spread out over more lines. Generally less value per line but more decomposed.

Re: Why I love Common Lisp and hate Java (2012)

#87

I tried reading the Java Language Specification once, but it was such insane garbage I stopped and never give it another look.

I read parts of the JLS and I found the text quite down to earth compared to the respective specifications of C, C++, and ECMAScript (JavaScript). Oh and as for scripting languages like PHP, Python, and Ruby? They don't have a standard because the implementation is the spec!

Re: Why I love Common Lisp and hate Java (2012)

#88
post #44

Earlier quoted context omitted.

What do you mean "aren't actually" ? Anything that behaves according to the rules of a lambda is one — they can certainly be implemented with classes.

There are quite a few complications of Java lambdas and their abstraction bleeds out in several edge cases. This is a result of their class implementation and would not exist if functions had first class support in the language and barcode bytecode (there are complications there too because they didn't want to change anything at the bytecode level for lambdas). https://dzone.com/articles/java-8-lambas-limitations-clo…

Lambdas in Java aren't really that complicated. If you understand anonymous classes, you understand lambdas.

That article just compares Java's closures with Javascript's closures. The "limitation" is that Java's closures can only access the final variables of the enclosing scope. But the article agrees that this limitation "can be considered negligible" (seriously, read it-- that's the conclusion.)

Also, starting in Java 8, you don't have to explicitly declare things "final" to use them in anonymous classes or lambdas. They just have to be effectively final, meaning they are not mutated.

Re: Why I love Common Lisp and hate Java (2012)

#89
post #7

It is a recurring theme for people to point out how verbose a hello world program is in Java: class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); } } For argument sake, let's compare it not to Lisp but to Python instead: print("Hello World!") Once you get proficient in a language and start writing larger programs, your perspective can change entirely. What appears to be…

Totally agree with you - I like Java precisely because it's so verbose. I'd rather have to type 20% more than spend 20% more time figuring out other people's code. And honestly, I always feel that the Hello World example is kind of biased. It's more an example of Java's way of launching a program being verbose because every program requires a certain minimal structure. But for the rest of the entire Java language tha…

The kind of verbosity you describe isn't really the issue in my view. The contentious verbosity is theKindWhereVariableNamesLookLikeThis and "fluent" programming style that turns "assert(testRes == expected)" into "assertThat(testRes).isEqualTo(expected)". It's excessive and removes value most of the time.

Re: Why I love Common Lisp and hate Java (2012)

#90
post #7

It is a recurring theme for people to point out how verbose a hello world program is in Java: class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); } } For argument sake, let's compare it not to Lisp but to Python instead: print("Hello World!") Once you get proficient in a language and start writing larger programs, your perspective can change entirely. What appears to be…

But “forcing learning early on” is exactly the problem. Approachable languages lead you up their learning curves in small, easy steps. The more knowledge you require newbies to swallow in one bite, the greater the number that will choke. (Not that anyone would call Lisp approachable either, of course.)

Agreed. I went back and read the original discussion on HN about this blog post and one commenter phrased it as such:

You need to learn and memorise 15 facts to fully grok the Java Hello World snippet (including how to compile and run it), for Python it's only four facts.

That's a big difference in cognitive load.

Post reply on HN