Live data from Hacker News

Why I love Common Lisp and hate Java (2012)

kuomarc.wordpress.com

31–40 of 171 posts

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

#31

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.

No one said otherwise, and the comment you replied to specifies "in a dev environment". The language you are using is unnecessarily combative: this is likely to inhibit the adoption of your ideas.

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

#32

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.

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 distrib…

> an pattern I see with junior devs who simply use "printf debugging" in development

Whereas I see this pattern more with senior engineers.

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

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

Swift is statically typed and a “Hello, World!” in Swift is just print(“Hello, World!”).

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

#34
post #29
post #6

Earlier quoted context omitted.

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.

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.

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

#35

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.

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

If I have easy access to a debugger. It’s extra work to hook things up to a debugger, and there are certain restrictions that may apply (attach too late if process launch is not under our control, program may behave differently, etc.). If I do have access to a debugger, often I will just do “printf debugging” there by setting a breakpoint and adding an action to “p someVariable; c”. Usually I treat my debugger a sort of IPython for statically compiled languages, to mess around with and inspect values as programs are executing.

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

#36

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.

Only with python. With LISP it's the common case to debug prod.

I would rather argue that such incompetent managers who speak such nonsense need to be fired.

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

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

there is a lot more structure in this java snippet though. At equivalent structure, the python code isn't that much shorter.

It's just convenient for a scripting language to be able to print stuff without any code structure. Something that Java enforces.

I've concluded it's because Java isn't designed for scripting that it doesn't allow scripting practices in its code bases. I just started learning Java and I guess if I use a class that could throw an exception I have to catch it (or transfer it to my class' user it seems). In this particular test I knew it wasn't gonna throw but it wouldn't compile: I was opening a file I knew existed for some quick test - instead of 1 python line I got 7 java ones. But with exception / catch structure.

It's an enterprise language, I'm all for the code structure enforcement. Help a dev catch an exception, so many things could already go wrong on larger codebases ;)

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

#38

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.

... which you can build using a LoggingFrameworkFactory.

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

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

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

#40
post #13
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

Turns out C# also has a REPL now, it's called "C# interactive". I've found out just now, spurred to look for it by your post.

Ummmm yes & no. It has a REPL, but it sure isn't easy to use and very few C# coders actually use it. Contrast that with a dynamic language like Python where people basically live in the REPL. Common Lisp takes this to a whole new level. You really can't equate C#'s REPL to Common Lisp's. This is one of those things where the sum of the thing is greater than its parts. Note that I'm not saying C# isn't a decent language, just very very different than what you get with languages like Smalltalk & Lisp.
Post reply on HN