SUMMARY: Better to write logical, simple run-time code that works well, than to include a ton of compile-time logic of which you know very little about what happens when the app is actually running, running for a long time, with unpredictable user (and other) input, in real time. Real-time is chaotic, and you can control the bugs easier this way.
I write my production SW in C++.
If code is well written, it can EASILY be converted ('ported') to a different language, and that's my goal. Best targets these days that I am aware of would be Python, Objective-C because Apple uses it, Java, or JavaScript.
One of my projects which is actually a lot of fun, is to REMOVE STL std::vector<> from code, and replace it with simple, easy to maintain and BUG FREE classes.
Why? It seems that with many days of debugging, headaches, very infrequent but persistent crash bugs, and memory usage problems, I conclude that the complexity of the STL code itself is a problem. It is a source of unending difficulties with young programmers. After reading the goals of the Python language, I've seen the light, and understand more. (also, I am stupid).
Run time efficiency, and simplicity, is very important. Using templates to provide much logic, might be elegant, cool, and might work well, but bugs do happen when people try to upgrade, change, modify, use pre-existing code.
So that code should be simple, obvious, transparent, not hidden in complex structures that are hard to find, follow, and trace. C++ templates, used in excess (more than a little) are kind of an exercise for geniuses, not so much for ordinary mortals. You're better off writing good run-time code classes rather than elegant compile time templates.
Done with my pulpit? Not yet. Remember Vista? Do you know where that project originated?
Vista was a programming project using some 'Loki' which was a template C++ library project (of Andrei Alexandrescu and maybe Herb Sutter) who wrote the book "Modern C++ Design" about the library.
Why was Vista such a problem? I'm not sure if they've discussed it in depth publicly, but we can make assumptions. It used too much memory because templates make it hard to manage memory effectively. It had many bugs due to excessive complexity, and programmers had to program around those bugs rather than strictly simplify their code.
Perhaps you should use BOOST, you will learn a lot, but will you produce easily maintainable, efficient, great working run-time real-time code? Maybe, but you could just write good classes and implement the patterns that you need with as much simplicity as possible, and you will control EVERYTHING.
Small discussion: http://stackoverflow.com/questions/2348112/why-is-the-loki-library-not-more-widely-used
This would be a great research project!
No comments:
Post a Comment