4 ms·
I was a big believer in Java, until I started work on the Google indexing pipeline in C++. There are cases where you really need to push both code generation a
by KMag 4y ago
I was a big believer in Java, until I started work on the Google indexing pipeline in C++. There are cases where you really need to push both code generation and lifetime decisions from runtime to compile-time. I think there's still a good case to be made in many domains for ahead-of-time compilation combined with on-stack-replacement/dynamic re-optimization using runtime profiling information. However, mandatory garbage collection is a difficult sell.
Yes, Azul systems, etc. show that you can have nearly zero-overhead GC if you have a few spare cores on which to push the majority of the GC work, but in some systems you can't spare the cores.
Yes, developer productivity is lower when you push these decisions onto the developer. However, there are a few select cases where that productivity hit is worth it.
OS kernels, web browsers, low-latency trading, and a few other domains are such that you really don't want the several percent overhead (and, as a rule of thumb, 2x peak space overhead)/latency variance of the garbage collector. (Yes, Bacon et. al.'s concurrent reference counting collector brings down that peak size, but to get good performance, you end up batching the cycle detections.) Firms that use Java/C# for low-latency trading end up manually managing object pools to remove most of the GC overhead, but then you're essentially back to manually managing memory using compile-time lifetime decisions.
In the specific case of web browsers, Netscape/Mozilla attempted Javagator. With the number of vulnerabilities in JavaScript/DOM in browsers, it's a near certainty that very capable senior engineers at both Microsoft and Google have had long serious looks into managed languages for their JavaScript engines / DOM implementations. Maybe we've advanced enough in both JIT and GC technology that it's worth another stab at a browser written mostly in a managed language, but it's certainly still a very difficult task.
Edit: I also love PyCharm and CLion, but GC pauses in both nearly drive me nuts. Sometimes I drop back to vim to avoid the GC pauses.
Edit: I'd also love to see Microsoft able to recompile Office as Managed C++ and start writing new features and bugfixes in C#/F#/etc. I want to believe. I'm rooting for people to find competitive solutions for the last few cases where GC isn't competitive. However, evidence suggests that most of a premier browser's code is still off limits for GC. I want to be a true believe in GC/JIT again, but I need to be shown.
- pjmlp 4y agoYet, year after year, C++ loses market share in distributed computing and CNCF projects to Java, .NET and Go. Google OSes only expose a JavaScript/Browser userland on one, and a Java/Kotlin on the other one, with a very castrated NDK. Where folks like Termux keep refusing to accept that the world has moved on from POSIX. Office is already managed, it runs on Azure and on the browser, the native version is slowly eroding from most Microsoft shops, as WinDev loses political power against Azure business unit, and everyone else rather ship WebWidgets and Electron, than whatever WinDev with their love for COM put out. XBOX is probably the survivor here.
- KMag 4y agoMarket share isn't everything. Last I checked, SkyllaDB wiped the floor with Cassandra. Hadoop Distributed FS underperformed GFS, etc. I'm glad C++ niche is shrinking, but there are still plenty of good use cases for non-GC'd languages. Top-tier browsers and top-tier games are the main niches on the desktop.
- pjmlp 4y agoYet, it is Cassandra. Hadoop Distributed FS that most people reach for, not SkyllaDB. As proven by Minecraft and plenty of games on the Switch, there is plenty of money to be made, and becoming a top-tier game, when attention to game design is taken, instead of what engine one should care about. WinDev doubling down on COM and C++ for WinRT and now WinUI/WinAppSDK, with tooling remanescent of the glory ATL days, is one of the reasons why even the most die hard Windows developers started to look elsewhere. Even other Microsoft business units, they get all the C++ they need on Microsoft Edge WebView2. One of the reasons why .NET team finally started to care about performance, and is finally on the record that C++/CLI is done, is that they want to reduce as much as possible the need to use anything else, and with each release nowadays there is a bunch of runtime code that gets ported from C++ into C#. I only see three big use cases for no-GC languages, kernel and drivers, GPGPU and LLVM/GCC integration, and even there I am a beliver in systems programming languages with GC, but I guess one needs to compromise somewhere and ChromeOS/Android/Cloud like workloads is the best we can get.
- kaba0 4y ago> manually managing object pools to remove most of the GC overhead, but then you're essentially back to manually managing memory using compile-time lifetime decisions. But those very firms will use ordinary normal Java for the initialization part and only switch to the more restricted “manual memory managed” Java on the hot loop — you are still much more ahead in productivity/manageability. Especially that it is not rare at all to just manage a huge ByteBuffer from Java - for indexing that’s what I would use with some sane abstraction over. Oh and mind you, in case of low-lat trading where Java is not sufficient, nor is C++ -> the next step is ASICs.