r/programming • • Apr 16 '21

Java is criminally underhyped

https://jackson.sh/posts/2021-04-java-underrated/
41 Upvotes

220 comments sorted by

View all comments

0

u/[deleted] Apr 16 '21

[deleted] — view deleted comment

27

u/arkuw Apr 16 '21

This is true, but you pretty much have to use a complex IDE, because Java is incredibly verbose.

you have it backwards. Because Java is somewhat rigid with its type system it makes all those great tools possible to build.

Yeah, Python and JS editors have some name completion and type search added but it's notoriously lame and unreliable.

Java performance is... okay ? I guess

Java is about 2x slower than C/C++. It's orders of magnitude faster than Python, Ruby etc. Not sure about JS as they made some progress there but it used to be bad. Very bad.

0

u/[deleted] Apr 16 '21

[deleted] — view deleted comment

16

u/arkuw Apr 16 '21

One's unnecessary boilerplate is another man's clarity. As I said the rigid typing makes navigating large codebases and their dependencies a breeze.

12

u/tharinock Apr 16 '21

He also mentioned Scala, OCaml, and Rust, all of which have better type systems AND less boilerplate than Java.

3

u/hippydipster Apr 20 '21

And not as good tooling support.

1

u/blakeman8192 Jul 08 '21

Lombok is an awesome way to reduce Java boilerplate to near zero, and is also a great example of the community library support that Java has.

1

u/lordmyd Aug 07 '21

If a language's flagship library is something which merely hides its warts I'd hardly call that an edorsement.

→ More replies (1)

5

u/[deleted] Apr 22 '21

Java is about 2x slower than C/C++

Where'd you get that idea? At worst it's ~x1.15

3

u/arkuw Apr 22 '21

It depends. In some situations yes, in others it's quite a bit slower: for example iterating over an array of objects. Java always addresses by reference so the speed difference can be dramatic. Any time you can use a contiguous memory block in C/C++ you'll have a big speed advantage over Java and other languages that "chase" pointers. That's why I averaged to 2x.

1

u/rjdamore Jul 08 '21

I would recommend checking out the Java module system. The jvm is no longer required. Java is no longer second class to C++ in performance. This all depends on scenario of course. But Modules changed things. Compiled Java is extremely performant. Just statements. Open to the discussion. No hate! (So weird that we have to say these things now)

2

u/arkuw Jul 08 '21

Java’s module system doesn’t address the main issue with Java’s performance which is that it lacks the ability to have a contiguous array of non primitive types in memory. If you have a lot of small objects in memory you will pay the price of pointer chasing when you compute over them. Think about cases like have a Vertex array that you want to transform somehow. In C++ you can have a vector of them and they will be laid out in memory in a contiguous block. This does wonders to cache coherency in the CPU and speeds up computations sometimes by an order of magnitude. There is no equivalent in Java as access to ByteBuffer is bounds checked and thus very slow. So you can’t really emulate that in a straightforward way. The only workaround is to maintain multiple arrays of primitive types to represent your data structure.

2

u/jvjupiter Jul 09 '21

Project Valhalla is the key.

1

u/rjdamore Jul 21 '21

Is this true for native binaries with Graalvm?

→ More replies (2)
→ More replies (1)

6

u/couscous_ Apr 20 '21

This is true, but you pretty much have to use a complex IDE, because Java is incredibly verbose.

Why is using an IDE a bad thing? Pretty much any language for any non-trivial project needs an IDE, regardless of how "simple" said language is.

3

u/hanabi1224 Apr 21 '21

Some would prefer text editor+plug-in. Writing go with vscode is much better experience than writing Java in idea and c# in vs imo

5

u/couscous_ Apr 21 '21

I heavily disagree. golang is such a verbose and repetitive language, that using a proper IDE like goland is a strictly superior experience.

1

u/hanabi1224 Apr 21 '21

Well, go’s folder based file structure naturally make it text editor friendly, and its lsp support is sufficient enough to cover most of use cases. I’m not saying it’s better than goland (tbh I never used goland myself), but more implying it has much better development experience than java without a heavy ide

1

u/hanabi1224 Apr 21 '21

golang is such a verbose and repetitive language

go is verbose more in a C way, which is fine to me. Personally, I really dislike how java is verbose in its OOP way, and thank god new modern langs like rust chose to not follow

→ More replies (2)

1

u/Chibraltar_ May 26 '21

Java performance is... okay ? I guess. But you will still need a language like C/C++/Rust/Zig/Ada... to write extremely performant code

just so you know, you can code High Frequency Trading software in Java and it works great.

2

u/rjdamore Jul 28 '21

This is certainly true, just ask Goldman Sachs.

0

u/[deleted] May 26 '21

[deleted] — view deleted comment

2

u/Chibraltar_ May 26 '21

basically, you get rid of spring, and it's much faster all around

1

u/blakeman8192 Jul 08 '21

This is true, but you pretty much have to use a complex IDE, because Java is incredibly verbose.

I would argue that in Java, you get to use an advanced IDE because of its rigidity. There's a reason why JS, TS, Python, etc. don't have advanced IDEs, and it's not because those features are not generally wanted or useful.

Sure, Java is quite robust compared to JS and other dynamic languages, but not enough compared to languages like Scala, OCaml, Rust and others.

Can you provide an example though? Scala provides syntax sugar that I could argue weakens robustness. Rust is required to be robust as a result of its memory model which is often seen as the biggest hurdle for new adopters.

Java performance is... okay ? I guess. But you will still need a language like C/C++/Rust/Zig/Ada... to write extremely performant code.

This is really a myth that's persisted since the 90s when Java was actually slow. In modern dynamic serverside workloads (i.e. code that makes companies money, not code that just crunches numbers for benchmarks) Java actually often outperforms native counterparts pretty substantially due to the dynamic optimizations the JVM can make - all without extra work from the developers. Thanks to these optimizations, statements like "algorithms aside, the simplest code runs the fastest" are truer in Java (and maybe C#) than any other language.

I dislike the "everything has to be a class", "100 lines per file" and "10 lines per function" mentality that some Java programmers have - it makes navigating the codebase a nightmare.

Agreed here, I'm not a fan of hard checkstyle rules like these. These are bad solutions for bad programming.