News for hackers. Stuff that matters.
Re:Why I love Common Lisp and hate Java (2012) by lmm on Sunday November 04, 2018 @06:37AM (#18375382)
> 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.

Strongly disagree. (Traditional) Java has no way to represent a function or a class as a first-class entity and it suffers for it. In Python functions and classes are plain old values (and indeed objects) and any value can live at top level in the module.

> * Python always executes the top level, so you end up with awkward idioms like: if __name__ == "__main__": main(sys.argv)

How is that any more "awkward" than the Java way? It's fewer lines of ceremony in all cases as far as I can see.

> * The "public" keyword might seem like noise, but in Python you denote private by prefixing the name with one or two underscores.

So Python has a) a better default (it's not that Java doesn't have a default visibility level, it's just such a spectacularly useless one that it never sees use) b) a concise symbolic syntax for something that's used extremely commonly, which is the right approach: http://www.lihaoyi.com/post/StrategicScalaStyleConcisenessNa...

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

Big applications will always have their own frameworks and no possible default set of imports makes sense for big applications (Java's default imports from java.lang. get in the way for big applications too). But a good language should work for small scripts as well as big applications, so having print in there by default makes sense. (I can sympathise with having a no-default-imports option or something like Haskell's custom preludes).

> * You still eventually need to learn what "@staticmethod" means in Python.

My 10+ years of Python say otherwise. You really don't.

There are no comments on this comment yet.