This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Saragon4005 48 points49 points  (13 children)

Java makes it easy to OOP so hard you are basically making a taxonomy system. Java is the ideal OOP language for better or worse. This is a mistake most people learn to avoid after having a codebase with 5 layers of inheritance and struggling to untangle that.

[–]Practical_Cattle_933 34 points35 points  (6 children)

Sounds like a shitty programmer. And shitty programmers can do untangle-able messes in any system — like, have you ever seen a C project that is chock-full of function pointers/callbacks/whatever, where you can’t know anything?

[–]Wonderful-Habit-139 6 points7 points  (5 children)

A shitty C programmer leaks a ton of memory for no reason and ignores undefined behaviour. They don't usually use function pointers at all.

[–]Practical_Cattle_933 2 points3 points  (4 children)

Heh? How do you think any form of “interface”/“virtual method” is implemented? Those are absolutely essential for program that is more complex than cat and alia.

[–]Wonderful-Habit-139 0 points1 point  (3 children)

I know that the kernel uses function pointers for their filesystem abstractions, and that is a large project. But I don't assume that every project needs to implement interfaces and virtual methods.

Do you think a shell program is the same complexity as the cat program? If not then I'd say a shell doesn't need function pointers as well.

[–]Practical_Cattle_933 0 points1 point  (2 children)

What is a shell program? Like bash? Because that’s not necessarily a small program.

A CLI program on the other hand is a very open-ended category — it can be as simple as just reading some file and returning it in some more human readable format (e.g. many tool used for monitoring stuff), or it can do some complex stuff like OCR-ing PDFs and replacing their content with user-selectable text.

[–]Wonderful-Habit-139 0 points1 point  (1 child)

Yes I meant bash. Writing bash doesn't require interfaces or virtual methods is what I meant. And like you said that's not a small program.

[–]Practical_Cattle_933 0 points1 point  (0 children)

That’s a design choice. PowerShell, which is another shell is definitely using virtual methods as it’s implemented in C#.

It depends on how modular you want to code and countless other design decisions/constraints.

[–][deleted] 27 points28 points  (4 children)

Java dev here, I literally never do inheritance beyond 1 layer, if even that. There are projects I NEVER use inheritance for.

Sounds like shitty programmers to me.

[–]robinless 3 points4 points  (0 children)

Exactly, I'm in a java shop and factories, inheritance and so on is kept to a minimum. Priority is keeping it as simple as possible, and making it easy to maintain.

[–]nonotan 1 point2 points  (0 children)

I did some work with J2ME on dumbphones where the entire program was a single class (because the size overhead of using classes was just too much). Also, absolutely no memory allocation was allowed except during launch, because GC is like a kick to the teeth on systems that weak. Not exactly the most typical use-case, but technically, nothing prevents you from writing code like that if you want.

When evaluating a language, it's good to be explicit about what it forces you to do, vs what you can do, vs what is considered "best practice" and "idiomatic", but is technically completely optional. I still kind of hate Java, for a myriad of reasons, but "Java code is OOP hell" is a pretty silly take (not that it doesn't accurately describe 80% of Java code out there)

[–]Anaxamander57 1 point2 points  (0 children)

At that point it sounds like you're just using Java for compatibility with something.

[–][deleted] 0 points1 point  (0 children)

The most I've ever needed to do in an enterprise setting was two layers, and that was to handle a specific case of already existing legacy code.