Slashdot Mirror


Is C++ a 'Really Terrible Language'? (gamesindustry.biz)

Long-time Slashdot reader slack_justyb writes, "Jonathan Blow, an independent video game developer, indicated to gamesindustry.biz that while working on a recent project he stopped and considered how miserable programming can be. After some reflection Blow came to the realization as to why. [C++ is a] 'really terrible, terrible language.'"

The main flaw with C++, in Blow's opinion, is that it's a fiendishly complex and layered ecosystem that has becoming increasingly convoluted in its effort to solve different problems; the more layers, the higher the stack, the more wobbly it becomes, and the harder it is to understand.
"Blow is the developer of two games so far -- Braid and The Witness -- and developed a new programming language known as Jai in hopes to help C++ game developers become more productive."

With Jai, Blow hopes to achieve three things: improve the quality of life for the programmer because "we shouldn't be miserable like many of us are"; simplify the systems; and increase expressive power by allowing programmers to build a large amount of functionality with a small amount of code.

Long-time Slashdot reader xx_chris calls C++ "the triumph of syntax over clarity," while in the interview Blow calls C++ 'a weird mess.' But the original submission ends with these questions. "Is Blow correct? Has C++ become a horrific mess that we should ultimately relegate to the bins of COBOL and Pascal? Are there redeeming qualities of C++ that justify the tangle it has become?

"And is Jai a solution or just yet another programming language?"

18 of 603 comments (clear)

  1. C++ is a terribly documented language. by Futurepower(R) · · Score: 4, Interesting

    C++ is a terribly documented language. Powell's Bookstore in Portland, Oregon, one of the biggest bookstores in the world, had 16 books about C++. All of them were about the many tiny details of C++, with no attempts to show how the language should be used.

    Powell's Books | The World's Largest Independent Bookstore

  2. Re:Yes by Anonymous Coward · · Score: 5, Interesting

    I use lots of C++. I also ignore major portions of it. I do not need all of it. There is nothing saying you have to use every bit of it. It is good to know all the bits though and understand how the tool can help you get things done. Take for example Visual Basic 6. Not exactly a 'bad' language. But it sure let lots of bad things to be created. That is because it was an easy lang to pick up and make a mess of. Being good at what you do takes time. There are no shortcuts. Blaming C++ is kind of a fad. Because like all languages terrible things can be done in it. It will not stop you from doing that. It expresses what you want. If you are not good at what you do you will express bad things. I have seen monsters made in pretty much every language at this point. None of them are 'good' at stopping you from making crap code.

  3. Re:Yes by Joce640k · · Score: 5, Interesting

    Yes. Even Bjarne said (something like): "Inside C++ is a smaller, cleaner language trying to get out".

    The trick is to learn what to use and what not to use.

    The main problems C++ has are:
    a) It's hard to learn C++ by hacking away at it. Some things are counter-intuitive, a good C++ mentor can save you years.
    b) It's not a platform. Casual programmers don't want a "language", they want a platform.

    The bottom line is this though: C++ allows you to precisely express anything you want to do. You never hit a brick wall like you do in other languages.

    Also: Garbage collection is a red herring. Nobody manages RAM in C++ because C++ understands RAII like no other language. All the garbage collected languages handle RAM OK but RAM is only one type of resource. You end up explicitly closing files, etc., when you finish with them. In practice, GC actually creates more work for you compared to C++.

    --
    No sig today...
  4. C++ is great by Actually,+I+do+RTFA · · Score: 3, Interesting

    You can write really great code, short and powerful. You can also write really bad code. In this way it's similar to other languages. However, I've found it far easier to write multiperson, maintainable code in C++ than in JavaScript.

    It does suffer some from things like iterators and safe pointers being added... 1/2 way through it's lifecycle. And therefore, they are less clear than they could be.

    --
    Your ad here. Ask me how!
    1. Re:C++ is great by djinn6 · · Score: 3, Interesting

      My previous post mainly focused on why it's hard to maintain in general. To answer your question, I think by far the biggest difference is readability, and JS being a higher-level language makes it much easier to understand what the code author intend it to do. It hides much of the details with weak typing and automatic memory management, so what a reader sees is just the logical flow.

      Yes, the compiler can enforce certain rules, but it's not foolproof and there are lots of ways to misuse a class or function that the compiler cannot check. At some point, the person using the interface needs to understand how it works. While clear documentation is far more important than the code itself for that purpose, diving into the implementation to figure out some detail still happens quite often, as is looking at the unit tests.

      The more recent changes to C++ significantly improved readability, but still not to the degree higher-level languages can accomplish. I still run into macro and template magic that takes far longer than it should for me to parse.

  5. Was OK for the '80's, But Its Time Has Past by Bruce+Perens · · Score: 4, Interesting

    C++ is a 1980's language (actually, Bjorn started work in 1979). It's lasted long enough that we don't have to shed any tears for its demise.

    We have many better options today. Personally, I am writing in Crystal, and you can see my explorations here:

  6. ALOTD (another language of the day) by jmccue · · Score: 3, Interesting

    I am no fan of c++, and I agree it is terrible. But, creating yet a other language sounds a bit over the top.

    I am convinced this is happening for one reason, companies do not want to train anyone! If they took the the time to properly train people the industry would not be in this state, now we get new methodologies and languages every other day.

    When I started out, senior people spent a lot of time with me showing how I can improve my skills and how the business works. These days you are expected to muddle along hoping to learn your job. No wonder we are having large breaches and crappy software

  7. Rust is that beautiful language within C++ by Anonymous Coward · · Score: 5, Interesting

    Bjarne is right: there is a smaller, beautiful language within C++: it is called Rust. Mozilla has taken the best parts of C++ like its fast performance and its flexible abstractions and created the ultra-safe, ultra-productive and ultra-powerful modern programming language called Rust. While C++ will probably never go away, more and more C++ programmers are opting to use Rust instead because it is so much like C++, yet so much better at the same time.

  8. Re:Yes by Joce640k · · Score: 5, Interesting

    The idea of programming as a semiskilled task, practiced by people with a few months' training, is dangerous. We wouldn't tolerate plumbers or accountants that poorly educated. We don't have as an aim that architecture (of buildings) and engineering (of bridges and trains) should become more accessible to people with progressively less training. Indeed, one serious problem is that currently, too many software developers are undereducated and undertrained. Obviously, we don't want our tools--including our programming languages--to be more complex than necessary. But one aim should be to make tools that will serve skilled professionals--not to lower the level of expressiveness to serve people who can hardly understand the problems, let alone express solutions. We can and do build tools that make simple tasks simple for more people, but let's not let most people loose on the infrastructure of our technical civilization or force the professionals to use only tools designed for amateurs.

    - Bjarne S.

    --
    No sig today...
  9. Re:Yes by blackpaw · · Score: 4, Interesting

    Yes and no, I agree you can do clean, lean good code in C++, but its when you try to avoid reinventing the wheel by pulling in 3rd party libraries that it all goes wrong. Or even the std ones for that matter - the string template library is a classic example, a monster of templates and polymorphism gone insane. If I have to pull out the docs to remember how to convert a string to lowercase, there's a problem.

  10. This is not your grandfather's C++ by mrsam · · Score: 4, Interesting

    Modern C++ looks nothing like C++ of the years past. C++ is a comparatively old language, it's been around for over 30 (!) years.

    And for the longest time C++ was gathering dist, stagnating, and remaining basically unchanged. But an effort begun to update the language, and since 2011 in my estimation C++ is now at least three times as big, and as complex as it was before.

    Folks who've been around the block for a while started getting someone shocked coming across C++ code that looked nothing like the C++ they knew. And people who attempt to start learning C++ from scratch were confronted with the entire, 100% complexity, of modern C++ right off the bat.

    And that's, IMO, is where the current bad rap for C++ is coming from. It is a hard, complicated, language to learn. But it's been my experience that once I spent th effort to learn the nuts and the bolts of modern C++, I found it to be a very powerful, rich, capable language. I don't think I would've been able to write LibCXXW in 2003 C++. It would've taken me five or six times longer than it did. Modern C++ attempts, in made ways, to bring many of the benefits of other, VM-based languages like Java and Perl, and bolt them on top of a compiled framework.

    Some time ago, on stackoverflow, I read a question from someone wondering why their C++ compiler was running out of memory compiling their code. I looked at it. The shown code attempted to implement Sieve Of Eratosthenes in the compiler itself. That is, the code was not trying to implement it itself, but make the C++ compiler do it, via templates, with the actual code resulting in a static array of prime numbers. And the question was why the poor compiler was running out of RAM...

    Try that, with Java.

  11. Re:You are holding it wrong by david_bonn · · Score: 5, Interesting

    That being said, if the semantics of a language tend to encourage people to write horrible code, does it make it a bad language? Good question. Discuss.

    My first observation about C++ is that the best examples of clean, well-written code in C++ tend to use a very constrained subset of the language.

    My next observation is that over the years many of the features added to C++ seem to be very obscure and seem to address odd corner cases. I suspect this is because of some deep design flaw in the language.

    C++ tends to reward a programmer who can design clean, graceful interfaces that can successfully evolve over their lifetimes. And C++ mercilessly punishes programmers who cannot do that. Unfortunately, the vast majority of programmers cannot design clean, graceful interfaces. And very few programmers can do so all the time.

    So yes, in my opinion if a language makes it too easy to write horrible code and very challenging to write great code it is probably a horrible language.

  12. Re:Yes by K.+S.+Kyosuke · · Score: 3, Interesting

    I think that's a very flawed argument. You have no control group in the form of another universe where C++ didn't gain the same popularity and the same programs were developed in an alternative language. Only then could you assess whether C++ helped you write those programs or whether it hindered you. Just because network effects, for better or worse, made most people use it in our world says little of its technical merits.

    --
    Ezekiel 23:20
  13. Re:Yes - Bless You by dgatwood · · Score: 3, Interesting

    Yeah, as I always have said:

    • The nice thing about making programming easy is that any idiot can write software.
    • The bad thing about making programming easy is that any idiot can write software.

    A good craftsperson does not blame the tools — not because you could hand that person terrible tools and get the same results as with great tools, but rather because the person would know what various tools do well, and would find ways to work within their limitations to create something good.

    The same is true for programming languages. Different languages are good at different things. I'd rather smash my head repeatedly with a ball-peen hammer than deal with giant steaming piles of templates, but stick embedded C++ in the kernel without all that STL baggage or exception handling or multiple inheritance or RTTI or any of the other junk that makes the C++ runtime so bloated, and you end up with a halfway decent language for writing device driver stacks.

    Need to use piles of regular expressions for some reason? Perl.

    Need a lightweight template-based web backend language for a small-ish website? PHP.

    Need a language for writing client code? Objective-C.

    Need a language for writing enterprise-scale server code? Java.

    Need a language for full-stack development by a single development team? Javascript, but don't do that. Really. Don't do that.

    And so on.

    --

    Check out my sci-fi/humor trilogy at PatriotsBooks.

  14. Re:Yes - Bless You by geoskd · · Score: 1, Interesting

    Need a language for writing enterprise-scale server code? Java.

    It's funny that you expressed the opinion that people should not write fullstack purely in Javascript, but were OK with writing enterprise scale software in Java. Java is a decent language if you have more compute power than you really need, but not enough to run Python. If you are writing enterprise scale code in Java, then you are wasting a lot of compute power. The point of Java was not to make performant code easier to write, but to make code more maintainable. Any competent C++ developer can get you both performant and maintainable code. The secret really is in the template meta-programming. It allows you to do high performance things that simply can't be done in any other language, including C. I can beat the performance of any implementation in Java, using C++, by at least 25%.

    A prime example of why I can do that is garbage collection. If you implement a linked list in Java or C++, as each node is created, it will have memory allocated for it from the heap. When you are done with the list, each node must then be freed. With a million nodes, that is a million memory allocations and a million frees. Using custom allocators in C++, I can avoid all of those allocations and frees, and use a single memory pool for all of the objects. This requires extra effort, but fundamentally cannot work with Garbage Collection, so in Java, you simply can't create an implementation that can compete. This is just an example of one of the many ways in which Java ties the developers hands in ways that guarantee sub-optimal performance.

    All the things that people complain about being too complicated or "dangerous" in C++ are the very things that give the developers the power to write software that doesn't suck. In all, if a programmer doesn't understand the complexities of C++, then I would argue that they don't understand the complexities of programming for performance, because the first derives directly from the second, and if you fully appreciate programming for performance, then all of the mysteries of C++ will be open to you.

    --
    I wish I had a good sig, but all the good ones are copyrighted
  15. STL & Boost by jklappenbach · · Score: 3, Interesting

    As far as I'm concerned, the language went off a cliff when it started incorporating elements of STL in its basic definitions. One good example of this is the ranged for loop, introduced in C++11, which requires iterators that conform to APIs established in the STL. IIRC, these are statically bound to the for operator, which prevents developers from leveraging inheritance and polymorphism when designing their own iterators.

    STL was a great improvement in its day, but I haven't been a fan for years, nor for Boost. Both are often cryptically written, poorly documented, and overly abstracted compared to modern frameworks. But, instead of improving on these standards with lessons learned from more recent efforts with languages and development kits, the C++ standards committee has doubled down on antiquity.

    I haven't looked back.

  16. Re:Yes by SoftwareArtist · · Score: 4, Interesting

    Inside C++ is a small(er), clean(er) language trying to get out, but it's still neither a small nor a clean language. It's still a verbose, inconsistent, badly designed language.

    Why do you need to separately declare and then define every piece of your API? Because that's how C worked, and C did it that way because of the limitations of compilers in 1977. It's totally unnecessary in a modern language, and it makes your code way less clean. But that's how C++ works.

    Why are templates designed in a way that makes you put the entire implementation in the header file? That was totally unnecessary, and it leads to clunky code. But that's how C++ works.

    How come if a parent class doesn't mark its destructor as virtual, all subclasses will (silently) fail to get cleaned up correctly? This is just bad design. It's probably caused countless bugs over the years.

    The language is full of inconsistencies because no one ever bothered to fix them. Why is "this" a pointer instead of a reference? Why does exception.what() return a char* instead of a string&? There are tons of minor points like this that could easily have been better if someone had bothered to think about consistency. But no one did.

    You can avoid the worst parts of C++, but what remains is still a poor substitute for a well designed language.

    --
    "I'm too busy to research this and form an educated opinion, but I do have time to tell everyone my uninformed opinion."
  17. Re:Firefox is starting to use Rust by Ultra64 · · Score: 5, Interesting
    I doubt it.

    Linus Torvalds:

    I'm not convinced about Rust for an OS kernel (there's a lot more to system programming than the kernel, though), but at the same time there is no question that C has a lot of limitations.

    To anyone who wants to build their own kernel from scratch, I can just wish them luck. It's a huge project, and I don't think you actually solve any of the really hard kernel problems with your choice of programming language. The big problems tend to be about hardware support (all those drivers, all the odd details about different platforms, all the subtleties in memory management and resource accounting), and anybody who thinks that the choice of language simplifies those things a lot is likely to be very disappointed.