Why do C++ folks make things so complicated?

This morning Miroslav Bajtoš asked “Why do C++ folks make things so complicated?” in response to my article on regular expressions in C++. Other people asked similar questions yesterday.

My response has two parts:

  1. Why I believe C++ libraries are often complicated.
  2. Why I don’t think it has to be that way.

Why would someone be using C++ in the first place? Most likely because they need performance or fine-grained control that they cannot get somewhere else. A Ruby programmer, for example, can make a design decision that makes code 10% slower but much easier to use. “Hey, if you want the best performance possible, why are you using Ruby? Didn’t you come here because you wanted convenience?” But the C++ programmer can’t say that. It’s not turtles all the way down. Often C++ is the last human-generated language in a technology stack before you hit metal.

This weekend The Register quoted Herb Sutter saying “The world is built on C++.” The article goes on to mention some of the foundational software written in C++.

Apple’s Mac OS X, Adobe Illustrator, Facebook, Google’s Chrome browser, the Apache MapReduce clustered data-processing architecture, Microsoft Windows 7 and Internet Explorer, Firefox, and MySQL—to name just a handful— are written in part or in their entirety with C++.

Certainly there is a lot of software implemented in higher-level languages, but those high-level languages are almost always implemented in C or C++. When there’s no lower-level language to appeal to, you have to offer a lot of options, even if 90% of users won’t need those options.

On the other hand, that doesn’t mean all C++ libraries have to be complicated. The argument above says that the lowest layers have to be complicated and they’re written in C++. But why couldn’t the next layer up also be written in C++?

Some time in the 90’s I ran across an article called “Top C++.” I’ve tried unsuccessfully since then to find a copy of  it. As I recall, the article proposed dividing C++ conceptually into two languages: Top C++ and Bottom C++. Explicit memory management, for example, would be in Bottom C++. Top C++ would be a higher-level language. You could, for example, tell a compiler that you intend to write Top C++ and it could warn you if you use features designated as Bottom C++.

Of course you could slip from Top C++ into Bottom C++ if you really needed to, and that’s the beauty of using one language for high-level and low-level code. Application code in C++ would use Top C++ features by default, but could deliberately drop down a level when necessary. A section of Bottom C++ could be marked with comments or compiler pragmas and justified in a code review. Instead of having to cross a language barrier, you simply cross a convention barrier.

I thought this was a great idea. I’ve followed this approach throughout my career, writing high-level C++ on top of low-level C++ libraries. To some extent I put on my Bottom C++ hat when I’m writing library code and my Top C++ hat when I’m writing applications.

But most of the world has decided that’s not the way to go. If you’re writing C++, it might as well be Bottom C++. Instead of Top C++, write VB or some other higher-level language. There’s very little interest in high-level C++.

I imagine this decision has more to do with management than technology. It’s easier to have people either write C++ or not. If you’re writing C++, then use any language feature any time. I suppose this is a stable equilibrium and that the Top/Bottom C++ partition is not.

More programming posts

125 thoughts on “Why do C++ folks make things so complicated?

  1. John,

    I remember the article about “Top C++” – a co-worker dropped it on my desk ~15 years ago. Unfortunately I don’t have a copy either. But I remembered the author’s name & tracked down some info…

    “Top C++”, Allan Vermeulen, Object Magazine, June 1996

    You would think in this day & age, anything technical would be archived & findable on the internet. Unfortunately, I can’t find the text of this article (Wayback Machine seems to be having some problems right now)

  2. Often interface of C++ libraries seems to be complicated because of two reasons:
    1) They are written to have high performance for most applications.
    2) They are written in C++ itself.

    The last point is very important. People often confuse functionality built into the language with the functionality built atop of the language. Of course additional functionality which is built into the language will be more convinient to use!

    The classical example is printf() in C vs write() in Pascal. You can do the following in Pascal:

    writeln('The area of circle with radius ', r, ' is equal to ', s);

    But in C you must write format specifiers:

    printf("The aree of circle with radius %lf is equal to %lfn", r, s);

    The Pascal folks will say that C sucks and very inconvinient. But writeln() is not a function! It is an operator built into the language. It can recognise the number and type of the arguments (Pascal funtions cannot do this). In C, printf() is a function which can be written in C itself. You can improve it if you want, or use high-performance formatted-output library instead (which is also written in C). If Pascal programmer will want to improve write(), he will not have the possibility to do so.

    You cannot implement faster/better regexp engine in Perl itself without using the underlying regexp engine. In C++, you can do it. So, these things cannot be directly compared.

    It is like comparing human made by God and robot made by human. You can say that human is smarter and easier to use, but you cannot alter or reimplement him as you can do with robots.

  3. The problem is Top C++ is still a pretty poor language. Most problems that are well solved in Top C++ are better solved in any of a dozen other languages.

    C++, top or bottom, is ugly, heavy on syntax (header files), has a very limited standard library, and no standard for memory management (always makes it fun to work with third party libraries). I have to put up with that when I want to talk to hardware, or write a performance critical piece of software, but I rarely choose to deal with it otherwise.

    I’m with Josh Reuben, C# is Top C++. If you need bottom C++, C# with Manage C++ has the best C++ interop I’ve ever experienced.

  4. Bottom C++ is all about DIY. So saying it doesn’t have automatic whatever (memory management, string libraries, thread pooling, etc.) is like saying a fish doesn’t ride a bicycle.

    The Top/Bottom C++ is still a great partition for teams working in environments that don’t support a non-C/C++ stack.

    MSN

  5. I will take this one step further and say that most of the world is built on C. Examples: Linux, SQLite (by far the most common DB on the planet), about every compiler and interpreter on the planet, and all the core embedded systems that operate your car and washing machine. With respect to 15 years ago, the world is simpler: Bottom C++ can be replaced by C, which has changed little, is portable, minimal and yet has maximal near-native interoperability with established libraries. Top C++ can be replaced by any high-level language with good C bindings; Python works well, but many interpreted languages work to that end. Specialization has indeed occurred, but not how it was hoped and predicted 15 years ago. In 15 years, my prediction is that high-level languages will have further improved, and C will have probably changed litttle.

  6. I’ll agree with gappy, Bottom C++ = C.
    However I’ll add that Top C++ = Objective-C.

  7. If that’s the case, it seems like people should be writing in C rather than in C++. The advantage of C++ is that you can get a mixture of good high-level features with good, predictable performance. But if you eschew higher level programming (e.g. well rounded OOP) then you might was well just bite the bullet and switch to an amalgam of C and Python or suchlike.

  8. I agree with Joey. Top C++ is a pretty poor language in itself. Still not an excuse to have complicated libraries, but it gets in the way.
    If Top C++ had certain features it could be really nice. For example, named parameters, unordered arguments, real optional parameters, list/array initalization, basic string manipulation, lambdas, lambdas as analysable recursive expressions, auto declared variables/type deduction, arbitrary precision integers/floats, nested functions, reflexion, automatic ‘make’ idiom (std::make_pair(), why not just std::pair()). Usually these feautures are criticized but, remember, this is Top C++, not Bottom C++.

  9. Here’s where I start with a language: what does it provide for you to handle errors? Specialized high-level languages that “solve a problem better than C++” look great until you start coding for things that might go wrong. C++ has RAII + exceptions so you can just go right ahead and write your code the way you want without constantly being distracted by error-handling code.

    Some C++ libs seem complex and difficult to use because they are not well put together. A good example seems to me to be various attempts to use C++ itself to build regular expressions at runtime. Mostly they err on the side of pushing syntax too far. The result is a complicated mess that is very hard to use and debug. This is not the language’s fault. Another example is libraries I have seen in which the author deliberately tried to produce something that looked like the Microsoft Win32 API, and succeeded, but the result is ugly. Writing libraries for reuse is an art and not everyone does an elegant job. Correct, maybe but not elegant or simple. This too is not the language;s fault.

    I don’t find the top C++ / bottom C++ idea useful. Code is always naturally layered, with things like word size, endianness and the operating system APIs at the bottom and then a stack of code on top of that. Upper layers build on lower layers. It is incredibly powerful that all layers are the same language and that all layers can use the same facilities. there is no reason the bottom layers should not use the same level of language sophistication as the top layers. For example, consider writing a generic bitmap class that efficiently associates names with arbitrary bitfields. That would be both low-level and sophisticated (as well as very useful in writing maintainable “low-level” code).

  10. Not all C++ libraries/frameworks are ugly and complicated. Check out Ultimate++ (U++).

  11. Top C++ is many languages. With the advent of SWIG and other languages supporting FFI you can have your “top C++” in Python, Lua, Ruby, Perl and others. Personally, I prefer Python for the top level of small projects.

    Anyways, C++ code is complicated because the language is complicated.

  12. Nemanja Trifunovic

    I don’t think C++ libraries are any more complicated than librares written in any other language. STL is a joy to work with; some Boost libraries are complicated, some are simple; WTL is probably the best GUI library I’ve seen regardless of the language. Of course, there are badly designed C++ libraries as well: Qt, MFC, Xerces,… but there are badly designed libraries in other languages. I currently work on a C# project and see complicated code all over the place.

    I like C++ and hope to code again in it soon. It is not clean, pure or perfect in any sense, but it is useful and powerful, and that’s what really matters.

  13. What to say….

    I worked in C and C++ past 20 years. I understand very well what You’re talking about; In the High-level language, as Java is, it is very pleasant to program data structures, for example. There is no messy pointers; the syntax is pleasant, so You can distinguish the parts of statements; some development environments, like Eclipse offer the possibilities like code completion, automatic Exception-handling proposal and like. I agree – programming in Java is something very nice and excitable. But….
    But, sometimes, there are situations where You simply MUST deal with C/C++ features – pointers, memory allocations and like. For example: I had a situation where the main software was written as Java web application. It was for some banking purposes. And there was a Hardware part – the hardware security module (HSM). Eracom, the Australian company, delivered this module with very, very poor support – there was just a C/C++ library, without sources – I had only binary DLL. But the main application requested the access to the HSM. In such a moment, I found the JNI – Java Native Interface. Very powerful. Through JNI I succeeded to call my own DLL, written in C++, which called Eracom’s DLL. My own DLL contained parts which simply collected data passed from Java module, formed the appropriate message strings, and made the HSM DLL’s functions call. So, I can suggest to anyone: take some High level language, such as Java is, and code the time-critical routines in C or C++; then, simply, call these routines using JNI or some other way, whichever You find appropriate.
    Maybe, one thing more. When You try to look at C++ libraries, as STL is, You will – at first – see the horrible syntax and nothing more. But. Consider this: The STL’s function called transform() is such a powerful thing that it You’ll be delighted seeing what it can do. A bit effort to learn the ugly syntax is really not important compared with power of STL library. Btw, looking at Java’s Generic programming, I can see several similarities. It looks that someone just has written a bulk of macros in C++, and – over JRE – passed the STL’s functions directly to Java core.
    Don’t forget – C++, as any other language, has its own specific moments; for example, the delegates in C# simply shocked me, causing the confusion that lasted some time.
    Best regards to anyone programming in High Level Languages!
    D.

  14. How about.
    Top C++ = C#/Java/Whatever is on top of C++
    Middle C++ = C++
    Bottom C++ = C
    OR
    Top C = C++
    Middle C = C
    Bottom C = assembly.

  15. Ok, briefly what I like and don’t like about C++. As an OO language it is good. But libraries. STL does not provide robust bounds checking for arrays and very few checks in general. It looks flacky when you deal of serious matrix processing and algorithms in general. These check are not standardized and implementations (if a ever) do them as asserts not as exceptions, which means that code can crash. Not good at all. The stream copying example, which allows to input data from the console is terrible: the end-of-stream codes are not standardised at all and to clear the stream to allow another input requires “crazy” manipulations on the stream, which makes you wonder what it is all about.
    I have spent some time developing code in C# and found how easy it is to develop a full application: GUI, multithreading, TCP/IP, avoid terrible crashes and confusion.

  16. Can I write a program that runs twice as efficiently in C++ as an equivalent program in C# or VB ?
    In this case, any advantage will be gone in 12 months due to the doubling of processor speed…?

    C# is built on custom libraries that give optimum access to the latest hardware like the file system and graphics system.
    If you are using C++ then you could be using using some old 16 bit or 8 bit libraries giving cross platform generic functionality that is super duper slow… to do file IO for example.
    Specifically I am impressed by the speed at which I can search text files with C# or Java, is this due to the fact that they have newer libraries that are taking advantage of the operating systems’ support of hardware like UDMA bus, or whatever.
    You compile a c++ application, and you may be using compatible file 16 bit file io from the 90’s ? Seriously, you should see how quickly you can do file IO with Java and C# compared to c++ compiled with gcc this is my personal experience.
    I mean, isn’t GCC a bunch of code for the x86 ?, for goodness sake, I want to use windows support for multiple processors, without thinking about it, simply by using C#.

    Bare metal programming,
    would that be embedded programming … real efficient programming
    ( i.e not Object Orientated) like C.

    Could we just let C++ go ? I don’t like it any more..:)

  17. Being in my early 30s currently, I started out my IT career using VB5/6. And for the record, I was someone who actually understood good programming techniques and was not afraid of a few Win32 callbacks in my code. Even so, the C++ snobs still looked down their noses at me: “oh, you code VB…”

    15 years later and with experience in several languages now, I have to admit I get a certain amount of pleasure reading articles that point out the shortcomings C++. Eat your heart out C code snobs…

  18. I dunno. I mean, a lot of the time to get maximum performance I’ll pull out the ol’ generic programming ‘compile time inheritence’. It this bottom C++ or top C++. It allows me to move conditionals higher up in the code, even to compile time, but allows the coding flexibility of writing conditionals in their natural place.
    So this is an example when going after performance requires going to the most advanced, futhest from C aspects of the language.
    So not sure its as simple as top and bottom.
    Bottom line: there’s no substitute for experience and talent.
    C# and performance. Depends what your talking about. If its serving up a web page quickly, more power to you. If its making 60 frames a second or processing 30 gigabytes of imagery, please allow me to roll my eyes here…

  19. Very interesting !

    I’ve actually used this approach for the last 5-10 years, and it makes much sense *to me* ! C++ “purists” will strongly disagree, of course, as I really only use a small part of C++.

    Instead of using MFC/QT/WTL, I’ve created a low-level object-oriented library using Win32 directly – the “Bottom C++”.

    For the application, I’m using a “higher-level” procedure/message-oriented system without objects (or templates). The higher-level code is inspired by Python/C#, and the low-level object-oriented library is partly inspired by the .Net framework.

    Arrays/pointers/memory allocations etc are all used in the Bottom C++, but not in the Top C++.

    This approach allows me to quickly try new things (script-like compiling cycle usually in less than 1-2 seconds) with powerful objects, but at the same time makes it possible to adjust/add the library for custom performance-optimized code when needed.

    Some more details and examples describing this approach
    http://www.ppcsoft.com/blog/c-star.asp

  20. I think that it is at least good to understand the abilities and control c++ provides being a lower level language. One may not chose to use it, but its good to at least know how things work in a language like c++ when they use higher level languages like java/c# and all that heavy lifting is done for them “under the hood”.

  21. I’ve been doing C++ desktop development since 2004 using Qt. It could kind of be considered a ‘top C++’ in the same way as some posters suggest C# given that it gives you tools for doing pretty much anything in C++, which I can then customize with ‘bottom C++’ if I need to work directly with memory or integrate with legacy C code.

  22. Hahaha
    I do that all the time, I learned to program dissembling software when I joined a cracker group just for fun making keygens(I was like 16-17), so I find invaluable to know what the computer is doing, I use C for low level as is like directly reading machine code but portable , I could get easily x10 x100 x1000 faster code because I understand what the computer is doing.

    Ruby is not 10% slower, it is 70% or 80% on real terms, but this is not the real thing as 70% is not too much, computers are so fast and cheap, people time is expensive, when the Inkscape guys converted it from c to c++ they lost 50% of performance, and duplicated binary size. I have experience converting old software to java and other high level languages and it is a similar(or worse) experience. The real fact is that you can not control how things are done and this means you could loose orders of magnitude easily as memory management is so important on CPU and specially on GPUs.

    But you can make your own high quality low level a library that you can use with any other language, I like using python(so easy to make modules),javascript, C++ and objective C as high level.

    It takes practice to be able to do that. Programmers either use to be low level or high level specialist.

    Low level specialists want to reinvent the wheel, while odds are solutions have been already created for common problems. You waste time not solving problems someone else can using high level code.

    high level specialists, they don’t want to use pointers EVER or understand what they do. If you don’t understand what pointers are or do you don’t know what the computer is doing as Linus Towards says. Not important if you are managing texts, essential if you manage sound, images or video or real time robot controllers.

  23. I had to bite my tongue on reading some of these comments. I always recall a favourite saying, wish I could attribute it – if you can’t name 5 terrible things about the language you love, you’ve not done enough in it.

    I’d like to think I have in both C# & C++, and C# is nothing special; taken purely as a language feature set, C# lacks flexibility & features. To take just two examples, it will eagerly force you to copy & paste code out over and over to do the same simple task because it has no concept of boilerplating & generics often are of no help. You can’t as easily do mix-in or policy-based programming because there’s no multiple inheritance or proper composition support. It doesn’t solve many existing language problems, like multi-threading design. What C# has going for it isn’t C# at all. It’s the NET framework. Huge difference – that’s a support library, not a language.

    That doesn’t make C++ perfect. C++ is an incredibly elegant & powerful language, if you have objects that do what you need that were well crafted. If you don’t, and you have to hand-craft those, then sure, the investment is much bigger, and the chance for error much higher. C++ supports COM & DCOM, openly admitted by Microsoft blogs to be by far the most powerful & best remote system they wrote (including subsequent NET efforts). Conversely it lacks some modern features (alfC listed a good set) and has a very long cycle time of improvements. It lacks the support of Microsoft in creating that huge standardised library specifically for Windows.

    I’ve seen some great usage of the Top C++ concept. It can work extremely well. It often doesn’t happen, because, say, in Windows you have to go to NET to do any WPF GUI. Ultimately, nobody except purists really care what language you wrote your software in. Users certainly won’t.

    @Richard – The free lunch of processor speed doubling went away a long time ago. As for NET being so great, ask most games developers why they code in C++ rather than using managed DirectX, for example. If the NET support was so great & optimised, they’d be using it.

  24. It’s been my experience that C++ programs tend to be portable but C++ programmers less so, because C++ is such a complicated language one develops a set of idioms which may require research and mind-set changing before being comprehensible to a C++ programmer from another environment.

    If you want performance, use standard C; you want rapid construction, use python or Java. Both have appropriate glue.

  25. As a C++ programmer for 17 years, I have recently been working in .NET and C#. The other day, I had the need to write a prototype based on some boost libraries. What a refreshing experience! I felt like the handcuffs were off and I could craft code to do EXACTLY what I wanted. Also I could succinctly express what I was trying to do in just a few lines of code rather than having my “application” spread out among multiple .cs and XAML files. I was not depending upon any magical runtime environment sweeping up after me or using some library where I had to hope it did the right thing. When I had questions about how a boost method worked, all I had to do was look at the source code.

  26. That C++ has no built-in memory management is a GOOD THING because you can write your own memory manager specific to the task. Same applies to other “missing” features: array bounds checking, arbitrary precision numbers, matrix operations, you name it.

    If you want to build a system which works JUST THE WAY YOU WANT, use C++, or even C. If you want to cook up something quickly using scotch and bubble-gum, use high-level languages, which may work for you just perfectly.

  27. By the way, Daniel Lemire has an interesting blog post on optimizing high-level code. You can get counter-intuitive results. Surely making one pass through an array is more efficient than making two passes through, right? In C++, yes. In Python, not necessarily.

    In C++, it’s easier to have an accurate mental model of how the computer executes code, and that makes it easier to optimize. That’s not to say we should avoid writing in higher-level languages. It just means that optimizing higher-level languages can require more trial and error. (And often optimization is unnecessary and so this doesn’t matter.)

    My general strategy is to not optimize high-level code. There be dragons. Maybe you run into counter-intuitive results like Daniel did. Or maybe your changes speed up the code on one platform and slow it down on another. Or maybe your changes speed things up for one version of the language but slow it down in the next. If performance is that critical, I’ll use C++ for the whole application or maybe just for the slowest part of the code.

  28. Wow, C++ is too complicated? I don’t even program in C++ and I don’t believe that. Sooner or later the bullet hits the bone and all those nifty, dreamy concepts like typeless data and “information wants to be free” has to be stuffed into a register somewhere and rendered as bits and bytes. God himself chose a four bit wide logic construct. Creation requires constrain or you have an amorphous sea of muck. Games require rules or you don’t have a game.

    If you’re a programmer, but you think that programming is too hard for you, then you probably should be doing something else. Or, if you like working in high level languages and scripting languages, don’t look under the hood and complain that you don’t understand it. If you don’t understand it, but you want to, then learn it… or go on dreaming in a fluffy, comfy bed of roses where typeless data runs free and the bit shifting pointers and overloaded operators have all been rounded up and dragged to the reservation. Just don’t look under the bed, there’s monsters under there.

  29. When people talk that C# is only good for slow, GUI code, I immediately answer that I wrote C++ code to communicate with several thousand electric meters per night (using sockets, reverse Telnet), and then rewrote it in C#.
    To my surprise, the C# code was more efficient and was easier to maintain.

  30. I am a newbie compare to you guys. So, I am here just to share my tiny experience.
    Every thing which is just above the metal is C (VxWorks – C, WinDrivers – C, Linux – C). All the APIs are C. Just above that is C++.
    Here is my performance chart –
    C – extremely powerful & lighting fast.
    C++ – extremely powerful, fast & manageable.
    C#/Java – powerful, easy to use, highly scalable & highly manageable.

  31. The C++ mantra is “as low level as you want, but not more.” There is nothing that forces anyone from having to use C++ as if it were C.

  32. I’m still a student but I’ve had my crack at VB back in highschool doing it for interactive PPTs, just for fun. I wrote my first C/C++ code in college just three years ago, and I’ve been writing C# applications for lazy jobs. Currently I’m trying my luck writing Java code for Android and some PHP+HTML+Javascript for some web projects. All in all I’ve been trying to understand what the heck is Programming now-a-days.

    Thus far I’ve categorized programming tasks (if not programmers themselves) into: Scripting, Embedded, and Middleware.
    Essentially, Scripting is writing code atop an interpreter. Middleware is writing code atop a CLR or VM (I consider Java to be Middleware. It’s not the most efficient programming language and never will be, IMHO.). And Embedded is writing code for byte or native code for a machine’s consumption, and not necessarily for a human person’s use (although, ultimately people will use/run it on their machines).

    And to tell the truth, knowing that there is an underlying byte or native code for the scripts you run atop the latest and fanciest doodahs to make your system run makes me wonder How does it make this happen and Is this the fastest or most efficient manner it can run?

  33. The “top c++” are things like python, which is the glue. Most of python libs (the good ones) are written in c/c++ and use python to make it easy to tie the concepts together. This is the greatness of ‘scripting’ languages. A lot of libraries that exist in ‘pure’ python or java, shouldn’t exist. This divergence between compiled and scripting language folks shouldn’t exist and should work together.

  34. I was a C++ programmer. I jump into higher languages because I didn’t see any new enhancement/ evolution in C++ as a language. IMO basically no language can be or is so perfect that no one has to released a new version/specification/implementation of that language (except GNU http://gcc.gnu.org/projects/cxx0x.html) for last of 10 – 15 years (fetch from wikipedia (http://en.wikipedia.org/wiki/C%2B%2B#History)).

    I still love to code in C++, but I see lot of companies are fine with lower performance higher level language (because of hardware cost is getting cheaper and C++ product development and maintainace cost is getting higher)

  35. If C++ looks more complicated than other languages, it’s because it gives you much more control on everything than any other language, C included.
    For example, in C you can’t get automatic resource control easily. In C++ it IS easier.
    And it is still better than Java and C# in that aspect.
    You can’t use longjmp/setjmp in C, either, without a huge maintanability problem.
    Unluckyly, you can’t use C++ by learning it on a weekend.

  36. @Richards

    You obviously are an app programer that has no idea how an operating system works.

    File I/O has nothing to do with what language you use, they all are going through the same system calls.

    And that nonsense you said at first, that any advantage would be gone in 12 months is just… stupid. Both applications would be running twice as fast, so the gap would still be the same.

  37. I’ve programmed in both C#/Java and C++, and I have to say that certain languages have advantages over others in certain situations. For example, when I do a lot of graphical experiments (equation graphing, simple 3D stuff), I tend to use C# because it’s easier. But when I want to deal with lower-level things (like pointers and manual memory management), I go to C++. The automatic memory management features of C# and Java are nice, but they can only help so much. The runtime has to decide when to free certain objects, and can lead to huge performance penalties if it guesses wrong. In C++ however, you have explicit control over everything; that just means a lot more “tedious” coding.

    And as for things like STL and C/C++ library routines not having error checking, it’s done for a reason: speed. These libraries are designed to be as fast as possible at the expense of runtime checking – this is left to the programmer. There are several instances where these routines do not need to check for bounds (because, for example, the code using them has already done so). IMO, I would rather be forced to check for errors when I have to, rather than be stuck with error checking when I don’t want it (performance-critical code, for instance).

  38. C++ is NOT a complicated language. I think this uncovers a flaw in the current education process of young computer scientists. C/C++ languages embeds Programming Language Concepts and once mastered, one could conquer any language of choice.

    There’s a difference between a Programmer and an Engineer/Computer Scientist.

    Languages like C#, Java etc. lacks the flexibility that C++ provides and cannot be compared. Although I will admit that simple Desktop projects that high school kids could maybe do as well as any professional are maybe better done in the higher languages when time is a constraint.

    If there’s any Embedded engineers reading here.. I think they’ll agree with me..

  39. Achilleas Margaritis

    I read comments like this (“C++ is complicated”) over and over, but no one ever puts up some examples. So, those of you that think C++ is complicated, can you please put some code examples?

  40. C# is for business people who didn’t learn C++.
    Besides it’s another way for Microsoft to get more people stuck with Windows. They could have done something like QT instead of inventing yet another language, but that would have given benefit to Linux users as well, which is not in their interest.

  41. “If you think C++ is not overly complicated, just what is a protected abstract virtual base pure virtual private destructor and when was the last time you needed one?”
    – Tom Cargill, C++ Journal, Fall 1990

    Ask anyone who works with compilers which language is the most complex – C++ is the most flexible and powerful of them all; but it comes at a cost..

    For lots of interesting, fun details:
    http://yosefk.com/c++fqa/

  42. I have to partially agree with Andy. When you get down to all the corner cases the language is pretty complicated BUT if you don’t want complicated then you don’t have to use the complicated parts.

    Other are talking about how C++ isn’t as good as language X because the API for library Y is so complicated and ugly in C++. That may be true but it’s because C++ is a bad language. It because most programmer aren’t all that good at it. Language X provides API Y because if you tried to write the API in the language it would be too slow. People who write programming languages tend to be better programmers so their interface to library Y is going to better than the C++ version written by some random programmer.
    To boil it down, yes language X’s API is better than the C++ version you saw on the Internet but, the API you wrote on top of it using language X is really any better looking than the API you’re complaining about…

  43. I guess should slow down and do a little more proof reading. My last sentence should have said:

    the API you wrote on top of it using language X *isn’t* really any better looking than the API you’re complaining about…

  44. recommend reading the art of unix programming.

    keep it simple, keep glue layers thin, and do one thing and do it well.

Comments are closed.