I know, there are threads out there covering parts of my question and this is a C++ forum, so I might have to change my nickname in a few...BUT:
I know about the benefits of C++, I'm far from expert but know my way around - stuff works for me, you know...right now I'm doing some heavy calculations with some C / C++ mix program. One run of it will take about a week on four cores, which are all close to 100% CPU (and I know I could do a lot better if I would have the time to optimise my data streams)...
My question now is: would the program possibly run faster (don't care for coding convenience) if written in plain C ??
Or in other words: how expensive (computational time) are the benefits of C++?
C++ streams work a bit slowly, than C, for example.
Of course, an abstraction, connected with classes costs time.
But if you write on pure C using a good C++ compiler, there will be no difference, whether writing using a good C compiler.
Well I would have to get rid of my class structure (overgod classes wich are used as frontend controlling their servant classes, doing memory allocation and such) and replace it with basically straight forward c functions.
The question is: does it cost computational time to use these fancy and quite useful data types? Because that's what it is, a class is just a data type which can do stuff at its own, isn't it?
So basically if I write c and use a c++ compiler there will be no difference vs. using a c compiler...i thought so. But does "real" c++ (templated classes, heritage classes, classes AT ALL) impact on performance?
Other thing: is there a real difference between boost and pthread, well other than the former is a C++ library and the latter "just C". With some workaround both should do the trick even for memberfunctions ?!
Well I would have to get rid of my class structure (overgod classes wich are used as frontend controlling their servant classes, doing memory allocation and such) and replace it with basically straight forward c functions.
Sounds like the design might be suboptimal. Generally, a class should have a specific, clearly outlined purpose.
The question is: does it cost computational time to use these fancy and quite useful data types?
Generally, no, although it depends on the context. At assembler level, a class is just a section of memory with a specific size. Accessing an element is reading or writing to a memory location at a specific offset. Calling a member function is the same as calling any other function, except with a hidden this parameter.
Because that's what it is, a class is just a data type which can do stuff at its own, isn't it?
But does "real" c++ (templated classes, heritage classes, classes AT ALL) impact on performance?
Those are features that don't cost anything.
Code for templates is generated at compile-time and the layout of classes is also known at compile-time (even if they use inheritance).
Other thing: is there a real difference between boost and pthread, well other than the former is a C++ library and the latter "just C". With some workaround both should do the trick even for memberfunctions ?!
The difference is the ease of use and the proper integration in C++.
Internally, Boost.Thread also eventually ends up calling pthread functions.
OK, that'll do for me...I don't do all that fancy programming. I just use classes to get some structure into my program and templates are THE solution for slim code. I'll stay with them, then ;)