8 ms·
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 co
by rococode 8y ago
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.
- sidlls 8y agoThe 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.
- jimmyspice 8y agoWell 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.
- polityagent 8y agoor you can use a language with macros, then a testing library can report the code being evaluated and the values in it.
- sidlls 8y agoEven Java has testing libraries that provide optional failure case messages with asserts to provide specific context where necessary.
- saagarjha 8y agoSwift is statically typed and a “Hello, World!” in Swift is just print(“Hello, World!”).
- sanderjd 8y agoSo 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")?
- saagarjha 8y agoAnywhere 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.
- deleted 8y ago[deleted]
- nayuki 8y agoI 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.
- ilovecaching 8y agoMost 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.
- omaranto 8y ago> 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.
- jose_zap 8y agoI often copy paste the inferred type to top level declarations, so I’m a sense it is true
- FranzFerdiNaN 8y agoTypes 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.
- ilovecaching 8y agoJava 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.
- goatlover 8y agoCan't you get all the same advantages of Java with less verbosity in languages like Go, Swift, Rust or Haskell?
- Redoubts 8y ago> 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).