News for hackers. Stuff that matters.

Ask HN: Is the Java OO model really broken and does C# provide a better model?

A friend of mine suggested that It would be better if I learn C# rather than Java. According to him, Java's OO model is a little bit. It's better tackled after learning a correct, functional object-oriented language like C#. What do you think? What's the meaning of "broken"? What is the definition of a good OO model?
( 12 comments | 2 points | on HN )
Re:Ask HN: Is the Java OO model really broken and does C# pr... by ayende on Thursday October 28, 2021 @01:55PM (#29028988)
From OO perspective, there really isn't any difference between Java and C#

There are certain features (such as linq, genetics,etc) that I consider C# superior, but OOPness isn't one of them.

That said, for historical reasons, Java has a lot more emphasis on class hierarchies, etc

Re:Ask HN: Is the Java OO model really broken and does C# pr... by dragonwriter on Thursday October 28, 2021 @03:31PM (#29030580)
> From OO perspective, there really isn't any difference between Java and C#

I'd say that properties, reified generics, and extension methods are all highly relevant to statically-typed, class-based OOP, and significant C# vs Java differences.

Re:Ask HN: Is the Java OO model really broken and does C# pr... by Danao on Thursday October 28, 2021 @03:34PM (#29030630)
Are these features (properties, reified generics, extension methods etc.) implemented in C# or in Java?
Re:Ask HN: Is the Java OO model really broken and does C# pr... by dragonwriter on Thursday October 28, 2021 @03:40PM (#29030730)
All three in C#, not Java (Java has properties, but they aren't the same kind of thing as C# properties.)
Re:Ask HN: Is the Java OO model really broken and does C# pr... by theandrewbailey on Thursday October 28, 2021 @02:24PM (#29029423)
If by 'better', your friend means 'newer', then sure, C# is newer than Java. However, OOP hasn't changed much since before either came out; hell, Java went so far into OOP that it can be cringeworthy[0]. C# has a lot of nifty features, but I'm not aware of any OOP area were it's way ahead of Java.

[0] https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...

Re:Ask HN: Is the Java OO model really broken and does C# pr... by policipal on Thursday October 28, 2021 @02:31PM (#29029585)
I would offer that Smalltalk has the most straight forward model of OO. If you want to compare OO models I might compare ST to C# instead.
Re:Ask HN: Is the Java OO model really broken and does C# pr... by Danao on Thursday October 28, 2021 @02:36PM (#29029654)
Why not to compare ST to Java ? What's the "problem" with java?
Re:Ask HN: Is the Java OO model really broken and does C# pr... by policipal on Friday November 05, 2021 @05:15AM (#29116984)
Java and C# simply have a lot of ceremony and features and that's not a bad thing. However, it's easy to miss the forest through the trees. Java is not bad at all nor is C# but there are so many more concepts in Java and C# that are unrelated to OO that it's easy to conflate Language conveniences and features with OO itself. Smalltalk is "stripped down OO". Both C# and Java are one interpretation of OO plus twenty years worth of other things added on top and that's not intended to be a criticism. If you start with a simpler and purer implementation of OO, what is OO, what is decidedly one languages interpretation of OO, and what has been added for other reasons will become more apparent. I've always found that developers who learned ST first were an order of magnitude better Java and C# developers than those who learned either of those first. Good luck with your learnings.
Re:Ask HN: Is the Java OO model really broken and does C# pr... by Danao on Monday November 08, 2021 @02:51PM (#29153431)
Thanks for the explanation ^^. Do you have any resource recommendation to learn Smalltalk?
Re:Ask HN: Is the Java OO model really broken and does C# pr... by policipal on Thursday October 28, 2021 @02:30PM (#29029554)
The simplest (easiest) OO model I would argue is Smalltalk.
Re:Ask HN: Is the Java OO model really broken and does C# pr... by Danao on Thursday October 28, 2021 @03:02PM (#29030151)
How C# compares to ST then?
Re:Ask HN: Is the Java OO model really broken and does C# pr... by policipal on Friday November 05, 2021 @05:13AM (#29116976)
That's a research topic and a few months of study. There is no freebie paragraph that will give you quick cheap answer. You'll need to do your homework to get anything short of a superficial blurb. See my comment above. I think that may help.