Live data from Hacker News

Why I love Common Lisp and hate Java (2012)

kuomarc.wordpress.com

41–50 of 171 posts

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

#41
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…

Java's insistence on using one class to one file, naming files with class names and placing everything in a class is extremely helpful in industrial software engineering. When you pile up devs with different backgrounds, some bright, some bad, the rules that force everyone to follow some standard are great. This also helps with creating IDEs and refactoring tools. If your area is to play with math, go use whatever you want. Java is not that, it's sweet spot is different. Why is thislink here? There's literally nothing smart or useful in it.

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

#42

Earlier quoted context omitted.

You really should be using a logging framework instead though, if you're working on a large application.

You use logging for production, but if you just want to see what a value is while when you run your program in the IDE and might not for a logger imported, print is handy.

If you're running from an IDE and want to inspect values, why not just set a breakpoint?

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

#44
post #29

Earlier quoted context omitted.

What about closures? Also, those lambdas are actually classes that try very hard to look like lambdas, but aren't actually.

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-closure...

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

#45
post #30

Earlier quoted context omitted.

This idea that debugging with print statements is superior to using a debugger is simply false. Learn to use the debugger for your platform it will pay huge dividends throughout your career. I regularly see pais+ of println debuggers debate and speculate while the guy with the debugger drills straight down to the issue, and fixes it.

I think it is a fallacy to choose either printing or debugging. I forgot where I read this, but the two techniques are fundamentally different. A debugger lets you stop execution and examine data structures at one point in time. Printing lets you accumulate a log of one particular data structure over a span of time. I think these techniques are complementary and have different effectiveness on different problems.

Yep. They call it “tracing” in debugging and a good debugger will be able to directly catch and log the values of any variable at a particular line of code.

By using logging instead you’re reimplementing years of good work done by engineers before you.

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

#47

Earlier quoted context omitted.

Fair enough, but attaching multiple debuggers across several interacting components with conditional breaks gets me there faster than incrementally inserting progressively more print statements, in a dev environment. Proper logging is a given doping out problems in a production system to then verify and correct in dev.

Logs aren't a bad thing and they aren't going away. Whoever let's you setup debuggers on prod should be fired.

Sometimes having a debugger on prod is the right answer.

"The Remote Agent software, running on a custom port of Harlequin Common Lisp, flew aboard Deep Space 1 (DS1), the first mission of NASA's New Millennium program. Remote Agent controlled DS1 for two days in May of 1999. During that time we were able to debug and fix a race condition that had not shown up during ground testing. (Debugging a program running on a $100M piece of hardware that is 100 million miles away is an interesting experience. Having a read-eval-print loop running on the spacecraft proved invaluable in finding and fixing the problem. The story of the Remote Agent bug is an interesting one in and of itself.)

"The Remote Agent was subsequently named "NASA Software of the Year"."

http://www.flownet.com/gat/jpl-lisp.html

http://ti.arc.nasa.gov/m/pub-archive/176h/0176 (Havelund).pdf

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

#48
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…

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 over shooting myself in the foot because Python does little to protect me from my own silly type/name mistakes.

I do lament that Java falls short on being able to declare tuples, lists, and dictionaries easily.

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

#49
post #4

Beside the REPL, another impressive feat of Common Lisp is meta-programming. You can write software to write software. Say what? Yeah, that was my initial reaction too, but Common Lisp’s macro system allows you to write functions that return code snippets. It completely redefines the word. Or more accurately, re-redefines, since Lisp is much older than MS Office, which is what most people associate macros with, sadly…

I would love to see the reverse. Ive never seen a Java codebase that I thought was pleasant to work with, but maybe I'm just not looking hard enough.

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

#50
post #39
post #4

Beside the REPL, another impressive feat of Common Lisp is meta-programming. You can write software to write software. Say what? Yeah, that was my initial reaction too, but Common Lisp’s macro system allows you to write functions that return code snippets. It completely redefines the word. Or more accurately, re-redefines, since Lisp is much older than MS Office, which is what most people associate macros with, sadly…

Inline some data structure. Json, interestingly, embeds trivially in lisp. Not so much in Java. Especially once you learn the quasi quote.

[deleted]
Post reply on HN