And comparing the ref-counted deterministic resource management offered by shared_ptr vs. garbage-collector systems, are the performance of ref-counted systems better than those offered by GC?
I found this article in which there is a detailed comparison of resource management techniques, and in the "Performance" paragraph it seems to show that a tracing GC can offer better performance than a ref-counted system:
And, as a side question: does it exist a tracing garbage collector for C++? The language is so powerful that I think it could be possible to write one. So people could still enjoy the advantages of C++ (e.g. portability on different platforms, not requiring
download and installation of .NET framework, not wasting time for just-in-time compilation of code, etc.) and don't pay too much attention to memory allocation, cleanup, cycles, etc.
Thanks, and looking forward for the next STL video.
STL: Thanks for your excellent *practical* explanation of computational complexity!
I read several more mathematical-oriented explanations, but they were too abstract and more "smoky", more vague; instead yours is very clear and effective.
About performance, I'm looking forward to the interview with Bruce Dawson (BTW: I agree the performance of IE8 is not very good - I do hope that his contributions will make a difference in IE9).
Speaking of performance, I used to think that when you really want the top performance, you should abandon STL and use a more C-like programming style. For example, there was an interesting series of blog posts about a Chinese/English Dictionary reader:
[...] Of course he used available lower level libraries to do this, but that's still a lot of work. Can you call what's left an STL program? I don't think so [...]
So, is it correct that when top performance is required (e.g. in a tight loop executed lots of times or in some other critical portion of code) we should abandon STL and use lower level C-like programming styles? Or is it possible to still use STL successfully
in these scenarios?
In Microsoft you guys write software used by millions of people worldwide: do you use STL in performance critical parts of your software?
It would be interesting to compare this native C++ app with a similar app written in C# using WPF, doing a fair comparison of some parameters, like start-up time, general responsiveness of the user interface, etc.
Another question: if my understanding is correct, you said that STL can smartly use memcpy/memmove to quickly copy raw POD data, and instead it uses proper copy constructor for non-PODs. My question is: how can you (the implementer of STL) discriminate between
POD and non-POD data? In other words, how can you ask a C++ class: "Are you a POD or are you a non-POD?" (such that you then could use memcpy/memmove optimization for PODs).
As a suggestion, I'd like a lesson (or a part of it...) on implementing custom allocators.
In particular, it would be very interesting if you could show how to implement a ".NET-like" allocator which consists in preallocating a big chunk of memory and then just increase a pointer when a (small) amount is requested (so: allocating memory == pointer
increase, very fast - and cleanup of the whole preallocated block is done at the end of the processing, kind of a very primitive "garbage collector").
Moreover, kind of OT... but I'd appreciate if you could spend some minutes sharing with us some insights on when to use exceptions vs. normal error codes in C++ code. Do you use exceptions only for exceptionally bad error conditions? Should exceptions be
used instead of error codes in modern C++?
Thanks much for your time and knowledge sharing skills!
I would love to watch an interview with Larry speaking about some software engineering issues and sharing his monumental experience with us in native coding. For example, listening to him explaining us why they don't use C++ exceptions, or some discussions about subtle bugs he had to solve, etc.