News for hackers. Stuff that matters.
Re:Why I love Common Lisp and hate Java (2012) by nayuki on Saturday November 03, 2018 @08:47PM (#18373357)
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 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) by rococode on Saturday November 03, 2018 @09:30PM (#18373510)
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) by nayuki on Saturday November 03, 2018 @10:09PM (#18373665)
I would say that Java has ~50% more code than Python due to types and braces. But I agree with you that it's worth it, because the compiler can check that a programmer satisfied a constraint, instead of relying on informal conventions or comments.

You can have a statically typed language without verbosity, via type inference (Haskell, newer Java, etc.). I wouldn't say I enjoy Java's verbosity, but I would take this over shooting myself in the foot because Python does little to protect me from my own silly type/name mistakes.

I do lament that Java falls short on being able to declare tuples, lists, and dictionaries easily.

Re:Why I love Common Lisp and hate Java (2012) by ilovecaching on Saturday November 03, 2018 @11:24PM (#18373995)
Most Haskellers write out the types even though they can be inferred. In a pure language, signatures are extremely close to documentation (you know exactly what a function will do by its signature).

Java requires more code than Python or Haskell because it's extremely imperative and statement based. Python on the other hand includes a lot of functional, more expressive idioms like concise list comprehensions.

Re:Why I love Common Lisp and hate Java (2012) by FranzFerdiNaN on Sunday November 04, 2018 @02:26AM (#18374721)
Types aren’t documentation, no matter how many Haskell users delude themselves thinking it is.

Documentation is more than a function definition. Types don’t explain rationales and how to use functions and programs. Types don’t give proper examples.

Re:Why I love Common Lisp and hate Java (2012) by chowells on Sunday November 04, 2018 @02:50AM (#18374784)
Types are really good documentation. I can tell I'm not deluded by thinking so because I can sit down with a Haskell library containing zero examples and write code that uses it. If your assertion was correct, that would be impossible. But it's not only possible, it's easy. Perhaps there is more to types than you realize.
Re:Why I love Common Lisp and hate Java (2012) by pmoriarty on Sunday November 04, 2018 @09:45AM (#18376074)
Alice: Hey Bob, want to try my nifty new function?

Bob: Sure, Alice, what does it do?

Alice: It takes an object and it returns an object.

Bob: But what does it actually do?

Alice: I told you. It takes an object and it returns an object.

Bob: But what does it do with the object? What's it for? Why should I use it?

Alice: Hey, I just gave you the full documentation for my function. You have everything you need. Now go use it.

Bob: Um, no thanks. I like to know more about what I'm getting myself in to.

Re:Why I love Common Lisp and hate Java (2012) by xboxnolifes on Sunday November 04, 2018 @11:37AM (#18376664)
Thankfully, Haskell supports much nicer types than only `Object`
Re:Why I love Common Lisp and hate Java (2012) by pvorb on Sunday November 04, 2018 @01:53PM (#18377425)
Alice: Hey Bob, want to try my nifty new function?

Bob: Sure, Alice, what does it do?

Alice: It takes a string and it returns an integer.

Bob: But what does it actually do?

Alice: I told you. It takes a string and it returns an integer.

Bob: But what does it do with the string? What's it for? Why should I use it?

Alice: Hey, I just gave you the full documentation for my function. You have everything you need. Now go use it.

Bob: Um, no thanks. I like to know more about what I'm getting myself in to.

Re:Why I love Common Lisp and hate Java (2012) by ilovecaching on Sunday November 04, 2018 @02:40PM (#18377681)
I think you're criticizing a language you have no experience in. Haskell development is type driven. You start by defining and constraining your types until you get a DSL to write signatures in. See the Idris O'reilly book for more on type driven development.

By the time you've added type constrains through typeclasses, selected types named after the domain, and selected a suitable name for the function, it's possible to write against the signature with no knowledge of the body or comments.

You're also forgetting that signature includes the name of the function.

reverse :: [a] -> [a] is easy to understand by it's name and type.

Re:Why I love Common Lisp and hate Java (2012) by pvorb on Sunday November 04, 2018 @04:20PM (#18378117)
I didn't critisize Haskell. I only criticized a statement about its type system.

> You're also forgetting that signature includes the name of the function.

That's what I wanted to point out. The name of a function is even more important than its types. Types alone seldomly give you the complete picture of what's going on in a function.

Of course the name can be wrong whereas types can't, but the name is less likely to be wrong than a comment.

Re:Why I love Common Lisp and hate Java (2012) by ilovecaching on Sunday November 04, 2018 @02:47PM (#18377724)
I suggest reading Type-Driven Development with Idris by Edwin Brady. I don't think you have enough experience writing Haskell to understand the outcome of type driven development.

In Haskell you start by defining your domain as types, and constrain those types with typeclasses. By the time you get to writing signatures, the implementations can almost be inferred (in Idris they actually can be inferred, the code literally writes itself).

In an imperative language with side effects, examples and documentation are a must because behavior is hidden in the body of a function; the signatures lie.

A journeyman Haskeller can write code that is completely self documenting. No examples are required, because the types coupled with the purity of the language allows us to tell the whole story.

Re:Why I love Common Lisp and hate Java (2012) by Buttons840 on Sunday November 04, 2018 @08:28PM (#18379134)
This is (probably often) true for all those who can load a few dozen arbitrary type signatures into their active memory and start drawing conclusions. For the rest of us a few examples of how to do common things would help a lot. Please include documentation.

I have experienced what you're talking about with Haskell but it was a lot of uncomfortable work. But it's "technically" true that the types often describe how to use a library, sometimes so well that errors cannot happen.

Re:Why I love Common Lisp and hate Java (2012) by StavrosK on Sunday November 04, 2018 @07:44AM (#18375593)
Types are documentation. Documentation isn't types.
Re:Why I love Common Lisp and hate Java (2012) by hasahmed on Sunday November 04, 2018 @02:38AM (#18374757)
It's better documentation than no documentation
Re:Why I love Common Lisp and hate Java (2012) by omaranto on Sunday November 04, 2018 @12:54AM (#18374308)
> Most Haskellers write out the types even though they can be inferred.

I don't think that's true. Idiomatic Haskell has explicit declarations only for top level functions and uses type inference for everything else.

Re:Why I love Common Lisp and hate Java (2012) by jose_zap on Sunday November 04, 2018 @06:16AM (#18375314)
I often copy paste the inferred type to top level declarations, so I’m a sense it is true
Re:Why I love Common Lisp and hate Java (2012) by pytester on Sunday November 04, 2018 @05:26AM (#18375192)
>In a pure language, signatures are extremely close to documentation (you know exactly what a function will do by its signature).

The same can be true of tests. I've started generating API documentation from mine: e.g. https://hitchdev.com/strictyaml/using/alpha/scalar/email-and...

I tend to think of types and tests as attacking the same problem from opposite directions.

Re:Why I love Common Lisp and hate Java (2012) by sethammons on Sunday November 04, 2018 @08:17AM (#18375711)
> StrictYAML can validate emails (using a simplified regex)

Public Service Announcement: don't validate emails with regex. Every time you do, god kills a kitten.

Re:Why I love Common Lisp and hate Java (2012) by pytester on Sunday November 04, 2018 @08:51AM (#18375853)
Just checking for the @ symbol is fair game. Anything beyond that is a bad idea.
Re:Why I love Common Lisp and hate Java (2012) by sethammons on Sunday November 04, 2018 @02:47PM (#18377727)
Agreed :)
Re:Why I love Common Lisp and hate Java (2012) by YouAreGreat on Sunday November 04, 2018 @07:58AM (#18375645)
> Most Haskellers write out the types

Maybe that's partly because Haskell can easily become a bit too elegant. Between all the currying and combinators, the type helps to understand code "top down", i.e. when you don't have studied and memorized all "bottom up" component parts.

Re:Why I love Common Lisp and hate Java (2012) by m_mueller on Saturday November 03, 2018 @11:25PM (#18374002)
Tuples especially, and more specifically how the language supports their unwrapping.

for idx, entry in enumerate(list)

vs. list iterators in Java where you have to repeat complex types at least 3 times and get about 5-10 times more code when it would only have to be about 2 times to achieve static type safety. Lack of typedef and the resulting drive towards dummy classes is exacerbating this problem further.

Re:Why I love Common Lisp and hate Java (2012) by ilovecaching on Saturday November 03, 2018 @11:21PM (#18373977)
Java is verbose, but it isn't expressive. In Java you talk a lot without ever saying anything. In an expression based language like Lisp or Rust, you can more compactly write your ideas into code, even though Rust might still be verbose syntactically like Java.
Re:Why I love Common Lisp and hate Java (2012) by sidlls on Sunday November 04, 2018 @01:35AM (#18374430)
The kind of verbosity you describe isn't really the issue in my view. The contentious verbosity is theKindWhereVariableNamesLookLikeThis and "fluent" programming style that turns "assert(testRes == expected)" into "assertThat(testRes).isEqualTo(expected)". It's excessive and removes value most of the time.
Re:Why I love Common Lisp and hate Java (2012) by jimmyspice on Sunday November 04, 2018 @05:17AM (#18375162)
Well the fluent style is more verbose, but has the advantage of telling you more information about what went wrong. You get a report telling you that "x was not equal to y" rather than "expected true". The verbosity is way more helpful to me.
Re:Why I love Common Lisp and hate Java (2012) by polityagent on Sunday November 04, 2018 @07:07AM (#18375485)
or you can use a language with macros, then a testing library can report the code being evaluated and the values in it.
Re:Why I love Common Lisp and hate Java (2012) by sidlls on Sunday November 04, 2018 @04:42PM (#18378206)
Even Java has testing libraries that provide optional failure case messages with asserts to provide specific context where necessary.
Re:Why I love Common Lisp and hate Java (2012) by saagarjha on Saturday November 03, 2018 @09:35PM (#18373528)
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) by sanderjd on Saturday November 03, 2018 @10:56PM (#18373858)
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) by saagarjha on Saturday November 03, 2018 @11:07PM (#18373916)
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) by Redoubts on Sunday November 04, 2018 @04:28PM (#18378151)
> I'd rather have to type 20% more than spend 20% more time figuring out other people's code.

If that were the trade off, it would be a no brainer. But instead it feels like double the code, for no clarity (or negative clarity because the noise becomes obfuscation).

Re:Why I love Common Lisp and hate Java (2012) by goatlover on Sunday November 04, 2018 @03:15AM (#18374844)
Can't you get all the same advantages of Java with less verbosity in languages like Go, Swift, Rust or Haskell?
Re:Why I love Common Lisp and hate Java (2012) by GlennS on Sunday November 04, 2018 @12:06AM (#18374143)
These criticisms look to me like you are trying to use your Java programming style in Python.

Prefer to use modules and tables of functions as an organising principle instead of classes.

Use inheritance rarely, and method overriding almost never. Otherwise you can make a really big mess (see Django's Form class hierarchy).

This sort of bad design where you have the flow of control jumping up and down the inheritance hierarchy happens in Java too, but the `abstract` keyword and static typing makes it easier to avoid.

In Java, make your code regular, so someone can understand the piece they're looking at without too much context.

In Python, make your code interesting. Factor out the unimportant repetitive parts, so someone can see a lot of the big picture all at once.

Incidentally, I'm quite happy with print() in the top-level namespace. Java's logging situation (5 widely used logging frameworks and a 6th to abstract over them all) is not better.

Re:Why I love Common Lisp and hate Java (2012) by devxpy on Sunday November 04, 2018 @07:27AM (#18375546)
> Django's Form class hierarchy

I personally liked it. It is a little overwhelming at first, but after you get used to it, it's actually quite powerful.

Re:Why I love Common Lisp and hate Java (2012) by saagarjha on Saturday November 03, 2018 @08:51PM (#18373373)
> 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.

Re:Why I love Common Lisp and hate Java (2012) by rococode on Saturday November 03, 2018 @09:15PM (#18373455)
You really should be using a logging framework instead though, if you're working on a large application.
Re:Why I love Common Lisp and hate Java (2012) by WaxProlix on Saturday November 03, 2018 @09:33PM (#18373517)
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) by dragonwriter on Sunday November 04, 2018 @04:08AM (#18374975)
> Except you don't want to have your logger in all places

Yes, I do.

Now, I may have to work with a language/ecosystem that makes that awkward, sure, but that's a problem, if an incredibly common one (Julia is one of the few languages that avoids it.)

Re:Why I love Common Lisp and hate Java (2012) by akvadrako on Saturday November 03, 2018 @09:31PM (#18373511)
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) by all2 on Sunday November 04, 2018 @12:07AM (#18374149)
Coming from python I like to set a breakpoint, and dive in with pdb. It's super easy to navigate through the stack frame and poke around to see what all the variables are. I get more out of inspecting state from inside of pdb than I do out of print statements.

On the other hand, I tend to use only print statements when I'm roughing in a program in an iPython Notebook. This gives a sort of visual documentation when navigating a library that I'm new to, and allows me to glance back at a verbose description of otherwise opaque data structures.

Re:Why I love Common Lisp and hate Java (2012) by rpeden on Saturday November 03, 2018 @09:54PM (#18373605)
If you're running from an IDE and want to inspect values, why not just set a breakpoint?
Re:Why I love Common Lisp and hate Java (2012) by tormeh on Saturday November 03, 2018 @10:31PM (#18373749)
Doesn't work with multithreaded applications and works poorly with non-deterministic behavior, so sometimes you just have to print lots of info and see if anything interesting pops up. It also requires knowledge about tooling for the language you're working on right now, which as a polyglot you might not care to learn.
Re:Why I love Common Lisp and hate Java (2012) by LoSboccacc on Sunday November 04, 2018 @07:05AM (#18375476)
Nah there's debugging for that
Re:Why I love Common Lisp and hate Java (2012) by amelius on Saturday November 03, 2018 @09:47PM (#18373576)
... which you can build using a LoggingFrameworkFactory.
Re:Why I love Common Lisp and hate Java (2012) by xxs on Saturday November 03, 2018 @10:24PM (#18373718)
It's java.util.logging.Logger.getLogger(...), and normally you'd have "java.util.logging.Logger" imported.
Re:Why I love Common Lisp and hate Java (2012) by judgardner on Saturday November 03, 2018 @08:56PM (#18373386)
Whats even better than print for debugging is using a debugger...
Re:Why I love Common Lisp and hate Java (2012) by beatgammit on Saturday November 03, 2018 @09:11PM (#18373440)
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.
Re:Why I love Common Lisp and hate Java (2012) by marktangotango on Saturday November 03, 2018 @09:20PM (#18373475)
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) by nayuki on Saturday November 03, 2018 @09:33PM (#18373520)
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.
Re:Why I love Common Lisp and hate Java (2012) by heavenlyblue on Saturday November 03, 2018 @09:58PM (#18373623)
Yep. They call it “tracing” in debugging and a good debugger will be able to directly catch and log the values of any variable at a particular line of code.

By using logging instead you’re reimplementing years of good work done by engineers before you.

Re:Why I love Common Lisp and hate Java (2012) by xxs on Saturday November 03, 2018 @10:26PM (#18373725)
>I find a debugger just slows me down

1st you have to add the useless print statements and after decades of programming a debugger is vastly superios in terms of 'debugging' when compared to printing. (Back in time basic had no debugger even)

Also printing is utterly useless for high concurrent code, as printing alters memory visibility, usually adds global sync, etc..

Re:Why I love Common Lisp and hate Java (2012) by a_t48 on Saturday November 03, 2018 @11:15PM (#18373952)
Attaching a debugger will also change the behavior of concurrent code.
Re:Why I love Common Lisp and hate Java (2012) by xxs on Monday November 05, 2018 @01:43AM (#18380356)
This would depend on the language/compiler/linker - take Java (which the article is about). Attaching debugger does nothing prior to adding a breakpoint.

The breakpoint would cause the method to be deoptimized, executed in the interpreter. Removing the breakpoint would allow the method to be optimized again.

Now obviously during stepping in, the thread would be blocked and not highly concurrent. However print statements just bare the concurrency.

Re:Why I love Common Lisp and hate Java (2012) by a_t48 on Monday November 05, 2018 @08:54PM (#18387724)
Let's face it - concurrency sucks to debug in general.
Re:Why I love Common Lisp and hate Java (2012) by shaklee3 on Sunday November 04, 2018 @01:05AM (#18374347)
So does repl, to be fair.
Re:Why I love Common Lisp and hate Java (2012) by judgardner on Saturday November 03, 2018 @09:20PM (#18373474)
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) by akvadrako on Saturday November 03, 2018 @09:34PM (#18373523)
> 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) by analognoise on Saturday November 03, 2018 @10:40PM (#18373795)
I don't use printf. I tie a pin to an assertion of the expected result, and watch it with an oscilloscope.

Get on my level, normies. /s

Re:Why I love Common Lisp and hate Java (2012) by saagarjha on Saturday November 03, 2018 @09:39PM (#18373548)
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) by sanderjd on Saturday November 03, 2018 @10:58PM (#18373866)
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) by saagarjha on Saturday November 03, 2018 @11:09PM (#18373922)
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) by dvlsg on Sunday November 04, 2018 @12:05AM (#18374139)
Or if an issue happens in your staging environment but not locally. That happened to me just yesterday, and a simple print statement gave me the information I needed to resolve the issue.

I probably could have attached a remote debugger, and executed the relevant function a few times until my request got routed to the right process in the cluster, but that honestly would have taken me more time than just committing the print statement and letting CI take it away.

Re:Why I love Common Lisp and hate Java (2012) by sanderjd on Sunday November 04, 2018 @10:04AM (#18376154)
That seems like a good thing to use logging for, instead of a print statement.

But you're right, figuring out a dev / prod discrepancy in already-running code is a case where a debugger is not as useful.

Re:Why I love Common Lisp and hate Java (2012) by candiodari on Sunday November 04, 2018 @04:35AM (#18375048)
Exactly, and in the replies it is really obvious what the debate is really colored by.

In many cases there is no debugger available for someone's favorite platform. And so they "hate debugging". Go programmers, javascript people (where you can't do client->server debugging, but really, really have to), ...

How many Java programmers don't use debuggers ? How many C# developers ? Those languages have excellent debuggers. Python, C/C++, ... decent at best. Go/Javascript/... dismal debugging support.

Re:Why I love Common Lisp and hate Java (2012) by minitech on Sunday November 04, 2018 @05:39AM (#18375232)
> Javascript/... dismal debugging support.

Eh? I thought JavaScript debuggers were pretty good.

Re:Why I love Common Lisp and hate Java (2012) by candiodari on Sunday November 04, 2018 @01:13PM (#18377201)
I always compare my React debugging experience to something like GWT debugging from 5 years back ... and I find it very lacking indeed.
Re:Why I love Common Lisp and hate Java (2012) by ggambetta on Saturday November 03, 2018 @09:00PM (#18373402)
Doesn't quite work when debugging a distributed system, though. You end up adding a lot of "distributed print", AKA logging.
Re:Why I love Common Lisp and hate Java (2012) by judgardner on Saturday November 03, 2018 @09:05PM (#18373419)
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.
Re:Why I love Common Lisp and hate Java (2012) by sieabahlpark on Saturday November 03, 2018 @09:12PM (#18373443)
Logs aren't a bad thing and they aren't going away. Whoever let's you setup debuggers on prod should be fired.
Re:Why I love Common Lisp and hate Java (2012) by pmoriarty on Saturday November 03, 2018 @10:08PM (#18373662)
Sometimes having a debugger on prod is the right answer.

"The Remote Agent software, running on a custom port of Harlequin Common Lisp, flew aboard Deep Space 1 (DS1), the first mission of NASA's New Millennium program. Remote Agent controlled DS1 for two days in May of 1999. During that time we were able to debug and fix a race condition that had not shown up during ground testing. (Debugging a program running on a $100M piece of hardware that is 100 million miles away is an interesting experience. Having a read-eval-print loop running on the spacecraft proved invaluable in finding and fixing the problem. The story of the Remote Agent bug is an interesting one in and of itself.)

"The Remote Agent was subsequently named "NASA Software of the Year"."

http://www.flownet.com/gat/jpl-lisp.html

http://ti.arc.nasa.gov/m/pub-archive/176h/0176 (Havelund).pdf

Re:Why I love Common Lisp and hate Java (2012) by canhascodez on Saturday November 03, 2018 @09:34PM (#18373522)
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) by rurban on Saturday November 03, 2018 @09:40PM (#18373549)
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) by protomyth on Saturday November 03, 2018 @11:11PM (#18373935)
Smalltalk folks will debug in production too. Although to be fair, Smalltalk folks will write whole programs in debug in development.
Re:Why I love Common Lisp and hate Java (2012) by rurban on Monday November 05, 2018 @03:12AM (#18380688)
Sure. Arguably Smalltalk is a LISP, just with non-Lisp syntax. It actually was prototyped in lisp first.
Re:Why I love Common Lisp and hate Java (2012) by judgardner on Saturday November 03, 2018 @09:29PM (#18373506)
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) by avita1 on Saturday November 03, 2018 @09:17PM (#18373463)
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) by xiaq on Saturday November 03, 2018 @09:17PM (#18373460)
> In Java the top level only contains classes and interfaces.

This design makes sense from conceptual purity, but Java is never a conceptually pure language. It distinguishes value types and object types, for instance. Not allowing free functions is really just a poor design choice.

Worse, the proliferation of single-method interfaces (which are really just functions) and static methods (which are in most cases really just free functions) really prove that free functions are useful. Java just makes it harder to use them.

Re:Why I love Common Lisp and hate Java (2012) by jayd16 on Saturday November 03, 2018 @10:52PM (#18373842)
>Not allowing free functions is really just a poor design choice.

I don't see why. The verbosity is pretty minimal and you enforce the availability of a privacy scope you wouldn't have had. ie private static methods and members that your public statics can use.

Although, pure functions are nice if you can't trust the code you're calling won't surprise you.

Re:Why I love Common Lisp and hate Java (2012) by tasuki on Sunday November 04, 2018 @03:20AM (#18374856)
I think this has to do with naming. Naming is generally hard, with free functions you must name the function, in Java you must also name the class.

If you could show some examples of single method interfaces whose naming makes sense, I'd be delighted!

Re:Why I love Common Lisp and hate Java (2012) by jayd16 on Sunday November 04, 2018 @08:47PM (#18379216)
>If you could show some examples of single method interfaces whose naming makes sense, I'd be delighted!

IDisposable with a single Dispose() method?

Re:Why I love Common Lisp and hate Java (2012) by tasuki on Monday November 05, 2018 @07:04AM (#18381641)
Fair point, though I'd smack you for IDisposable :) Why not just Disposable?
Re:Why I love Common Lisp and hate Java (2012) by fantispug on Sunday November 04, 2018 @05:15AM (#18375156)
The "top level" problem is real in Python and in Lisps; but in practice it's not a huge issue (if you really don't like __name__ == "__main__" you can create your main app as a separate script to your library). main in Java is as magical as __name__ in Python.

Python now has type hints and good static checking libraries so you can add as much type checking as your want. Java's type system is atrocious (c.f. Haskell, OCaml); it doesn't check nulls (a common bug), making simple constructs (tuples, unions) often requires a new class file of boilerplate.

The HelloWorldApp is a bad fit for objects. All the functions are static. This confused me for a long time learning Java. You can get a very long way in Python without knowing @staticmethod.

The static nature of Java does make it easy to know where to look for things and introspect code; there tends to be less magic.

Re:Why I love Common Lisp and hate Java (2012) by diebir on Saturday November 03, 2018 @09:53PM (#18373601)
Java's insistence on using one class to one file, naming files with class names and placing everything in a class is extremely helpful in industrial software engineering. When you pile up devs with different backgrounds, some bright, some bad, the rules that force everyone to follow some standard are great. This also helps with creating IDEs and refactoring tools. If your area is to play with math, go use whatever you want. Java is not that, it's sweet spot is different. Why is thislink here? There's literally nothing smart or useful in it.
Re:Why I love Common Lisp and hate Java (2012) by globuous on Saturday November 03, 2018 @09:47PM (#18373573)
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) by j88439h84 on Saturday November 03, 2018 @10:50PM (#18373834)
From the perspective of a python programmer, I must say this is an interesting list. I'm rather convinced by your points on print and public.

On the other hand,

"__name__ == __main__" is just a convenience for debugging and small scripts. I wouldn't use it in real programs.

I dont use @staticmethod, or find it useful. If I want a function, I use a function.

Re:Why I love Common Lisp and hate Java (2012) by lou1306 on Sunday November 04, 2018 @09:53AM (#18376106)
> I dont use @staticmethod, or find it useful. If I want a function, I use a function.

In principle, it makes sense to "bundle" functions that are strictly related to a class within the class itself (i.e. as static methods). Of course, the benefits viz. top-level functions are only noticeable if your codebase is big enough.

Re:Why I love Common Lisp and hate Java (2012) by j88439h84 on Sunday November 04, 2018 @08:44PM (#18379200)
What are those benefits?
Re:Why I love Common Lisp and hate Java (2012) by lou1306 on Tuesday November 06, 2018 @06:20AM (#18390011)
Of course it's just better organization of the codebase and a less-polluted namespace. Also, if you're writing a library, it may affect the API you give to the user. If you move a function to a static method, the end user only needs to import the desired class.

But again, they are "usability" benefits. I'm no CPython expert but I don't think that a static method would have noticeably worse (or better) performance than a function.

Re:Why I love Common Lisp and hate Java (2012) by tasuki on Sunday November 04, 2018 @03:05AM (#18374820)
> Do you really want print() to be so easily accessible in the top-level namespace?

Not necessarily, but I definitely want functions to be accessible in the top-level namespace. Not everything is an object.

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.

Re:Why I love Common Lisp and hate Java (2012) by paavoova on Sunday November 04, 2018 @03:02AM (#18374807)
You wouldn't be able to write linear scripts in Python if it were so restrictive, or execute the interpreter from the command line with the -c command. You'd be forced to use OOP patterns for trivial code, whereas Python as it is now doesn't require any OOP at all. I really don't understand why you'd want to force everything into OOP doctrine.
Re:Why I love Common Lisp and hate Java (2012) by on_and_off on Saturday November 03, 2018 @11:03PM (#18373894)
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) by smacktoward on Saturday November 03, 2018 @08:55PM (#18373384)
But “forcing learning early on” is exactly the problem. Approachable languages lead you up their learning curves in small, easy steps. The more knowledge you require newbies to swallow in one bite, the greater the number that will choke.

(Not that anyone would call Lisp approachable either, of course.)

Re:Why I love Common Lisp and hate Java (2012) by TeMPOraL on Sunday November 04, 2018 @04:14AM (#18374992)
Agreed. When asked, I keep saying that Java is not the best "first language" to teach to a person, because it overwhelms people with concepts from the get-go.

A normal person who's sincerely trying to learn, when shown the Hello World will ask about everything - what is this "class" and why it's needed? What does "public", "static" and "void" mean, and why they're written. What "System.out" is? Not to mention, the package declaration at the top of the file.

All of those things have reasons for them, but when explaining this to a novice, you'll have to initially handwave most of those reasons away. That seems very uncalled for, especially when the basic abstraction you're trying to teach is that "computer executes simple instructions top to bottom, one at a time, and everything is built out of those simple instructions".

Re:Why I love Common Lisp and hate Java (2012) by kungtotte on Sunday November 04, 2018 @01:46AM (#18374466)
Agreed. I went back and read the original discussion on HN about this blog post and one commenter phrased it as such:

You need to learn and memorise 15 facts to fully grok the Java Hello World snippet (including how to compile and run it), for Python it's only four facts.

That's a big difference in cognitive load.

Re:Why I love Common Lisp and hate Java (2012) by coldtea on Sunday November 04, 2018 @06:28AM (#18375356)
> Python always executes the top level, so you end up with awkward idioms like: if __name__ == "__main__": main(sys.argv)*

And that's more "awkward" than the idea of a "public static void main" and a MANIFEST file because?

Re:Why I love Common Lisp and hate Java (2012) by RyanHamilton on Sunday November 04, 2018 @04:21AM (#18375013)
I've made an attempt at a java scratchpad/REPL that guesses what imports you want. It allows just print by itself but Dump("Hello World!") is better in most cases as it handles collections well and outputs to tables/HTML as well as text.

Example: http://jpad.io/example/1y/test-different-output

Re:Why I love Common Lisp and hate Java (2012) by eismcc on Sunday November 04, 2018 @01:16AM (#18374379)
IMO, it’s a balance of entropy with maintainability. The amount of info I a line of java is likely lower than lisp, so the cognitive load is likely lower and the code reviews of diffs are spread out over more lines. Generally less value per line but more decomposed.
Re:Why I love Common Lisp and hate Java (2012) by TeMPOraL on Sunday November 04, 2018 @04:05AM (#18374969)
Having done both Java and Lisp for years (both professionally), I agree that in general Lisp requires more cognitive effort to read per line, but I disagree about the reason.

Cognitive load vs. verbosity can be visualized with something like Laffer curve - sure it's easier to read a couple lines of Lisp than one line of APL, but when you get into situations like one line of Lisp (or Python) gets expanded into 30 lines of Java, then the former is much easier. Terse languages make you pay cognitive cost for unpacking meaning, verbose languages make you pay for keeping track of what all these lines of code are doing. Ever had this situation when you read two pages of a book and realized you didn't really read anything, and have to re-read it (and 3 pages prior) to understand what's the point? That's Java in a nutshell, especially pre-1.8.

As for Lisp and cognitive load, the difficulty comes from a) dynamic typing, and b) macros. The former makes bad naming choices much more painful, as you can easily lose track of what's the code doing, and to what data. The latter are fine when written well, when written badly, your problem suddenly explodes in complexity as you have to peel off a layer of syntactic abstraction, and fix the underlying mechanism.

Re:Why I love Common Lisp and hate Java (2012) by LoSboccacc on Sunday November 04, 2018 @07:00AM (#18375460)
And all the verbosity disadvantage almost goes away anyway once you get outside default functions and stop using globals