Handmade Hero»Forums»Code
Livet Ersomen Strøm
163 posts
C++
I have noticed that a considerable amount of the streamtime, goes into debating the choices made, to how the code is written.

I mean, to the C++ part of the thing, as opposed to the game itself.
Not that I mind much, as long as it is mostly in the Q&A.

But I notice it's not just here, but all over the net. On gamedev and here and there, where games are supposed to be topic. You end up reading countless essays and debates about the C++ language itself.

For me it's interesting to read, as I pick up details about the language that way. For free, without actually having to install and use it. I also tend to think it may not be, all that productive in the end. I never have to worry about any of that.

Many topics are circling around the use of auto pointers, whatever that is, and various other things, like STD::this, and STD::that, which I guess are language-features. And many of these debates receive a considerable amount of attention.

But why is this? Why do people think that these topics are so important? Are you digging your own grave if you start coding in C++ without being 100% aware of all these topics?

Some people use a rather hard language when they disagree on how a language feature should be used. You can tell it is important to many people.

How much of the time you spend in your career, is for C++ spesific consideration?

Are the peculiarities of C++ itself, interesting IN and OF itself, in such a way that it makes C++ more interesting *because* it has all these syntax issues?

Any thoughts?
Krzysiek
17 posts
C++
Edited by Krzysiek on
I think you may be right.
C++ became so popular because of all those peculiarities. It certainly is excellent language for teaching&learning as you can talk a lot about its weird issues.
But I don't think C++ is very useful for real coding, I don't like it.
Edit: I mean I definitely prefer plain C.
Patrick Lahey
67 posts
C++
Edited by Patrick Lahey on
C++ is immensely complicated and I find it depressing that it is the industry's go to language for performance and resource constrained problems. C is also widely used (at least in embedded) but I suspect that C++ is more common for "large" code bases. The problem is that I don't see a practical replacement for production systems at the moment (yup - I know about rust and julia and Jon's language, etc...).

As to your question about how much C++ do you need to know to start using it, C++ was designed to be largely compatible with C so, if you know C, you can start using C++ for your own work and use C++ features as you learn about them and see they fit for your system (this is what Casey is doing - except in his case he knows C++ and is deliberately avoiding features he doesn't like). On the other hand, I would not let a straight C coder anywhere near an existing "modern" C++ code base if they didn't know about exception safety and RAII but I'm not going to comment on whether I think that style of programming is a good idea or not...
Jari Komppa
41 posts / 1 project
Programmer, designer, writer, a lot of other things; http://iki.fi/sol
C++
The thing that makes C++ so powerful and versatile is that you don't need to use all of its features to be useful.

I've met people who cringe at my "c with classes" approach to programming, saying it's not "proper C++".

The thing is, one of C++'s design principles is that if you don't use a feature, you won't pay for it. Don't use exceptions? Fine, you won't get the overhead of exceptions either. Don't use templated generic containers? Fine, you don't get their overhead either.

I prefer using C++ over C just because bunch of things are simpler to express in C++, but at the same time I don't go overboard with templates, polymorphism or complex object relationships.

Personally I feel C++ has become a rather ugly<> language, and every new version seems to be making it even uglier, but since it's the only game in town, there's little you can do about it.
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
C++
A crude analogy:

If you and some friends want to play a card game, you have a number of games that you can play with a standard deck of cards where you will have a perfectly delightful time, and you can have as much randomness or strategy as you want depending on what kind of game you pick. That's C.

However, if you want to argue with people about the rules, spend time learning a whole new set of cards every year, try to use existing cards that you like only to find out they've been deprecated, spend hours or days constructing strategies only to find that they don't work in practice, flame about what strategies are best on on-line forums, and constantly consult a manual to find out whether how your thought your strategy worked is really how it works in tournament play, you really need to buy Magic: The Gathering.

That's C++.

- Casey

DISCLAIMER: I actually like Magic: The Gathering just fine, since it's an entertainment product and entertainment can be about complexity, certainly - and if one were writing a program in full C++ style for entertainment, that would be totally reasonable, too!
29 posts
C++
Magic the Gathering even used to have a stack as one of its central mechanics (until they shamelessly removed it :'( ). Clearly a game for programmers :)
Gavin Williams
26 posts
C++
What ? They removed the stack ! ... :`(
29 posts
C++
My bad, apparently it wasn't.

It's just that damage do not go on the stack anymore: http://archive.wizards.com/Magic/...icle.aspx?x=mtg/daily/feature/42a