News for hackers. Stuff that matters.
Re:The Java type system is broken by monocasa on Thursday July 19, 2018 @11:09AM (#17567009)
Unlike Java, Go doesn't have to worry about bytecode backwards compatibility. That was the main issue that had them reaching for type erasure.

Take a look at C# which added it without many issues (because they were willing to break back compat of their bytecode). Go fits this model a whole lot better.

Re:The Java type system is broken by pjmlp on Thursday July 19, 2018 @11:52AM (#17567447)
The missing part every time this story gets told, is that Microsoft already had a generics implementation ongoing being lead by Don Syme of F# fame.

They just decided to release 1.0 without generics, instead of waiting for it to be 100% ready.

As Don clearly describes on his blog.

Re:The Java type system is broken by monocasa on Thursday July 19, 2018 @11:58AM (#17567506)
Sure, totally.

In fact, I'm a big fan of how Microsoft does versioning, supporting previous versions, but releasing major versions with backwards incompatible changes. You see this in DirectX, and IMO, that's why we're talking about DirectX and Vulkan, rather than AZDO OpenGL these days. It really gives you an opportunity to clean up the cruft.

Re:The Java type system is broken by pjmlp on Thursday July 19, 2018 @01:05PM (#17568350)
Yeah, although I think they missed an opportunity to move beyond "only C goes" mindset at Khronos.
Re:The Java type system is broken by majewsky on Thursday July 19, 2018 @03:32PM (#17569547)
Is there any language besides C that's not a complete pita to generate FFI bindings for?
Re:The Java type system is broken by pjmlp on Thursday July 19, 2018 @04:51PM (#17570154)
There are many ways to define APIs, we don't need to struggle ourselves only to C.

Metal uses Objective-C/Swift, with shaders in C++14. The Objective-C runtime can be used as FFI.

DirectX, uses COM with HLSL (a C++ subset). Likewise any COM or .NET (via RCW) aware language can talk to it.

One of the reasons OpenCL lost to CUDA was being stuck with C, while CUDA offered C, C++, Fortran and any additional language that could target PTX.

Which was what eventually made them come up with SPIR and later SPIR-V.

NVN and LibCGNM are also based on C++ and C++ inspired shader languages.

All modern OO, with nice SDKs that handle font, texture, materials, maths, GPGPU debugging.

Re:The Java type system is broken by bunderbunder on Thursday July 19, 2018 @04:40PM (#17570060)
fortran?
Re:The Java type system is broken by alexeiz on Thursday July 19, 2018 @01:19PM (#17568472)
> Take a look at C# which added it without many issues

I wouldn't say "without many issues." It took a major surgery in the CLR codebase to add generics. The difference between CLR 1.1 without generics and CLR 2.0 with generics was huge. No area of code was untouched.

Re:The Java type system is broken by mcculley on Thursday July 26, 2018 @05:19AM (#17616112)
Go doesn’t have an ABI? Does every library ship only as source code? I didn’t know that.

I was thinking of more fundamental changes to Java idiom and the standard library had generics been part of the design (e.g., how arrays work).

Re:The Java type system is broken by enitihas on Thursday July 19, 2018 @11:17AM (#17567102)
Did C# really break backwards compatibility of their bytecode? What I understand is that C# generic and non generic APIs are completely different, and are not inter operable.
Re:The Java type system is broken by bunderbunder on Thursday July 19, 2018 @12:47PM (#17568099)
To the first - yes, the version of .NET that introduced generics broke bytecode backward compatibility. Stuff compiled for .NET 1.0 will not run on the CLR for 2.0 and later. In practice, this wasn't a big deal; maintainers just shipped two different versions of their packages, and you'd download the one you wanted.

To the 2nd - The concrete types are separate, but they fit into a common interface hierarchy, so, at a source code level, they're plenty interoperable. For example, the (non-generic) IEnumerable interface has a Cast<T>() extension method that will convert it to a (generic) IEnumerable<T>. IEnumerable<T>, for its part, simply inherits IEnumerable.

In general, I actually like using those conversion methods for downcasting, because it gives a clearer indication of when I'm in a danger zone - for example, converting a non-generic list to a generic list might fail if the non-generic list contains a mix of different types of object. Java's situation feels less predictable to me, as this article illustrates fairly well. A few keystrokes for the sake of safer code is a dandy tradeoff in my book.

Re:The Java type system is broken by teh_klev on Thursday July 19, 2018 @04:29PM (#17569963)
> Stuff compiled for .NET 1.0 will not run on the CLR for 2.0 and later

That's not true. (Mass shared hoster kinda guy here) when we pushed a bunch of customers code compiled for .NET 1.0/1.1 over to hosting environments with only CLR 2 available, their code ran just fine. These were .NET 1.0/1.1 assemblies.

There are some edge cases where stuff could break, say when doing reflection or emitting your own IL, but that for most LOB web hosted apps was pretty rare.

I did in fact marvel how backwards compatible CLR 2 was when it first shipped.

Re:The Java type system is broken by mohaine on Thursday July 19, 2018 @11:42AM (#17567348)
Not sure on the first part but the second part is true.

When there is a C# class that both has and doesn't have type information, they are actually completely different classes that just happen to share a base name.

This really made it painful when they first added generics. If you used generic containers but wanted to call into a library that predated it you hand to transform your data in/out of all the calls to the library. In Java land you didn't have to do anything other then a blind cast on the out side which doesn't even have a runtime penalty.

Long term the C# way was probably better but then they didn't have nearly as robust of a library ecosystem when they added generics.

Re:The Java type system is broken by kjeetgill on Thursday July 19, 2018 @11:31AM (#17567232)
Yea from the wording I think they mean you can either break backwards compatibility or "fork the world".

In Java's case, old bytecode using Map would correctly work with change to Map <K, V>. C# introduced a new set of collections I believe.

Re:The Java type system is broken by monocasa on Thursday July 19, 2018 @11:54AM (#17567470)
Yeah, IIRC they added the "constrainted." instruction prefix. It's a prefix to the callvirt instruction that constrains the the underlying call to the specified type, allowing runtime generic type decisions/exceptions rather than only compile time decisions like Java.
Re:The Java type system is broken by mnd999 on Thursday July 19, 2018 @03:19PM (#17569450)
Except they didn’t - they introduced annotations at the same time and bumped the class file version for that.
Re:The Java type system is broken by jeremyjh on Thursday July 19, 2018 @07:08PM (#17571142)
Changing the class file doesn't necessarily break backwards compatibility. Are you saying a 1.4 JVM couldn't run 1.3 bytecode?
Re:The Java type system is broken by pron on Thursday July 19, 2018 @12:37PM (#17567989)
> added it without many issues

Except for the fact that all CLR languages must adopt the same variance model, enforced by the runtime (or choose not to interoperate well).

Re:The Java type system is broken by monocasa on Thursday July 19, 2018 @12:42PM (#17568053)
Sure, but in context Go doesn't have that issue. Go's compiler only supports Go in a more or less statically linked binary.
Re:The Java type system is broken by pron on Friday July 20, 2018 @01:45PM (#17577192)
Go doesn't have this issue because there aren't other languages running on that runtime. If there were (and you wanted an interop of those languages with Go so that you could use Go libraries), then you'd have this issue regardless of the fact that the runtime is linked with the image.