Another C++ entry

Michael L Torrie torriem at
Wed Mar 22 16:49:17 MST 2006

On Wed, 2006-03-22 at 16:25 -0700, Sasha Pachev wrote:
> In order to have C++ truly crush everything else, you must abandon STL, object 
> creation in a loop, redundant copying of the data, and other performance 
> killers. Use your own hand-crafted hash. Compute the hash index in a loop as you 
> process each character. Or you might actually do better organizing the 
> dictionary into a sorted list, and using an incremental binary search. Or maybe 
> put the dictionary in a tri.

So basically we need to abandon C++ and return to C.  And limited C at
that.  Re-implementing I/O libraries, etc.

> Also fine tune the I/O to eliminate waste. Have a buffer, read chunks into it, 
> then deal with each chunk in place one at a time. Do not copy anything if you 
> can at all avoid it! Figure out a way to deal with the words being chopped off 
> at the end of I/O block. In short, you have essentially full control on the CPU 
> level - use it!

I guess it all comes down to trade-offs.  Do you want to increase
productivity as a programmer at the expense of speed?  For example, is a
200% increase in programmer efficiency worth a 40% speed penalty?  Or is
a 25% increase in speed worth a decrease of 50% in programmer
efficiency? Depends on the application.

I think it is great that someone can bring a library to bear on a
problem and solve this problem in 10 lines of code.  Sure the libraries
may add up to thousands of LOC, but it's the number of LOC the
programmer has to write that is often most important.  So if STL
decreases the amount of work you have to do at the expense of some
potential inefficiency, I say all power to them.  The times reported
here are not shabby at all. 

> Anybody wants to shake his C/C++ muscle?

More information about the PLUG mailing list