Live data from Hacker News

Why I love Common Lisp and hate Java (2012)

kuomarc.wordpress.com

21–30 of 171 posts

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

#21

Earlier quoted context omitted.

Whats even better than print for debugging is using a debugger...

Doesn't quite work when debugging a distributed system, though. You end up adding a lot of "distributed print", AKA logging.

There is much more to logging than print statements. I have yet to run into production code which uses vanilla stdout print statements for logging.

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

#22

Earlier quoted context omitted.

Whats even better than print for debugging is using a debugger...

I disagree. Most of the time, I find a debugger just slows me down. It's super helpful in some cases, but good logs can pinpoint problems far before a debugger can. Also, building in debug mode can change everything, so you may not even catch your bug, especially if it's concurrent in nature.

I think there are two use cases here, I was referring to debugging during development and a lot of replies are regarding troubleshooting an active prod system.

Of course we all hope for well thought out logging to troubleshoot issues we're seeing in prod.

I'm referencing an pattern I see with junior devs who simply use "printf debugging" in development instead of learning to use a debugger properly, even with distributed systems.

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

#23

Earlier quoted context omitted.

Whats even better than print for debugging is using a debugger...

I disagree. Most of the time, I find a debugger just slows me down. It's super helpful in some cases, but good logs can pinpoint problems far before a debugger can. Also, building in debug mode can change everything, so you may not even catch your bug, especially if it's concurrent in nature.

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.

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

#24

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.

Agreed, great logs are great.

My comment explicitly stated dev environment, not prod, for debugger usage.

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

#25
The languages that tend to become popular are simply languages that appeal to the lowest common denominator. Java was the language invented for the "common programmer", and people find that comforting. Now it's Go; as Rob Pike once said of it, "They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt."

That's why it's always a battle to push languages like Lisp, that offer mathematical elegance over languages that are a soup of half baked idea that veer programmers away from ideas that take more than a few days to master. For those of us who aspire to do better, we should continue to try to bring the from first principles approach of functional programming to the mainstream.

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

#26
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 that's not the main method, the only real "verbosity" comes from having to declare types, which is pretty much just a requirement of statically typed language and isn't so specific to Java itself.

I've written reasonably large amounts of code in Python, Javascript, Ruby, Racket, StandardML, etc. Every language has its own little forms of "beauty" - chunks of code that are particularly short and pretty to write in those languages. And I do get a certain amount of satisfaction doing trickier operations in a couple lines in languages like Python. But I always end up preferring Java's more verbose style because I don't want to have to think about the correct syntax to maximize my code's stylishness.

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

#27

Earlier quoted context omitted.

> Do you really want print() to be so easily accessible in the top-level namespace? It seems to me that the bigger an application gets, the worse it is to easily litter the codebase with print statements. Yes? It's great for debugging, which is generally what you'd use a print for anyways in a large application.

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.

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

#28

Earlier quoted context omitted.

> Do you really want print() to be so easily accessible in the top-level namespace? It seems to me that the bigger an application gets, the worse it is to easily litter the codebase with print statements. Yes? It's great for debugging, which is generally what you'd use a print for anyways in a large application.

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

Except you don't want to have your logger in all places: unit tests, early in startup lifecycle when guice or spring haven't wired everything up yet, etc. Printing to stdout is simple and ubiquitous.

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

#29
post #6
post #2

If you are running JDK 9 or later, you can use jshell: jshell> "Hello World!" $1 ==> "Hello World!" https://openjdk.java.net/jeps/222

And lambdas were introduced in 8 making nearly all of the author’s issues mute.

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

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

#30

Earlier quoted context omitted.

I disagree. Most of the time, I find a debugger just slows me down. It's super helpful in some cases, but good logs can pinpoint problems far before a debugger can. Also, building in debug mode can change everything, so you may not even catch your bug, especially if it's concurrent in nature.

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.
Post reply on HN