Java's Magic Sauce
azul.com
azul.com
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.
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.
> 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."
Same for Xamarin?
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.
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#.
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.
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/xam...
[1]: https://www.appbrain.com/stats/libraries/details/react_nativ...
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#.
> "[C# is] sort of Java with reliability, productivity and security deleted."
-- Gosling on https://www.cnet.com/news/why-microsofts-c-isnt/
Oracle is improving Java native interop with 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.
> 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++.
Value objects are still on the roadmap, specially since Oracle plans to eventually replace Hotspot with Graal.
.. unless you're making some turn based thing.
"The Next Mainstream Programming Languages: A Game Developer's Perspective" by Tim Sweeney
http://www.cs.princeton.edu/~dpw/popl/06/Tim-POPL.ppt
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
Quakecon 2013 keynote section about GC
https://www.youtube.com/watch?v=1PhArSujR_A&feature=youtu.be...
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.
"A Star Wars UE4 Real-Time Ray Tracing Cinematic Demo"
https://www.youtube.com/watch?v=lMSuGoYcT3s
"Siren Real-Time Performance"
https://www.youtube.com/watch?v=9owTAISsvwk
After all, it should be relatively easy to challenge such giant bloated sluggish behemoth OOP engine.
As for BASIC, probably. If John made use of a proper BASIC compiler for MS-DOS like PowerBasic, nee TurboBasic, with the right set of compiler flags.
Naturally it would also have its share of inline Assembly, just like Doom, as every owner of "Zen of Assembly Language" first edition knows that C and C++ compilers for MS-DOS weren't the speed daemons developers nowadays taken them for.
You should spend some time learning how AMOS used to be loved on the Amiga Demoscene back in the day.
If you want to see what data oriented design can do, with regards to games, you can check out Unity's lastest show of their beta ECS and Job systems. And their custom C# compiler called Burst. Essentially sidestepping the Garbage collector, compile away many of C# safety features, like bounds check, under specific conditions. While processing entities in straight array iteration fashion. All in the name of performance, undoing the damages caused in the past. I guess you know that newer generations of CPUs require effective use of the cache as well as multithreading to extract the full power out. At least Unity technologies should be applauded for trying to do that, and for trying to bring it to the mass.
I'm pretty sure that many game engines do use data oriented design to some capacity, especially those that used to run on PS3. But just because they are not available off-the-shelf, no source code to look at, doesn't mean they don't exist. Off the top of my head is Insomniac Games, arguably successful studio which is also a strong advocate of DOD.
All this is to say that there are times when even the legends hold questionable beliefs, which we should take with a grain of salt.
You should find some submissions done by myself.
HPC# job is only to replace those parts currently written in C++, everything else is written in plain C#, with GC, as Unity always was. In fact they have migrated to .NET 4.6 with 4.7 on the roadmap.
Just like Unreal uses C++ with GC, but naturally in performance critical paths they resort to other techniques.
Which isn't much different than on the old days, avoid malloc() and new on the performance critical paths.
Just because there is a GC available doesn't mean one has to use it for every single allocation.
Unity's ECS is implemented in a OOP language, C#, and anyone that has spent some time in the CS literature about component systems, knows that they are just another variation how to do OOP.
One of the best sources uses Component Pascal, Java and C++ (COM) to described them (1997), with the 2nd edition (2002) updated to include C# as well.
"Component Software: Beyond Object-Oriented Programming"
https://www.amazon.com/Component-Software-Object-Oriented-Pr...
https://www.gamasutra.com/blogs/DavidLightbown/20180109/3094...
It was a mixture of C and QuickBasic.
With regards to GC, do check out Unity3D new ECS/Job system/burst compiler. Essentially sidestepping the garbage collector, C# safety checks, while trying to work with the how the new generation of CPUs are designed to perform.
I can also state that in the old days C wasn't worthwhile to be useful as a programming language to write game engines, because proper game engines were written mostly in Assembly with C, Pascal or Basic as their scripting layer if at all.
For example,
https://www.atariarchives.org/
https://www.amazon.com/PC-Intern-Programming-Encyclopedia-De...
Microsoft tried to make this happen with .NET compact framework on Windows Phone for years and failed. So, no, Android could not have been delivered in C#.
https://blog.xamarin.com/android-in-c-sharp/
Also .NET compact framework is not the same runtime as the .NET Framework, .NET MDIL (WP 8.x) or .NET Native (WP 10/UWP).
Actually, thanks to being AOT compiled to native code, budget WP 8.x and WP 10 device, used to be faster than their Android counterparts on the same price range.
[1] https://en.wikipedia.org/wiki/Universal_Windows_Platform
lol what are you talking about, i can use Java on everything.
Yes, and it would have been as successful if Unsafe was never added. The language choice rarely hinged on this, it was just used to improve performance and could have been done natively if it had to.
I don't think so. Do you mean by something like JNI? The use-cases of Unsafe that I see most often would not have been tractable using JNI. They rely on intrinsification.
> it was just used to improve performance
But to the point where Java is not suitable at all without the performance, so it's not a nice-to-have for some people, it's essential.
While I agree that performance is often essential, I don't think the gains from unsafe measurably affected the language's success. Even without, the performance was still a draw compared to many other high level options. If anything, I do think it kept a bunch of libs from dipping into JNI.
I'm glad that it is moving into a fully supported state, though.
There's a new crop of Java databases, starting from Apache Cassandra and towards memory grids such as Apache Ignite or Apache Geode. And they benefit tremendously from access to Unsafe.
Yes it's probably 1% of code ever written in Java by line count, but with potential of being 20-50% by CPU and RAM usage. It is sine qua non, a vital piece of infrastructure.
What unsafe gets you is good cache usage. JNI and other approches negate that benefit(also disables inlining and other things).
This is not to say Unsafe was not appreciated by lots of places, esp wrt high performance libs, embedded dev, HFT shops, etc. But I don't believe that Unsafe really affected success/popularity of the language, heck, it's not even the most important pert of the performance story around the success/popularity of the language not to mention all the other non-performance-related aspects that really did affect its success.
The same reason that you see Unity dominate the game space is that the native interop and cache usage story is much clearer.
FWIW JNI is not a silver bullet to performance problems by any means. The actual overhead of the JNI call either into or out of the VM is non-trivial and usually evicted whatever cache line you were touching. For things that are performance critical you'd usually see a drop of 10-50x between mixed JNI and code that was more cache aware but did the same work(in C++/C/C#).
- Arrays are subject to being moved by the GC, so even if you could get the address they could move.
- Arrays are limited to around 16 GB, and that's if you're packing data into longs.
- Accessing an array involves a bounds check, which may float out of a loop, but may well not.
- Arrays cannot be allocated with memory that is anything except mapped private.
I use Unsafe to put memory into a location where I can get a stable native address in order to make native calls using it. Using an array would not allow that.
On HotSpot arrays are limited to 2 GB
At least J9, Azul and now Graal, and then there is the plethora of embedded ones, but those ones wouldn't be able to use that much memory anyway.
While J9 can give you larger arrays AFAIK you're not guaranteed to get a single, contiguous memory region. You won't notice in Java but JNI criticals may return copies.
I haven't tested Zing, but Zulu is just HotSpot.
In my world I prefer a hard crash than me wingless results, which I then have a hard time reading down ...