4 ms·
I think it's a good thing to separate requirements/problems/etc. 1: Java has an horrendeous amount of unnecessary garbage due to their erasing generic design (
by whizzter 20d ago
I think it's a good thing to separate requirements/problems/etc.
1: Java has an horrendeous amount of unnecessary garbage due to their erasing generic design (until Valhalla ever arrives), there was some old blog post that chronicled the creation of Dictionary for C#'s System.Collections.Generic (as opposed to the initial Java-like System.Collections) and how it reduced garbage-load by an magnitude.
Java chose compatibility (code continued running as before, with the added compiler checked type safety), so you could use the same Vector, List,etc classes but it also means a ton of boxed Integer,etc objects.
C# went for proper runtime generics, packable struct:s and deprecated their initial collection classes. C++ code with templates can similarly benefit from developer controlled memory usage in places.
You don't need the absolute best GC's when your language doesn't create the same amount of GC-pressure.
2: While the compaction of objects has benefits in compactation and later runtime it does add complications everywhere (you either need to halt while updating moving pointers or have read-barriers).
3: C++ collectors are tricky to get right since compilers don't support it (I'm a bit miffed that they didn't see the GC support through and now removed it), personally I dislike that Boehm has taken so much mindshare since it's lacking in many respects and has given GC's a bad reputation. Reading this article I think it fulfills most parts well (even if it's not 100% faitful to the "abstract" C++ model even if it's probably fine in practice).
4: Reading the article I'm also surprised by the usage of plain pointers, a wrapped pointer type could've provided some concurrent marking support also (assuming optimizing compilers doesn't mess it up), some older GC or other PLang papers measured a 10:1 memory read/write ratio of real world code, so write barriers (esp if only for reference) often aren't that expensive if you're gunning for better latency via concurrent marking.
5: JS <-> C++ is probably the biggest reason they've created their own GC, early JS engines (IE6 iirc) often did reference-counting in C++ and JS GC's and could end up with reference cycles forcing JS developers to avoid certain patterns.
Having unified reachbility in the object graph:s avoids these issues since liveness, in terms of managing moving objects in one heap.
Iirc you created JS-GC:reference objects in V8 interfacing code in the past, didn't check the internals but those objects probably registered themselves with the JS GC,either to be update the references or pin those objects temporarily, you need the interface somewhere, and if the GC's can cooperate at the same time it's an improvement overall.
- Joker_vD 19d ago> You don't need the absolute best GC's when your language doesn't create the same amount of GC-pressure. Conversely, if you language (e.g. LISP) does create a huge amount of GC-pressure, it will lead to the development of the absolute best of GC technology. Edit: no need to downvote this, it won't change the fact that both GC itself and generational GC in particular was invented specifically to make it possible to run LISP programs on the actual existing hardware in reasonable time.
- pjmlp 19d agoOne thing that people almost 100% of the time miss in the Java vs C# generics discussion, is that .NET was actually being designed with generics support, but they weren't ready on time for the 2001 launch, and there were some internal fighting of they should even be delivered, thus the work was only finalised on time for .NET 2.0. This is documented by one of the authors, Don Syme of F#'s fame, on his blog posts and the F# HOPL paper. Meanwhile Java went through Pizza and other alternative proposals until landing were it did. However from my point of view both ecosystems could have been much better on version 1.0, had they taken the learnings from Cedar, Modula-3, Eiffel, Sather and Oberon, among other predecessors, regarding AOT compilation and value types, in GC enabled languages.
- throw755868 19d ago> You don't need the absolute best GC's when your language doesn't create the same amount of GC-pressure. Oilpan manages DOM nodes in Chromium. Some webapps running on POS terminals like to create and destroy thousands of them very rapidly (I’ve seen such code generated by some Java->JS transpiler used by a customer). On lower-end devices this leads to long GC pauses (10-90s) blocking all interaction. This GC is a joke for the purpose it is being used, where the heap pressure is controlled from JS code from a webapp. A generational GC would have no problems with that. Seeing Oilpan described as “high-performance” in Google docs always makes me laugh, having profiled it for some customers in the past, who were having problems with it.
- pebal 19d ago[dead]