Wednesday, January 6, 2021

Programming: C verses C++

I don't always agree with Linus Torvalds, but on this topic I do.

http://harmful.cat-v.org/software/c++/linus

In my own words, software should be readable.  Unfortunately C++ encourages completely unreadable code.  Template libraries in particular pretty much guarantee unreadable code.  And unreadable code is unmaintainable code.  And unmaintainable code is doomed to fail in the long run.

Another strike against overly abstract code is performance.  The more abstractions you have in your code the less understanding you have of the performance cost of each line of code.  Using too many levels of class inheritance can obscure giant inefficiencies.  Code performance can quickly blow up if there is no understanding of the cost of an operation.

On the other hand I do agree object oriented programming has value.  No question.  I guess I'm saying there is a balance, and the trick is to find the right level of abstraction for whatever software you are writing.

No comments:

Post a Comment