4 ms·
I've written low-level C++ calling functions from Fortran and doing all sorts of magic to do out-of-core matrix calculations. I've written high-level C++. Gene
by thras 17y ago
I've written low-level C++ calling functions from Fortran and doing all sorts of magic to do out-of-core matrix calculations.
I've written high-level C++. Generic code with all my objects cleaning up after themselves.
So my experience is that C++ is a large language that allows programming in many niches.
- gcv 17y agoGeneric code with all my objects cleaning up after themselves. Are you sure they really cleaned up after themselves, and you don't have a subtle memory leak waiting to happen because of some unnoticed and rare and disastrous problem with the order in which your destructors get called? :)
- thras 17y agoGenerally not a problem if you don't use much multi-inheritance. Making your objects exception-safe will have lots of benefits -- and it's exceptions that are far more likely to be causing leaks in your code than destructor-order issues. Your mileage may vary. Then again, I don't mean to trivialize the issue. It can be a real problem. But can you suggest a language that will prevent 100% of subtle memory leaks? I can't think of any. Hell, if you're using Ruby with a pre-1.8 VM, you don't even need to roll your own leaks.
- sorbits 17y agoWith proper overloads you can easily track your memory usage or even which instances are leaked. So yes, C++ is low-level (it does after all include C), but it has features to abstract away tedious details — this allows higher level programming but being in control of how the abstractions are implemented, as there are many performance trade-offs in choosing (implementation of) abstractions, and that is what makes C++ such nice language for software where performance is important.
- loup-vaillant 17y agoSo, the API of these auto clean up objects is high level. Now how high level is the implementation? If you wrote it yourself (you sound like you did), and the abstraction has few or no leak, I bet you had to write insanely low level code to achieve that. I see only one reason to do that: you need performance so high that no garbage collected language could provide it; and the application is so complex that you have to write high level APIs. Not to mention that your application has to be basically bottleneck-free, or you would have used a garbage collected language, it's FFI, and C/Fortran for the tight loops. To my eyes, that is a tiny niche. It may even be void. The "pure low level" and "pure high level" niches are both better filled by simpler languages. The "low and high level with bottlenecks" niche can be filled by a combo (a combo is simpler than C++, in my opinion). Now, there is a huge niche best filled by C++: the use and maintenance of C++ programs. This is my current day job.