I thought this was a stack trace at first, with the fully-qualified package names just being this long.
To be fair, though, if we’re including badly formatted “one-liners”, then a lot of the more functional-style programming languages would need that monitor.
I frequently produce such “lines” in Scala and Rust with the list/iterator operations.
The entire family of the LISPs would also need it.
Definitely would not be of any use in Lisps from my experience. I rarely have lines that have over 100 characters in Clojure. Here’s what typical Lisp code looks like in my experience. :)
I was trying to say that it would be of use, if you remove all the newlines from what can be a one-liner (as that Java code example seems to have done).
So, e.g. in that file you linked, line 49. That semantically ends in line 64. So, if you removed all the newlines in between, you could make that a one-liner with 346 characters in one line.
I find vertical alignment actually helps semantically break up code and makes it more readable. If lines 49 through 64 were a single line it would be much harder to read.
Nesting, and indentation makes it possible to scan the code quickly. One really nice thing about s-expressions is that your code is basically a diagram showing relationships within it visually. By looking at the nesting you can quickly tell which pieces of code are related.
I’m saying the Java code in the screenshot is horribly formatted.
Rather than being written like this:
something.doX().doY().doZ();
…it should be written like this:
something
.doX()
.doY()
.doZ();
And I’m saying that if we’re taking horribly formatted code into account, then LISP languages would also be able to produce incredibly long lines of code, but obviously no one does that.
Java code in the example might be particularly horrible, but I’ve certainly dealt with a lot of code that looks very much like that in Java during my career. Also, the problem isn’t just with formatting, it’s the fact that Java code has very low information to noise ratio. It takes an inordinate amount of code to solve simple problems in Java, and that adds a lot of mental overhead for the developer. A lot of the code is completely incidental to the problem being solved, and it’s just boilerplate resulting from mapping your problem domain to the available constructs. Java is not a terribly expressive language. It’s certainly come a long way recently with stuff like streams and lambda sugar for anonymous classes, but it’s still results in an inordinate amount of incidental code.
It’s not like I like Java. It tries to keep the number of language concepts extremely low, with the goal of enabling quick on-boarding for new team members.
And, in my opinion, that is extremely pointless. Learning new libraries and frameworks is daily business as a software engineer. So, learning the syntax and std library of your programming language is a very small overhead.
I just feel like Java gets more shit than it deserves.
For example, I think that it’s a much better beginner’s language than Python, because it has less concepts, better error messages and better tooling. Having to memorize publicstaticvoidmain(String[] args) isn’t optimal, but certainly doable by even the biggest dumbass.
Yet, for whatever reason, Python is all the hype.
I definitely don’t think Java is the worst language out there, and agree that it’s preferable to Python. I also think that JVM as a platform is absolutely incredible piece of engineering.
No idiomatic use of Rust (or Java) would yield this code. In any case, in both Java and Rust whitespace doesn’t matter so you can make those lines shorter even when writing functional-style code.
I thought this was a stack trace at first, with the fully-qualified package names just being this long.
To be fair, though, if we’re including badly formatted “one-liners”, then a lot of the more functional-style programming languages would need that monitor.
I frequently produce such “lines” in Scala and Rust with the list/iterator operations.
The entire family of the LISPs would also need it.
Definitely would not be of any use in Lisps from my experience. I rarely have lines that have over 100 characters in Clojure. Here’s what typical Lisp code looks like in my experience. :)
I was trying to say that it would be of use, if you remove all the newlines from what can be a one-liner (as that Java code example seems to have done).
So, e.g. in that file you linked, line 49. That semantically ends in line 64. So, if you removed all the newlines in between, you could make that a one-liner with 346 characters in one line.
I find vertical alignment actually helps semantically break up code and makes it more readable. If lines 49 through 64 were a single line it would be much harder to read.
Nesting, and indentation makes it possible to scan the code quickly. One really nice thing about s-expressions is that your code is basically a diagram showing relationships within it visually. By looking at the nesting you can quickly tell which pieces of code are related.
You seem to misunderstand me completely. 🙃
I’m saying the Java code in the screenshot is horribly formatted.
Rather than being written like this:
something.doX().doY().doZ();
…it should be written like this:
something .doX() .doY() .doZ();
And I’m saying that if we’re taking horribly formatted code into account, then LISP languages would also be able to produce incredibly long lines of code, but obviously no one does that.
Java code in the example might be particularly horrible, but I’ve certainly dealt with a lot of code that looks very much like that in Java during my career. Also, the problem isn’t just with formatting, it’s the fact that Java code has very low information to noise ratio. It takes an inordinate amount of code to solve simple problems in Java, and that adds a lot of mental overhead for the developer. A lot of the code is completely incidental to the problem being solved, and it’s just boilerplate resulting from mapping your problem domain to the available constructs. Java is not a terribly expressive language. It’s certainly come a long way recently with stuff like streams and lambda sugar for anonymous classes, but it’s still results in an inordinate amount of incidental code.
This study shows just how bad the situation is.
Yeah, I can get agree with that.
It’s not like I like Java. It tries to keep the number of language concepts extremely low, with the goal of enabling quick on-boarding for new team members.
And, in my opinion, that is extremely pointless. Learning new libraries and frameworks is daily business as a software engineer. So, learning the syntax and std library of your programming language is a very small overhead.
I just feel like Java gets more shit than it deserves.
For example, I think that it’s a much better beginner’s language than Python, because it has less concepts, better error messages and better tooling. Having to memorize
public static void main(String[] args)
isn’t optimal, but certainly doable by even the biggest dumbass.Yet, for whatever reason, Python is all the hype.
I definitely don’t think Java is the worst language out there, and agree that it’s preferable to Python. I also think that JVM as a platform is absolutely incredible piece of engineering.
I think they just repeat the same sequence multiple times instead of using variables:
No idiomatic use of Rust (or Java) would yield this code. In any case, in both Java and Rust whitespace doesn’t matter so you can make those lines shorter even when writing functional-style code.
Use method chaining and
rustfmt
.I put those quotes there, because I don’t actually write them into one line. That Java code sample seems to just have done so unnecessarily.
So, while I don’t use rustfmt, I do probably format it the way it would format that.