Java has a culture of fully drinking the OOP coolaid. It also has a lot of outdated stuff in the language, this is made worse by a lot of places using outdated versions.
Using Java's more recent versions and using OOP as a tool in your toolbox, rather than the end-all be-all, Java becomes a completely fine and portable language with mature tooling.
Java to me is completely unremarkable. Not too fast, not too slow, no novel concepts. Just a language with generics, OOP and a garbage collector.
Using Java's more recent versions and using OOP as a tool in your toolbox, rather than the end-all be-all, Java becomes a completely fine and portable language with mature tooling
This, right here, is how I use the language. I think that regardless of how you feel about OOP as a whole you probably hate inheritance when it's used too much. Definitely the tool added by OOP that should be used sparingly.
OOP has the side effect that the IDE knows the structure of the app and can refactor it every which way. Whereas on the other end of the spectrum, with the dynamic nature of JS and Python the IDE can't be sure whether the objects' structure is modified at runtime and thus what's referenced by any identifier.
P.S. JavaScript coders have the habit of saying that IDEs are unnecessary, which is probably because they never saw the extent to which the IDE knows about a non-dynamic language.
Maybe Javascript is a bad comparison, but I don't see that as any worse than JS passing a couple dozen parameters through multiple files which I'm seeing regularly these days. Huge pain in the butt when I'm trying to find where something is actually managed or used. Maybe my company just has bad JS code though.
They may be inside. But you can write JS and Python without ever bothering with organizing code into OOP, whereas you can't with Java. That's what matters for the IDE.
Also, JS objects are more of glorified maps that have some conventions for handling calling of methods — same way as with Lua tables.
It's not the tables in Lua or plain objects in JS that makes them OO. It's the meta tables (Lua) and the prototype fields (JS) that enables their OO capabilities.
Also modern JS is full blown OO:
Say you write a React application, then your functional components are objects that apply props (objects) into an object tree (VDOM = virtual document object model) which then gets applied to another object tree (DOM...). It's OO all the way down.
Or if you use async/await, you are essentially wrapping your function (= object) into a promise (= object).
Or if you encoding a JSON string (stringify) then methods are called on your object that you can overrwrite.
Try this:
function Foo() {}
Foo.prototype.toJSON = () => "frobniz";
foo = new Foo();
JSON.stringify(foo);
The "class" keyword is not required for something to be OO. In fact in JS it's just syntactic sugar for prototypal inheritance.
Again, none of this helps the IDE in any way, because to be sure of objects' structure, it would have to evaluate the prototype fields, and it can't do that. It can only have a bunch of heuristics that make the best-effort guess. The code can mess that up at any time, even with classes.
OOP as it was defined in Simula and then C++, relying on classes first of all, mapped really well on static analysis of code. JS pretty much drops back to ‘Lisp with objects’ (or maybe Smalltalk without message passing), constructing the code in runtime. It's not the OOP that became established in the eighties-nineties, and it doesn't work with the same kinds of tooling.
OOP as it was defined in Simula and then C++, relying on classes first of all, mapped really well on static analysis of code.
Static typing and OO are orthogonal. You don't need classes and associated methods for what you describe (see C, Go, Zig, Rust...).
So really what we're talking about here is static vs dynamic languages and not about OO.
JS pretty much drops back to ‘Lisp with objects’ (or maybe Smalltalk without message passing), constructing the code in runtime. It's not the OOP that became established in the eighties-nineties, and it doesn't work with the same kinds of tooling.
The way you should be programming with those languages is by writing in it while it's running (smalltalk/lisp etc.).
In that case when you write foo. your editor will directly suggest methods/fields that are actually there at runtime in that moment. Similarly in Lisp you evaluate and run code piecemeal.
You then don't just now the possible shape of your data, but the actual one (like in a debugger).
That's sort of the main point of using a dynamic language: Extremely fast and granular feedback loops.
In theory at least... The JS ecosystem and certain features have made this style of programming difficult due to the terribly designed es6 module system and some other features. So you need complicated tooling (hot reload etc.) to get not even half-way where it should be...
No wonder that people introduce even more complex (and leaky) stuff like TypeScript. We don't have the instant feedback of an attached REPL, so there's a stronger need for static typing.
With all that said, I agree with your main point.
JS kind of sucks, because it has the downsides of being a dynamic language but only parts of the upsides.
I think your point about it being sorta a middle of the road language is why it's so popular. I mean, it being one of the earlier "run anywhere" languages was huge, but Java also hasn't changed that much since its inception. We've got new features but they use the ugly java verbose syntax, making it feel like it's not as modern as it is.
I didn't realize people didn’t like oop. This explains why js libraries are so weird then. They'll do anything to avoid creating a contained, portable model with packaged functions. It's like no one really even paid attention in college or just went to 6 month programs where they tell you mvc is god and must not be questioned, even though no framework follows it completely.
OOP is a tool that basically gives you infinite opportunity to abstract. This is not healthy for all situations. It can abstract into the "wrong direction".
As a data oriented design enjoyer, I'm more fond of the ECS pattern, which usually means my classes usually don't do much inheritance, if any, and their methods are just operations on their data, with no other side effects, or simple query methods, who's result only depends on the contained data. This design philosophy allows for encapsulation, but doesn't really need liskov substitution, it also makes managing memory easy, which makes OOP (builtin vtable support) and garbage collection kind of moot points imho.
I'm not claiming this is one-size-fits-all (kind of unwieldy for large, unique, and heterogenous datatypes), but it's a nice and efficient pattern for a lot of cases.
Honestly I think what you are doing here is a better embodiment of oop than the infinite inheritance, and dont even get me going with multiple inheritance. The core concept of oop is creating a cookie cutter that makes as many cookies as you need. Massive inheritance chains just to create a singleton is not even oop in my professional opinion. I'll look more into the ECS pattern although I also agree there is no one size fits all pattern. Sometimes you even create your own for a specific situation (shh don't tell pattern police). OOP is something that should always be in one's toolbox though.
I didn't really go into why ECS works well with this comment. The ECS way to organise code is basically:
My program has a database (or databases), everything is a database entry. A function will query the database and either mutate it, or make a monadic operation (write to file/screen).
Very good for games and simulations, or basically everything with a lot of similar data. Easy to manage memory because every datatype (component) basically has it's own array/vector, and related components are resolved by belonging to the same entity.
There are some good articles from the creators of the flecs ecs library.
It still feels too cemented in its old ways. Just writing a map over an array, basic FP, is made unwieldy because of Java's limitations. Call me crazy but it's been years since I write a proper for loop and that's what Java asks from me.
That said, OOP isn't bad, I think both C# and Ruby are more "modern" versions of OOP that are much more tasteful in their design.
You don't write for loops? I do it even on C#, hell even on Kotlin sometimes when I feel like it is more clear that way. For loop is verbose but if you do something complex it is much more clear than writing forEach or map
406
u/Attileusz Jun 12 '25
Java has a culture of fully drinking the OOP coolaid. It also has a lot of outdated stuff in the language, this is made worse by a lot of places using outdated versions.
Using Java's more recent versions and using OOP as a tool in your toolbox, rather than the end-all be-all, Java becomes a completely fine and portable language with mature tooling.
Java to me is completely unremarkable. Not too fast, not too slow, no novel concepts. Just a language with generics, OOP and a garbage collector.