|
From: Per W. <pw...@ia...> - 2003-04-24 02:54:33
|
Yes, it's possible to write C++ programs using only the C subset. However, in my book a program not using templates, objects, operator overloading etc is a C program even if the source files happens to have the cpp extension and we use the C++ compiler for generating the object files. It isn't just a question of if the object files gets the C or C++ binding, it's a question of what design concepts that are used. For just about every improvement to a language, there is also often a cost, and it's up to the individual programmers to decide the individual merits of the pros and the cons. _Bool in a c rogram is of course an improvement, since strict type checking makes for error free applications while allowing better optimization by he compiler. BUT, the cost in this case is portability. Objects does improve code quality and greatly increases code reusability, BUT at the cost of resultin in fragmentation of CPU cache. Templates greatly reduced the number of lines to write in a program, thereby reducing possibilities of adding new bugs BUT at the cost of increasing the application size through binary code duplication. Operator overloading allows superb integration of new data types, such as vector addition etc in beautiful code BUT at the cost of not always being intuitive, i.e. when you look at the code it might require a lot of mental work to figure out all type conversions taken place in a single 'a += 2 * b + c' line, just to figure out which operator overloads that actually gets called. ... Just about any feature of any language somehow have both pros and cons. The net result is that whatever languag that are used, the programmer has to spend more or less time on every single line, deciding if the line is more good or evil regarding the target goals of the application. Net result: Use whatever language that is available and fits the bill. Just make sure that you know why you use the language, and that you know what the used features of the language actually do. It is impossible to create a language that is always at least as good as any other language. To get such a language, you have to add new features to the language, and a lot of these new features MUST result in some form of penalties making other languages more fit for use according to that specific criteria. An example: A jack of all trades language has to be large. But then it MUST be harder to learn than a specialized language dedicated to solving some specific subset problems. /Per W On Thu, 24 Apr 2003, Ioannis Vranos wrote: > > -----Original Message----- > > From: dev...@li... > > [mailto:dev...@li...] On Behalf > > Of Per Westermark > > Sent: Thursday, April 24, 2003 1:58 AM > > To: Daniel K. O. > > Cc: dev...@li... > > Subject: Re: RES: [Dev-C++] Re: C and C++ > > > > > > One problem with bigger code is that just about all > > applications larger > > than hello world is getting bigger than the processor cache. That, > > together with multiple concurrently running programs, make us > > loose a lot > > of the total processoer capacity in costly cache misses. > > > > That is one situation where it is a bit easier to optimize in > > a C program > > - a non-OO program makes it easier to place all costly functions close > > together in a single file, letting them better fit in the cache. > > > Or use the procedural paradigm of C++ (the C subset). A language having > almost C90 as a subset can't be any slower than C! > > > For direct hardware optimisation the C subset is to be used, that's the > rational thing to do. Please people do not confuse that C++ is only OO! > Anyone uses the combination of paradigms that fit the purpose. > > > > > Ioannis Vranos > > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL 1: http://run.to/noicys > * Alternative URL 2: http://www.noicys.cjb.net > > > Anti-racism movement: http://www.positive-youthfoundation.org > Iraq Peace Pledge: http://www.peacepledge.org > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |