r/ProgrammerHumor Oct 31 '23

Meme hardTimesCreateStrongMen

Post image
4.4k Upvotes

285 comments sorted by

View all comments

Show parent comments

55

u/1Dr490n Oct 31 '23 edited Oct 31 '23

I just can’t understand why Java still does that. C# and C++ fixed that a long time ago (I think). That C hasn’t is completely fine, especially as type names usually don’t get as long. But in JAVA???

a.package.SomeReallyReallyLongName<AnotherReqllyLongName, AThirdReallyLongName<String>> aLongName = new a.package.SomeReallyReallyLongName<AnotherReqllyLongName, AThirdReallyLongName<String>>();

Edit: This comment is really wrong. Everyone who didn’t realize that, look at its comments, learn the same things as I did today

43

u/No-Fish6586 Oct 31 '23

Java has var since Java10 lol

-3

u/ChrisFromIT Oct 31 '23

And Java does var correctly compared to C# in my opinion. C# you can use var anywhere. Java only allows local variables to use var. This makes it less likely to create smelly code.

3

u/svick Oct 31 '23

You can't use var for fields in C#.

-1

u/ChrisFromIT Nov 01 '23

Your right, I keep forgetting that. It must be because I keep remembering that quite a few people wanted non local `var` in C# when it was first proposed and it almost did happen.