Live data from Hacker News

Why I love Common Lisp and hate Java (2012)

kuomarc.wordpress.com

61–70 of 171 posts

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

#61

Earlier quoted context omitted.

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!”).

So going back to the original commenter's points: how does Swift handle top-level code? Where is it legal for me to write print("Hello, World")?

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

#62

Earlier quoted context omitted.

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…

I have yet to come across a situation in which it is not worth the effort to figure out how to attach a debugger to a piece of code I'm modifying.

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

#63
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 remember being struck by a snippet of pseudocode in a discrete mathematics textbook[0]:

https://pastebin.com/L2dwawgu

So basically being able to run an arbitrary number of dependent, nested loops. Now imagine you want to run arbitrary code in the interior, rather than just incrementing a count.

It's a simple idea. And it can be expressed so succinctly in just a few lines of pseudocode in a freshman-level computer science textbook.

And yet I wouldn't want to touch this in Java. The lisp macro to write this isn't much more verbose than the pseudocode itself.

[0] Rosen's Discrete Mathematics and Its Applications, 7th e.

Edit: Traded formatting for pastebin

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

#64
I've recently come around on Java (although I'll still rarely choose it), mostly due to the idea that "all things get complicated, so what matters is how you manage that complexity".

Java started to "click" when I realized how much you build objects out of other objects like layers of an onion, just adding a bit at each step, and it clicked a bunch more as I understood Spring's bean system, which itself clicked more when I began to understand that the object-based dependency graph is basically the equivalent of the top-level Ruby script. All the code describes how X and Y relate to eachother, and then you go to the bean definitions to find out what X and Y are. That's actually pretty neat.

I still prefer the "simple script" approach you can do in Ruby; and I'm loving the way Scala is kind of Ruby, but in Java, and so (and to relate to the actual content) inherits a lot more from Lisp.

So, PS, author, if you're reading this, seriously give Scala a try. It's been pretty fantastic so far for me!

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

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

You're really underestimating the power of Java's boring workhorse methodology. If you're looking for love there's a lot of other languages that are more pure and more beautiful for certain use cases.

However, there's a reason Java is in the top 3 most popular languages. Its pragmatic, it scales, it plays nice with tooling and the language itself is pretty passable.

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

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

You can have your cake and eat it though thanks to kotlin.

It is way more concise than java but does not become ambiguous because of it.

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

#67

Earlier quoted context omitted.

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

So going back to the original commenter's points: how does Swift handle top-level code? Where is it legal for me to write print("Hello, World")?

Anywhere outside of things like a class or structure definition, if you have a single-file project. In a multi-file project, only in main.swift.

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

#68

Earlier quoted context omitted.

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…

I have yet to come across a situation in which it is not worth the effort to figure out how to attach a debugger to a piece of code I'm modifying.

Again, attaching a debugger is occasionally not helpful–for example, if you're trying to figure out why your program isn't loading certain plugins at launch, you trying to attach the debugger may happen after this step occurs. So you don't get to debug this process.

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

#70
post #36

Earlier quoted context omitted.

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.

Smalltalk folks will debug in production too. Although to be fair, Smalltalk folks will write whole programs in debug in development.
Post reply on HN