News for hackers. Stuff that matters.
Re:Why Java? Tales from a Python Convert by pka on Tuesday December 08, 2015 @05:01PM (#10699920)
> Java’s type system, while verbose at times, allows you to write code that largely “just works”.

NullPointerException would like to have a word with you about that.

In all seriousness, it feels unreal that people can be that impressed by Java's safety or lambdas. Makes you shudder to think about what they've used before that.

Re:Why Java? Tales from a Python Convert by throwavay_java on Tuesday December 08, 2015 @05:14PM (#10700050)
AttributeError: 'NoneType' object has no attribute

isn't much better.

Java might not be perfect, but it does let you catch a lot of problems at compile time rather than run time, which is a step in the right direction. The alternative (run it and see) gets old fast.

Re:Why Java? Tales from a Python Convert by pka on Tuesday December 08, 2015 @05:25PM (#10700143)
While I agree - this particular alternative is worse - it's not the only alternative. I was talking about more expressive type systems, not less.
Re:Why Java? Tales from a Python Convert by dragonwriter on Tuesday December 08, 2015 @07:33PM (#10700972)
Java provides less of the benefits of static typing than many other statically-typed languages (even than others available on the JVM), at a much higher cost in required ritual invocations made to the type system.

Yes, there is a value in static typing, but that value is minimized when you have a type system that isn't particularly expressive and/or have to make add a lot of redundant code to satisfy a comparatively unsophisticated type checker.

Java may have gotten slightly better since its poor performance in cost:benefit terms when it came to static typing helped launch the surge in popularity of dynamic languages, but its still not a great poster child for the benefits of static typing.

Re:Why Java? Tales from a Python Convert by dozzie on Wednesday December 09, 2015 @06:27AM (#10703070)
> Java provides less of the benefits of static typing than many other statically-typed languages

Don't let Java's type declarations fool you into thinking that Java is statically typed. It's still dynamic typing, with merely some kind of type hints slapped on top to be checked at compile time.

Re:Why Java? Tales from a Python Convert by codingbinary on Tuesday December 08, 2015 @10:49PM (#10701788)
And don't forget Java's type erasure. Still wondering how they could actually call that a FEATURE.
Re:Why Java? Tales from a Python Convert by potatosareok2 on Wednesday December 09, 2015 @12:34AM (#10702096)
Was erasure necessary to maintain backwards compatibility?

Also what are you doing that you need type information at runtime?

Re:Why Java? Tales from a Python Convert by codingbinary on Wednesday December 09, 2015 @05:16PM (#10707170)
Type Erasure is the reason you can't use builtin types as generic arguments. And in a lot of cases it forces you to cast.

And as type erasure happens very, very early in the compilation process, you lose a lot of static type information the compiler could act on or give you warnings.

Re:Why Java? Tales from a Python Convert by dmm on Wednesday December 09, 2015 @06:53AM (#10703125)
No it wasn't necessary to maintain backwards compatibility. Type erasure was implemented to allow libraries to upgrade to generics without breaking compatibility with existing applications.
Re:Why Java? Tales from a Python Convert by wtetzner on Wednesday December 09, 2015 @11:14AM (#10704504)
How is that not backwards compatibility?
Re:Why Java? Tales from a Python Convert by codingbinary on Wednesday December 09, 2015 @05:16PM (#10707172)
The one is on a language level, the other on an application/framework level.
Re:Why Java? Tales from a Python Convert by IshKebab on Tuesday December 08, 2015 @05:14PM (#10700048)
Python. Says it in the title.
Re:Why Java? Tales from a Python Convert by angryasian on Tuesday December 08, 2015 @05:17PM (#10700078)
Now with Optional in Java 8 its not an issue.
Re:Why Java? Tales from a Python Convert by alexkindel on Tuesday December 08, 2015 @05:41PM (#10700257)
Optional is great, but it would be far more powerful if types not wrapped in Optional were guaranteed to not be null.
Re:Why Java? Tales from a Python Convert by TheCoelacanth on Wednesday December 09, 2015 @12:54PM (#10705339)
And if Optional values themselves were guaranteed not to be null.
Re:Why Java? Tales from a Python Convert by wtetzner on Wednesday December 09, 2015 @11:16AM (#10704515)
It's still an issue, because as far as the type system is concerned, every reference type can still be null.

Optional gives you a way to avoid using nulls, but null is still in the language and libraries still use it.