6 ms·
Oracle went the wrong direction with unsafe. Unsafe memory access is a feature of .NET and the CLR, not a hidden API where you get reprimanded by the community
by sreque 8y ago
Oracle went the wrong direction with unsafe. Unsafe memory access is a feature of .NET and the CLR, not a hidden API where you get reprimanded by the community for using it. Not surprisingly, c# has succeeded where Java has failed in being cross platform, used for instance in game development with the unity engine or multi platform mobile development via xamarin. On the other hand, no one in the .NET community is complaining that their code is segfaulting all the time.
The jdk API developers should not be granted a special API because they are more trustworthy than the rest of us "average" developers. Unsafe should be made public, not removed and replaced.
- jontro 8y agoDid you read the article? The point is that they have done this in java 9 with http://openjdk.java.net/jeps/193 http://openjdk.java.net/jeps/193
- sreque 8y agoI read it, thanks. That wasn't the point of the article at all. Also, Variable handles only represent a small part of what unsafe is used for.
- cogman10 8y agoRight, and they are just one example of unsafe apis moved into the public jdk. Oracle took a fairly measured approach here, they saw what was used and made public apis that are either clones of the private ones or that better capture common usage. That it took so long isn't great, but they are certainly going the right way.
- didibus 8y agoI think OP means, how in C#, you have the unsafe keyword, which restricts unsafe usage to particular unsafe code blocks, and allows any unsafe operation to be contained.
- _asummers 8y agoFrom the HN comment guidelines: > Please don't insinuate that someone hasn't read an article. "Did you even read the article? It mentions that" can be shortened to "The article mentions that."
- didibus 8y agoDoesn't unity just steal the C# syntax, but actually compiles it on its own? Effectively, it's unrelated to the CLR? Same for Xamarin?
- titanix2 8y agoNo and no. I’m no unity expert but I think it is based on Mono, an open source implementation of the CLR and the C# compiler. So it doesn’t "steal" the syntax, it use a compiler made for the language. To put it simply, Mono was (cf infra) the open-JDK of the .net world. Xamarin is a startup founded and run by people working on Mono. In the recent years Microsoft opened its new C# compiler (Roslyn) and bought Xamarin with have blurred the lines between the implementations.
- pjmlp 8y agoKind of, Mono never was up to speed with what .NET Runtime is capable of, plus before Xamarin got acquired by Microsoft, Unity didn't want to renew their licenses so C# on Unity was stuck into .NET 3.5 world. They also started their own native code compiler for C#, called IL2CPP, because it compiles MSIL via C++ compiler. Recently they migrated to .NET 4.6, although the latest version is .NET 4.7.2, due to some Roslyn integration issues. Additionally they started another project to compile a C# subset (HPC#), with a new compiler named Burst, as a means to start porting some of their C++ modules into C#.
- bitmapbrother 8y ago>Not surprisingly, c# has succeeded where Java has failed in being cross platform, used for instance in game development with the unity engine C# succeeded in game development? That's its claim to fame? Being an optional scripting language used by Unity? The real work is done by the graphics engine that's written in C++. >or multi platform mobile development via xamarin Last time I checked the percentage of apps on the App Store and Google Play that were written with Xamarin tools were so low that they barely even registered.
- ivm 8y agoIt's not optional, it's the only language used in Unity by developers since UnityScript got deprecated. At least Google Play has more apps in Xamarin[0] than in ReactNative[1] but RN is used in many top apps while Xamarin apps are mostly obscure. [0]: https://www.appbrain.com/stats/libraries/details/xamarin/xamarin https://www.appbrain.com/stats/libraries/details/xamarin/xam... [1]: https://www.appbrain.com/stats/libraries/details/react_native/react-native https://www.appbrain.com/stats/libraries/details/react_nativ...
- pjmlp 8y agoAnd even more in Java and C++ than those two summed up together.
- mellinoe 8y agoThere are a lot of very successful indie games written in C# (entirely, not just in a scripting layer). It is very popular for game development.
- lawlessone 8y agoand lots more aren't.
- de_watcher 8y agoThe engines nowadays are the problem of the engine developers. There are about 5 to 10 serious ones. The actual game logic is written by the game developers in these "scripting languages". Sometimes the language is C++, but with Unity Engine it's C#.
- pjmlp 8y agoActually one might say Sun was the one that went the wrong way. > "[C# is] sort of Java with reliability, productivity and security deleted." -- Gosling on https://www.cnet.com/news/why-microsofts-c-isnt/ https://www.cnet.com/news/why-microsofts-c-isnt/ Oracle is improving Java native interop with projects Panama, http://openjdk.java.net/projects/panama/ http://openjdk.java.net/projects/panama/ Java has surely not failed in being cross platform, not if we are comparing it with .NET. .NET Core still doesn't run in many environments, where I can gladly put Java on. The computing world is much bigger than just macOS, Windows and GNU/Linux. And then there is the issue that even Swing/JavaFX/SWT are better supported that whatever .NET Core UI framework one can think of. Xamarin is nice and way better than React Native, Cordova or Qt, and yet you aren't going to find much love for it on online forums. On game development C# got lucky with Unity, because finally there was a company that was firm to hold on to managed languages in game development no matter what, and they managed to turn out one of the best engines out there for indies. Had Unity decided to go the way of Unreal with UnrealScript and the story would be quite different. I still remember the JavaGamming initiative at Java ONE, Java3D or the JOGL project, but like many other Sun initiatives, they let it die after a couple of years. Maybe here the story would have been different if they were actually committed to it. Thing is UNIX companies never understood desktop and gaming cultures, so here .NET has notoriously an advantage by having been part of a desktop OS SDK since its inception, from a company that actually understands desktop and gaming cultures.
- earenndil 8y agoC# does have XNA/FNA, plus bindings to qt and gtk.
- pjmlp 8y agoWhat I have written was: > And then there is the issue that even Swing/JavaFX/SWT are better supported that whatever .NET Core UI framework one can think of. Try to use GUI designers and commercial component libraries for Swing/JavaFX/SWT and then try to use GUI designers XNA/FNA, Qt and Gtk+ while using only C# code. I am speaking about production quality GUI tooling with commercial support, not a legacy framework abandoned by Microsoft due to their internal politics, or some bindings written over a couple of weekends that still rely mostly on C++.
- skocznymroczny 8y agoCheck out Project Panama. It's trying to bridge the gap between Java and C# when it comes to native interop, which is the main usecase for 'unsafe' features.
- peterashford 8y agoUnity "proving" C#'s success in games is about as reasonable as saying that Android games in Java proves Java's suitability for games. Its an accident of history that those languages were tied to particular projects that were very successful. Unity could have used Java for scripting (in fact, it does now for Android) and Android could have been delivered in c#. Claiming that these products could have only been delivered in their target languages is just ridiculous
- RayDonnelly 8y agoAnd the notion that a garbage collector should ever be part of a game engine (or anywhere near it) is frankly baffling to me. .. unless you're making some turn based thing.
- RayDonnelly 8y agohttps://youtu.be/NF6kcNS6U80?t=1000 https://youtu.be/NF6kcNS6U80?t=1000
- pjmlp 8y agoMy games development experience is quite irrelevant, however Tim Sweeney and John Carmack might know a thing or two about game engines. "The Next Mainstream Programming Languages: A Game Developer's Perspective" by Tim Sweeney http://www.cs.princeton.edu/~dpw/popl/06/Tim-POPL.ppt http://www.cs.princeton.edu/~dpw/popl/06/Tim-POPL.ppt https://wiki.unrealengine.com/Garbage_Collection_Overview https://wiki.unrealengine.com/Garbage_Collection_Overview "Considering that 8 bit BASICs of the 70s had range checked and garbage collected strings, it is amazing how much damage C has done." John Carmack - https://twitter.com/id_aa_carmack/status/329210881898606593 https://twitter.com/id_aa_carmack/status/329210881898606593 Quakecon 2013 keynote section about GC https://www.youtube.com/watch?v=1PhArSujR_A&feature=youtu.be&t=1443 https://www.youtube.com/watch?v=1PhArSujR_A&feature=youtu.be...
- undefuser 8y agoHonestly, this is a poor argument. While both Tim Sweeney and John Carmack are legends of the gaming industry, their opinions are still should be taken with a pinch of salt. Here's why: both Unreal Engine 3 and Unreal Engine 4 are giant OOP behemoths that powers sluggish games and sluggish editors. They consume a rediculous amount of memory, especially in large projects. Even in the slides you linked, they admitted that there is no obvious way to optimize the engine or scale it over multiple cores, because its performance suffers from death by a thousand cuts. Recently Epic spent a huge amount of time trying to optimize their garbage collector, which, arguably, without it they could have better spent the man hours elsewhere. And then there's the new network replication blueprint which is designed to overcome OOP performance issue. And Tim Sweeney swears by OOP. All of these while the industry is moving more and more towards Data Oriented design. Regarding John's tweet, an interesting question was that could he have built the successful Doom games with BASIC? Most likely no.
- lawlessone 8y ago>surprisingly, c# has succeeded where Java has failed in being cross platform, lol what are you talking about, i can use Java on everything.