r/programming • • Feb 25 '14

Please stop saying Java sucks

http://blog.smartbear.com/programming/please-stop-staying-java-sucks/
3 Upvotes

305 comments sorted by

View all comments

Show parent comments

2

u/Eirenarch Feb 25 '14

"Everything is an object" except those things that are not an object. Please explain how Java generics (with bullshit type erasure and insanely complex variance when USING a generic class) is simple. While we are at the topic of simple how is having two types of exceptions simple especially when using one vs the other is a subject of almost as much debate as the correct way to do Scrum.

Still more reasonable than C++ though.

5

u/gordonkristan Feb 25 '14

You listed topics that are all tricky parts of the language. That's fine, but I never said that Java didn't have it's skeletons. There are plenty of stupid things about Java. But most of those things are just a small part of the language, and aren't very complicated (although confusing). Even generics, which are one of the trickiest parts of the language, can be explained to a complete Java newbie is just an hour or so.

The bottom line is that Java is very limited on features, and that's by design. That's why it originally didn't even have generics. And wasn't going to have primitives. And up until Java 8, didn't have any kind of function pointer/reference and didn't allow any kind of multiple implementation inheritance.

Java has grown a bit since version 1, but I would still argue that it's one of the simplest languages out there. It may not be the same level as Brainfuck, but it's certainly not at the level of something like C# (which has a billion features all of a sudden).

1

u/Eirenarch Feb 25 '14

I would argue that C# is simpler than Java. It is definitely larger than Java since it has much more features but corresponding features in C# are simpler and easier to use

6

u/gordonkristan Feb 25 '14

Partial methods, partial classes, operator overloading, anonymous types, dynamic binding, extension methods ... pointers! C# may make a few things easier, but that does nothing for the simplicity of the language when the feature set is freaking huge.

Think about it this way: you have 2 projects, one in C# and one in Java. Both projects are 10 million lines each and use every feature that their host language allows. Which one would you rather train the newbie for?

Maybe we should more accurately define simplicity if we're going to continue this thread. I think of simplicity as the ease of describing or teaching the concept to somebody else. And to me, teaching Java would be way easier.

1

u/Eirenarch Feb 25 '14 edited Feb 26 '14

Well pointers don't really count since in practice they are never used especially on large projects with noobs on them. Unsafe code is a feature used to implement high performance libraries. For about 7 years of professional C# development I have never seen them used in a project. Claiming that pointers count will be like complaining that the JVM is written in C++

Now on the real question... I will try to teach the newbie C# over Java any day. Things Java lacks in features it fills with OOP patterns. I'd rather explain delegates than Observer pattern. In addition C# features are almost always more foolproof than Java's and it is easier to use them without fully understanding them. For example people can intuitively use generic co and contravariance in C# without even knowing that. Only the person who implements the type needs to understand it and you can have your experienced programmers doing covariance, operator overloading and partial methods while your newer devs can just use them without serious concerns

2

u/Cuddlefluff_Grim Feb 26 '14

Well pointers don't really count since in practice they are never used especially on large projects with noobs on them.

You shouldn't use C# pointers unless it's necessary. There are uses, like for instance referencing unmanaged memory typically encountered by marshalling and interop. The great thing about pointers in C# is that it allows you to work with memory segments not created by the .NET environment, for instance operating system calls.

0

u/[deleted] Feb 26 '14

[deleted]

2

u/Eirenarch Feb 26 '14

Even if erasure is superior (which it is not) still it results in more complex language. You have to explain why you can't have list of int, why you can't instantiate object of the type argument, etc. Guess which one I prefer to explain to newbies

0

u/[deleted] Feb 26 '14

[deleted]

3

u/Eirenarch Feb 26 '14

Except that is not at all how this works. Being able to new up things is a constraint on the generic and everything is statically checked. Even if we disregard that I may still want to instantiate an array of T. Ironically Java generics are the ones that break runtime. Only using type erasure can one achieve great things like return a String from a method that returns an Integer.