Subj : Re: OO compilers and efficiency To : comp.programming From : Rob Thorpe Date : Sun Jul 31 2005 02:36 pm Gerry Quinn wrote: > In article <1122470945.664579.51800@z14g2000cwz.googlegroups.com>, > robert.thorpe@antenova.com says... > > Gerry Quinn wrote: > > > > Nonsense. The C-like bits should be encapsulated in classes with > > > standard interfaces - there is no reason for them to be exposed to the > > > main part of the program. > > > Ideally yes. But if you're writing a part of the program in the C > > style it is probably for performance reasons. Parts of the code like > > this are commonly changed as new ideas come along for improving > > performance. This means although these parts of the code are behind > > standard interfaces they're important and their maintainability is > > important. > > That probably means they weren't thought out properly in the first > place. > > I'm sure there are cases where programs are continually modified to > improve performance. But surely they should be an exception, given > that computing power increases all the time, and if performance was > merely adequate last year, it should be satisfactory this year and more > than satisfactory next year without any further modification? > > Thus in most cases, the programmer should be assigned to a more useful > task such as improving the user interface, rather than thinking of > ideas to improve performance and introducing bugs. I don't think you and I would really disagree with each other if we were talking about a real program, it's an artifact of talking in the abstract. If you can put your C like bit behind standard interfaces, then that's OK. If you can't then : > That probably means they weren't thought out properly in the first > place. In my experience most programs aren't well thought out and don't really have standard interfaces anyway. Much C-style-C++ still hanging around in programs today dates from old requirements for performance. The C has hung around because no-one has had the time or inclination to replace it, or because new programmer mistakenly believe it's there for a reason. In situations like this programmer should decide if they're C or C++ programmers and move in one way or the other. If not, and if you're writing code in C for performance reason then it's quite likely that's because it _always_ needs to be fast. If it's a weak requirement that goes away as time progresses it's likely easier to write it in C++ anyway and put up with a little slowdown until computers get faster. If you have a program like this I think it's often wise to isolate the performance sensitive part in a separate library or executable. At the very least a clear interface must be created to it, even if it's the only clear interface in the whole program. .