3 ms·
> How confused can one person be? IMO this sentence is completely unnecessary. > Unlike in Java, which offers practically nothing else to organize a program,
by skinkestek 6y ago
> How confused can one person be?
IMO this sentence is completely unnecessary.
> Unlike in Java, which offers practically nothing else to organize a program, in C++ inheritance is wholly optional, and is typically used only where it solves a specific problem.
As someone with extensive experience in both Java and a number of other languages (before and after learning Java) this just isn't true.
It detracts from your point for everyone who knows Java and it adds unnecessary anxiety for people who will learn Java in the future if they belive this.
Java has flaws, but inheritance is not the only way to compose Java programs.
Edit: As a general rule I'd suggest everyone stop pretending Java is generally bad until they have some actual experience from real world systems in Java and a couple of other languages under their belt.
- sideshowb 6y agoBeen a while since I used java but is it still the case that your main function has to be inside a class which has to inherit, ultimately, from Object? I think that's what gp meant in implying that inheritance is not optional. In practical terms of course a bit of boilerplate to declare a class where none was needed, doesn't matter a great deal.
- skinkestek 6y ago> but is it still the case that your main function has to be inside a class which has to inherit, ultimately, from Object? I think that's what gp meant in implying that inheritance is not optional. This is correct but not what GP wrote. What GP wrote is: > Unlike in Java, which offers practically nothing else [than inheritance] to organize a program, To point out why GP is wrong: - In Java you can organize files by packages - by purpose (different folders for test vs production code), - you can use composition to combine classes (in fact this is the recommended way these days) - etc I normally don't care about language wars but I think it is OK to point out when someone writes something that is clearly wrong.
- johnnycerberus 6y agoAlso, you can further organize your packages into Java modules (Java >=9). I don't know why people say that you can't use composition in Java or that it is unique to purely functional languages. You can achieve composition by using Streams, decorator, composite and chain of responsability patterns.