“C with classes”
Traditionally, people are used to think about C++ as “C with classes”. Even those who realize C++ code must have totally different style than C, assume sometimes, it’s all an attempt to make C++ more “OOP”-ish, while C++ is “not really OO”, for the lack of virtual machine, clumsy RTTI, and so on. Look at Java or C#, they say – those are “real” OOP, you don’t bother with crap like garbage collection, it’s all being done for you, and so on, and so forth.
Well, unfortunately (or fortunately, that depends on your point of view), although C++ might have been invented as “C with classes”, it ended up with a very specific role in software development industry, that no other language can compete with.
I’m talking about time-critical operations, while the problems it solves are still fairly complicated and require a lot of code.
OOP exists for reasons. To be able to effectively manage a complex problem, you need an abstraction which binds together functions and data – that’s how OO approach came to existence. “Entities which behave” is much easier to process with human brain than “functions processing data”.
Most Object-Oriented language platforms are also trying to take away from the programmer all kinds of small and nasty problems, like memory allocations, garbage collections, which implies you lose some control on object lifespan and CPU load. As computers become faster and memory larger, all that seems less and less critical, Java and C# pushed C++ to the side of the road, and that is the nature of the things.
When it comes, however, to trading financial markets, where microseconds matter, and you try to squeeze the limits out of your CPU, no matter how fast it is – quite often you have no choice but to go to the only high-level programming language, where you still can have control both on both your memory and your CPU.
Some people take it to the extreme point and say that C++ is “provoking” developers to write inefficient code, and they’d better stick to pure C. The answer is exactly the same as in real life: strong people are not easily “provoked”, they solve real problems and do real business. If you know what you are doing, you won’t be “provoked” into ineffective implementation; on the other hand, if your problem was simple enough to begin with, to make it possible to solve it with C – you might just perfectly get away with a simpler and less effective tool.
Taking the blame
C is simple, alright. It’s a well-recognized “system programming” language. Any new OS or VM or platform will traditionally provide some C-based API, just to be compatible with the rest (and the most) of the world.
However, if you think about it, C is hardly even a high-level programming language. C has structures, and that’s the only level above machine commands. Everything else in C is pretty much syntactic sugar for assembly language. (Well, structures are, too.)
In last couple of years there is a trend in financial/trading industry to write things in pure C, “to avoid complications”. Put aside some unique features supported by C but not by C++, they usually bring the following arguments:
- When you are allowed fewer things, you also do less mistakes (no kidding…)
- C++ compilers are slower than C (no shit!!! compilation time is what’s really expensive nowadays!)
- Too many bad C++ programmers around (and of course, there are much less bad C programmers)
As a side note: it’s not a coincidence that this approach is popular in places implementing Agile/Scrum/Sprint approaches. When you prefer to depend on a “process” rather than on people, this is exactly what you get:
- compilation time becomes more important than developer’s time
- many of your developers are incompetent
- the progress is unbelievably slow
Long story short, if you start blaming a tool, a sharp, multi-purpose tool, and look for a simpler tools which can be operated by less qualified people… well, I guess the very suggestion of it would be considered ridiculous anywhere but in software development.
C is nice when you operate the level of OS calls, dynamic libraries, and so on. But even then, you would typically have “handles” on system object, i.e. OOP comes naturally where it’s needed. Implicitly, a hierarchy of classes can be found in OS world, like file stream is a stream, TCP socket is a socket, and so on. However, C is definitely not enough when your code becomes big and complicated – the object-oriented approach is what it takes to handle that complexity, and C++ provides that approach while still giving you means to optimize your code.
If you think you can build a cheaper business without severely compromising manageability – good luck with that!