5 ms·
I see your point, but even if you avoid GC you have other alternatives nowadays.
by marpalmin 13y ago
I see your point, but even if you avoid GC you have other alternatives nowadays.
- kintamanimatt 13y agoSuch as?
- yareally 13y agoProbably referring to reference counting, but that's not exactly a new idea. Still makes for a performance hit using reference counting all over the place.
- kintamanimatt 13y agoI hope not! Reference counting is horrible in terms of CPU time!
- aktau 13y agoCitation?
- kintamanimatt 13y agoThere is no a priori reason to think that it isn't horrible in terms of CPU time. Anything that has to do more work just to manage memory is going to consume cycles, and usually a lot of them. In simple utility programs it might not be observable but in larger applications with more objects, or on slower hardware (phones, for example) the cost is palpable. > We find that an existing modern implementation of reference counting has an average 30% overhead compared to tracing, and that in combination, our optimizations are able to completely eliminate that overhead. This brings the performance of reference counting on par with that of a well tuned mark-sweep collector. [-3] Even the best tuned mark and sweep GCs are a drag on performance. > Reference counting is expensive - every time you manipulate pointers to an object you need to update and check the reference count. Pointer manipulation is frequent, so this slows your program and bloats the code size of compiled code. [-2] > "Unfortunately, reference counting is expensive in both time and space". [-1] Also, the slide entitled "Why reference counting is slow" in some recent lecture notes go into some detail. [0] [-3] http://users.cecs.anu.edu.au/~steveb/downloads/pdf/rc-ismm-2012.pdf http://users.cecs.anu.edu.au/~steveb/downloads/pdf/rc-ismm-2... [-2] http://ocaml.org/tutorials/garbage_collection.html http://ocaml.org/tutorials/garbage_collection.html [-1] http://www.rtsj.org/RTJPP/errata.html http://www.rtsj.org/RTJPP/errata.html [0] http://cs.nyu.edu/courses/fall12/CSCI-GA.2110-001/lectures/GC.pdf http://cs.nyu.edu/courses/fall12/CSCI-GA.2110-001/lectures/G...
- yareally 13y agoIf using something like shared_ptr in C++0x, it does come with some drawbacks (due to not having a strict ownership) as mentioned by Bjarne Stroustrup[1]: Please don't thoughtlessly replace pointers with shared_ptrs in an attempt to prevent memory leaks; shared_ptrs are not a panacea nor are they without costs: -a circular linked structure of shared_ptrs will cause a memory leak (you'll need some logical complication to break the circle, e.g. using a weak_ptr) -"shared ownership objects" tend to stay "live" for longer than scoped objects (thus causing higher average resource usage) -shared pointers in a multi-threaded environment can be expensive (because of the need to avoid data races on the use count) -a destructor for a shared object does not execute at a predictable time, and the algorithms/logic for the update of any shared object is easier to get wrong than for an object that's not shared [1] http://www.stroustrup.com/C++11FAQ.html#std-shared_ptr http://www.stroustrup.com/C++11FAQ.html#std-shared_ptr
- marpalmin 13y agohttp://www.webkit.org/coding/RefPtr.html http://www.webkit.org/coding/RefPtr.html http://www.chromium.org/developers/smart-pointer-guidelines http://www.chromium.org/developers/smart-pointer-guidelines
- rbehrends 13y agoIf you use naive reference counting, yes. But reasonably tuned implementations of deferred reference counting are competitive.
- Arelius 13y agoNot really. Nothing mature. I mean Mozilla is working on Rust for exactly this reason. But the immaturity of that is why we don't have a Rust based browser at the moment. Otherwise, C++ is really our only choice for a mature, modern language without GC.
- marpalmin 13y agoI was referring mainly to rust, but you are right in what you say.
- Arelius 13y agoThen I agree in that Rust is a wonderful language with a lot of potential. But I'm not sure it's yet a practical language to develop a large piece of software in.
- gte910h 13y agoObjective C is also all of those things.
- Arelius 13y agoObjective C is close. in that it's a superset of C. But it has problems in portability, and it's insistence for dynamism make it not obviously well suited for the same problems. At least not more than just working in C.
- bitwize 13y agoThere's C. There's Ada. There's Object Pascal. There's Objective-C. If you're a GNOMEhead, Vala can be pressed into service. I seriously think that anyone who finds themselves reaching for C++ to solve a task should try Ada instead. The semantics of their code will be clearer and their code will be more readable, therefore maintainable.
- kintamanimatt 13y agoI didn't downvote you, but, oh holy crap, Ada! Free documentation is non-existent, performance is lacking compared to C++ [-1] (yeah, yeah, benchmarks, etc), the community is minuscule and pretty much limited to stuff like critical real time systems (read: avionics), and the price of the books (the complete, current ones) is a barrier to entry.[0] From what I've read of others' experiences, there aren't many happy Ada developers. This isn't exactly conducive to a successful FOSS project! (On a side note, I do mostly like the language's syntax and its influence on Ruby is very obvious.) I'm not sure anybody would use Objective-C if it weren't for Apple, any more than people would choose to use JavaScript if it weren't for it being the only language available in the browser. It's a bit of a chicken and egg problem, but the one thing you really need for a successful OSS project are developers. Do any of the Object Pascal implementations actually have a community? A codebase as large as a browser written in C would be a horrible, unmaintainable mess IHMO. [-1] http://benchmarksgame.alioth.debian.org/u32/ada.php http://benchmarksgame.alioth.debian.org/u32/ada.php [0] http://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3Daps&field-keywords=ada%20programming&sprefix=ada+p%2Caps&rh=i%3Aaps%2Ck%3Aada%20programming http://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3D...