Why I love Common Lisp and hate Java (2012)
kuomarc.wordpress.com
Why I love Common Lisp and hate Java (2012)
1–10 of 171 posts
Re: Why I love Common Lisp and hate Java (2012)
#2jshell> "Hello World!"
$1 ==> "Hello World!"
Re: Why I love Common Lisp and hate Java (2012)
#3Re: Why I love Common Lisp and hate Java (2012)
#4The article could be improved by including an example. Pick one in which Java makes the problem to be solved tedious, verbose, repetitive, or error-prone and where Lisp macros do not. Bias the example as much as possible to a problem where Lisp can shine. It should, however, be a real problem most programmers are likely to face in some form.
Then present the source for both solutions.
This approach would even help those who don't use Java regularly because they could try to implement the same functionality in their language of choice and compare it the the Lisp implementation.
Re: Why I love Common Lisp and hate Java (2012)
#5If you are running JDK 9 or later, you can use jshell: jshell> "Hello World!" $1 ==> "Hello World!" https://openjdk.java.net/jeps/222
I don’t think the argument in the linked article is very good but this apology is worse. It doesn’t really show any merit of Java (more that the repl in Java is much less powerful than in eg CL) or argue against the spirit of the article.
Re: Why I love Common Lisp and hate Java (2012)
#6If you are running JDK 9 or later, you can use jshell: jshell> "Hello World!" $1 ==> "Hello World!" https://openjdk.java.net/jeps/222
Re: Why I love Common Lisp and hate Java (2012)
#7 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 verbose in the Java version starts to make sense. For example:* In Java the top level only contains classes and interfaces. All functions must be put inside a class, and I believe this design simplifies conceptual understanding. Whereas in Python, you have a distinction between top-level variables and functions versus fields and methods bound in classes.
* Python always executes the top level, so you end up with awkward idioms like: if __name__ == "__main__": main(sys.argv)
* Static typing versus dynamic typing. We all know this debate, so I won't repeat it. (This is regarding void and String[].)
* The "public" keyword might seem like noise, but in Python you denote private by prefixing the name with one or two underscores.
* 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.
* You still eventually need to learn what "@staticmethod" means in Python. Java just forces this learning early on.
Re: Why I love Common Lisp and hate Java (2012)
#8It 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…
Yes? It's great for debugging, which is generally what you'd use a print for anyways in a large application.
Re: Why I love Common Lisp and hate Java (2012)
#9It 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…
(Not that anyone would call Lisp approachable either, of course.)
Re: Why I love Common Lisp and hate Java (2012)
#10It 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…
> 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.