Of Bounties and Mercenaries
Stephan T. Lavavej
stl@caltech.edu
Tue Apr 6 04:12:00 GMT 2004
[Scott Robert Ladd]
> C is an excellent language -- despite being Standardized
> (twice!) by committees
Despite, heh.
> it remains a clean and succint way of expressing algorithms.
I don't really think so; not when the algorithms involve any sort of data
structures (which means basically most algorithms).
> Yes, C++ has many nice object-oriented features -- and those
> features are often misused, obscuring the underlying logic of
> a program.
I didn't suggest using Crummy, Common C++, where inheritance is overused and
bozos abound.
> It is very easy to be seduced by the power of higher-level
> abstractions, only to lose the efficiency and clarity of
> expression required for elegant programming.
Recently I was discussing with some friends how to implement Huffman
compression. When a Huffman tree is being constructed, "available" nodes
are kept in a pile, and nodes with the lowest weight must be repeatedly
removed, while new nodes are inserted.
After a bit of thinking, we arrived at this:
std::priority_queue<Node *, std::vector<Node *>, boost::function<bool (Node
*, Node *)> >
available_nodes(*_1 > *_2);
Now, that's certainly... subtle, but it simplifies greatly the following
code.
And you don't ever have to use GC if you use RAII.
Stephan T. Lavavej
http://nuwen.net
More information about the Gcc
mailing list