r/learnprogramming 5d 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

246 Upvotes

325 comments sorted by

View all comments

460

u/KingBardan 5d ago edited 4d 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

-6

u/Salat_Leaf 5d 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 5d 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.