5 ms·
Is that really a "quirk" of specifically Go? I am pretty sure Java--the implementation of which defined a lot of how numerous languages handle this kind of thin
by saurik 2y ago
Is that really a "quirk" of specifically Go? I am pretty sure Java--the implementation of which defined a lot of how numerous languages handle this kind of thing--has the same behavior: you can cast String[] to Object, but not Object[].
- kgeist 2y agoC# allows casting string[] to object[], but this requires the compiler to insert runtime type checks each time the array elements are modified: object[] array = new string[10]; // throws a run-time exception array[0] = 10;
- neonsunset 2y agoNote that array covariance is largely considered a design mistake and if .NET was to be redone it wouldn't have one (and a bunch of smaller things that are an artifact of generics getting introduced in C# 2.0 and not 1.0, well, the problem is much worse in Go heh). Other data structures like List<T>, Span<T>, etc. do away with covariance. There's an upcast for ReadOnlySpan<T> but only because it's zero-cost and does not introduce the issues stemming from covariance. Luckily, you almost never see someone use array covariance beyond occasional object[] upcasts (and the compiler is also good at reasoning whether to insert covariance checks or not).
- pjmlp 2y agoWell, .NET only exists in first place because of Sun's lawsuit, Ext-VOS was designed with J++ in mind. Thus having high compatibility with how Java used to be was a big factor designing C# 1.00
- neonsunset 2y ago25 years ago :)
- pjmlp 2y agoYes, and 25 years later Java is still relevant enough that Microsoft has become yet again a Java vendor, with their own distribution, made the key contribution for Windows ARM support, VSCode Java experience is still ahead of C# DevKit thanks collaboration with Red-Hat, and doesn't require an additional licence. At the same time, JVM has embraced the polyglot ecosystem CLR was supposed to be, while C# seems to have sucked the life of all those language implementations demoed at the launch back in 2001, and .NET SDK being offered on computer magazine CDs. Which is kind of interesting, how things have changed 25 years later. At least we finally have cross platform support (ignoring Mono and DotGNU efforts), and good AOT instead of NGEN, which should have been there on .NET 1.0.
- neonsunset 2y agoIf you have to reach for popularity as an argument in favour of technology X or platform Y, perhaps it's not a technical point you want to make? > VSCode Java experience is still ahead of C# DevKit thanks collaboration with Red-Hat, and doesn't require an additional licence. I'm not sure if you're intentionally attempting to make inflammatory replies or something in what I said rubbed you the wrong way. (for other readers - this marks me posting for 20th time here that DevKit is an optional product and thousands of developers are happily coding in C# in VS Code and VSCodium, Neovim and Emacs without ever running into it)
- pjmlp 2y agoUnfortunately not always the best technology wins out, and the turns that go around them are nonetheless quite interesting. I am stating facts, do you want links to .NET team interviews where they assert it is a business decision VSCode is never going to achieve feature parity with VS for .NET? VSCode for Java doesn't have such artificial constraint, hence the better tooling, mainly implemented by Red-Hat. C# DevKit being optional doesn't change the fact specific features are only available when users opt into using it, with a corrrespondig Visual Studio license. And yes, this irritates me, because I feel it is a disservice to .NET community how Linux and macOS developers are kind of 2nd class, not by .NET team themselves, but higher up Microsoft management.
- kgeist 2y ago.NET is still called COM+ in .NET's source code, they initially envisioned .NET as a successor to COM. They wrote about COM+ in 1997 in an issue of Microsoft Systems Journal (they talked about GC, runtime type info, etc.) It makes me believe the idea for .NET (COM+) existed before the lawsuit. It's possible that after the lawsuit, the COM+ and J++ teams were merged to reposition it as mainly a Java alternative.
- pjmlp 2y agoThat was the Ext-VOS project, that I made a reference to. WinRT was supposed to replace .NET by the original goals, after the Sinofsky and his followers took over Windows development after Vista, it has been COM as the main API. "Turning to the past to power Windows’ future: An in-depth look at WinRT" https://arstechnica.com/features/2012/10/windows-8-and-winrt-everything-old-is-new-again/ https://arstechnica.com/features/2012/10/windows-8-and-winrt... However as we all know by know, it didn't went down as expected.
- kgeist 2y agoI never heard about "Ext-VOS". Tried googling it, and all mentions of it are from you ("pjmlp"), on Reddit, Github, etc. :) Where can I read more about it?
- pjmlp 2y agoDon Syme from .NET generics and F# fame has written about it, that is how we got made aware of it. Now those blog posts are kind of gone from their original hosts. F# HOPL paper, https://fsharp.org/history/hopl-final/hopl-fsharp.pdf https://fsharp.org/history/hopl-final/hopl-fsharp.pdf Original blog post on way back machine, including the link to "MSR White Paper: Proposed Extensions to COM+ VOS (Draft)" paper. https://web.archive.org/web/20190111203733/https://blogs.msdn.microsoft.com/dsyme/2012/07/05/more-c-net-generics-research-project-history-the-msr-white-paper-from-mid-1999/ https://web.archive.org/web/20190111203733/https://blogs.msd...
- 2y ago
- skitter 2y agoC# inherited this from Java, which added it because it was designed without generics and therefore decided that the additional expressiveness provided by enforced array covariance was worth the tradeoff of having an unsound type system.
- sltkr 2y agoActually in Java you can cast String[] to Object[] although this is technically unsound. This how generic methods like Arrays.sort() are implemented.
- saurik 2y agoHuh, fair enough!! What's then funny in the context of this thread is that, while I am sure I knew that 20-25 years ago, it feels so wrong that it would support that -- and more like a "quirk" that it ever would -- that it surprises me (though it certainly doesn't shock me: most things have many quirks).