Sasha Pachev wrote:



C versus object-oriented lanuguages like C++/Java is a topic I have
discussed a lot with programmers. I believe that traditional procedural
approaches and languages, like C, are the best for 'systems programming', by
which I mean implementing anything with complex data structures and lots of
parallelism. A DBMS is a typical example of such a complex program. My
opinion is based on:


Amen!

When you look at a DBMS, "complex" barely does justice to the code at hand from what I've read. You basically have to build your own OS (especially in the case of MySQL/InnoDB, considering it runs on UNIXes, Linuxes, BSDs, NetWare and Windows).




1) The object-oriented paradigm recommends that algorithms are structured
around 'objects', that is, around data structures. But I think it is easier
for humans to understand complex algorithms, like the splitting of a node in
a B-tree, if the algorithms are presented on their own terms, and not
fragmented around the 'objects' involved. Donald Knuth of the Stanford
University remarked that proving the correctness of an 'object-oriented'
algorithm is hard, because keeping track of autonomous 'objects' is
difficult.


Amen!

A lot of people at my university would say "But an object is just like a struct! How hard can it be??" I bet you're really going to love writing the method BTreeNode::splitInSomeManner() that produces something that can be used for spliting on the downward traversal and BTreeNode:splitInSomeOtherManner that can be used on the upward traversal.




3) A weakness of C compared to Java is memory management. In C you can
easily write programs that leak memory or run over allocated buffers. In
practice, it has turned out to be relatively easy to keep these memory
management bugs at a tolerable level in our C programs, so that a move to a
language with automatic memory management is not needed.


In Java is it easy to write a program that wastes large amounts of memory, which is worse than a leak. In C, you are full from the start, and then you leak a drop at a time until you are empty. In Java , you are empty from the start, and you have nothing to leak anyway even if you could :-)

Additionally, I find it amusing when an exception chain in Java ends inside the Java VM.


Additionally, Java's too nice. When I stuff something up, I want to see something disheartening like "Segmentation Fault" not "NullPointerException". How dare Java take away the spice of life which is the fun of debugging C code!



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to