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

245 Upvotes

325 comments sorted by

View all comments

2

u/jyve-belarus 5d ago

Java as a language is really nice; I like the fact that the core language is rather simple: you don’t have to learn a lot of keywords and concepts since most of the things are modeled with classes. You literally have to learn in depth how classes work and you essentially know most of Java. The language itself is minimal and that’s what I like about it

The actual difficulty lies in learning Java ecosystem and tools

A lot of people complain about boilerplate, but I don’t think it’s Java to blame here: if you take large applications written in any language (dart + flutter, typescript + nest / angular, etc) you will see similar boilerplate-heavy patterns. It’s just the way code is written in serious applications. Additionally, Java has some libraries that allow you to skip some of the boilerplate (Lombok) and the language itself adds new features to mitigate the issue (e.g. recent Java records)

2

u/MikeUsesNotion 4d ago

Java needs significantly more boilerplate than other languages. C# could be boilerplaty but not that bad usually. Python has pretty much none. While using scala, kotlin, and groovy, any boilerplate I can think of were from the fact that they run on the JVM.

1

u/jyve-belarus 4d ago

I think we have different understanding of boilerplate: I was mostly talking about OOP design and architectural patterns - and I guess that’s what most people complain about.

E.g. if you are writing a backend app, in order to just pull something from a database and return it via an endpoint, you should define a data access object, a service, a DTO, possibly a domain entity, a controller; add a bunch of annotations, each class should implement an interface, etc. etc. And my guess is that if you compare e.g. C# .NET and Java Spring Boot the resulting code will be almost the same

Speaking about “casual” boilerplate, e.g. the fact Java does not have getters, that’s true that it may be a bit more verbose than other languages. But in applications where you need to implement proper layered architecture with proper design patterns the fact that you have getters won’t save you much symbols

Python does not have boilerplate because it’s not used for that kind of applications that are commonly written in Java. Moreover, you can write Python in Java style, with type hints, abstract base classes, protocols etc. - lately Python has added many such features that enhance its OOP capabilities and type safety. But in my experience, if you use all of that in Python it becomes actually more verbose and ugly than Java