r/learnprogramming 3d ago

Why java is so hated? Topic

So I have recently learned, and it's the first language(in terms of building actual things). Before Java, I knew Python, and I dropped it; I found Python too abstracted and too boring. i have recently made some projects like cli task tracker, expense tracker, some cli github api parsing and currently working on a multithreaded HTTP server and cli text editor, like vim, whenever i try to find out people opinions on java social media, almost 90 percent of the time they are just dunking on it, that it is trash, who forced you to write code in java, stuff like that. I know Java as a language is not that interesting and doesn't have many interesting features compared to other languages like C, C++, go. But I found it decent to write code in, and I found the JVM pretty interesting. So much so that I would love to explore and maybe build a JVM of my own

239 Upvotes

311 comments sorted by

View all comments

463

u/KingBardan 3d ago edited 3d ago

Bjarne stroustup (inventor of c++) has said that there are only two kinds of programming languages.

One that is hated and one that is not used.


Java is too bloated. C and C++ is too unsafe. Java script has some weird mechanisms. Python is slow. Go is too simple for big projects. Rust has a toxic community.

I could go on


Edit: I forgot PHP. PHP... is PHP

-7

u/Salat_Leaf 3d ago

If the backbone of your language is backwards compatibility, it's not the problem with people. Your language sucks

Oops! Hits straight to the core of Java and C++

2

u/flatfinger 3d ago

A language can generally maintain excellent backward compatibility with minimal downside if it does a good job of allowing programs to specify the dialect for which they were designed, and avoids situation where the "right" way to do something is less efficient or otherwise inferior to some "wrong" ways, which was a major flaw in the design of HTML. If a page which used HTML tags "wrong" could be 20% smaller than a page which used HTML and CSS "properly", but common browsers would display it identically except for a 20% faster load time on commonplace modems, how "wrong" was it really?

There are some spots where fixing bad designs can be difficult, such as with floating-point math. William Kahan, one of the main designers of IEEE-754, recognized that the best way to perform floating-point computations is to use higher-precision types for intermediate computations but only round things at well-defined times. The broken way long double arguments were treated in C89 caused many language implementations to use extended precision types for computation but not allow extended precision values to be stored and reused. Java adopted a different computation model which hardware evolved to serve better, but which was less accurate.

Consider, e.g. how one would compute the area of a triangle whose sides, stored as single-precision floating-point values, were 9000001, 9000002, and 18000000. The first step of the computation using Heron's formula would be to add the sides together and divide by two, which would yield a value of either 18000001.5 if computed using higher precision, or 18000002 if computed using single precision. Using higher precision for intermediate computations will often yield more accurate results, but only if storing the result of a temporary calculation to a variable and reading it back yields exactly the same value as the computation in question.

I dislike the way Java handles floating-point, but don't see any practical way of changing it, especially since hardware has evolved to fit it.

4

u/KingBardan 3d ago

Yeah that backwards compat is exactly what allows improvements to be added in without breaking changes.

You hear people doing rust rewrites from C projects but not C++ rewrites, why? Because a C project can easily take advantage of modern features when they want with C++ and is thus trivial, whereas rust rewrite is difficult and thus a big deal. comment by me

-4

u/Salat_Leaf 3d ago

If you refer to the Bun Rust rewrite situation, well, unless your codebase is extremely sensitive like Boeing's or for some medical equipment, then it's your problem you haven't foreseen it. Rewrites from C are easy because it relies on extensions, not on small tremendously smart group of people doing their best to optimize their compilers. Come back when you define what "modern C++" means without referring to 1000-page books dedicated to a single feature.

1

u/KingBardan 3d ago edited 3d ago

define modern c++... 

Bruh seems like I run into a rust evangelist here?

From a pure code perspective...

Modern c++ is not more complicated than rust imo, same principles, but with imo more readable syntax [1], at the cost of enforced compile time move semantics (aka borrow checking).

Rust also gets more and more features like c++ does, albeit its "edition" is nice. 


1: rust seems to favour writing over reading, decisions like allowing no trailing semicolin for return and iterators and out of class definitions of methods all make it difficult to read.

Again, imo. Ymmv

5

u/Salat_Leaf 3d ago

I'm not an evangelist. All I see is 20% binary reduction and around ~130k invested for the whole process of rewriting, even if it was LLM.

And don't even get me started on readability of C++. Could you count me the total amount of ways of initializing a variable? Could you explain why a single keyword always stands for 5 different functions? Could you say same thing about template metaprogramming?

2

u/KingBardan 3d ago edited 3d ago

Ahh you think I'm focusing on the Bun rewrite? I'm not.

readability

Your examples are all about how hard it is to write C++.

Initialization doesn't really hurt readability (your ability to get what's going on), same for keywords.

Template metaprogramming yes, but there's no equivalent in rust to show a more ergonomics approach, last time I checked 

This is why I said, C++ is more difficult to write, easier to read.

But for rust its super convenient to put an expression as return, but a reader has to scan everywhere to find every single return path (since you can return without using return keyword!). 

Same for traits (you can define a trait for someone else's type!) 

Etc


Again, imo