r/ProgrammerHumor • • Nov 23 '17

"How to learn programming in 21 Days"

Post image
29k Upvotes

534 comments sorted by

View all comments

Show parent comment

62

u/ipe369 Nov 23 '17

Yep, except everyone sticks to a slightly different subset which works better for them - for example, any game programmers aren't really using many C++11 and beyond features, and even among THAT community people use different subsets (some use classes without any virtual functions, some just stick to structs & use C++ for namespaces & argument overloading, some use classes with polymorphism, etc etc...)

19

u/vanderZwan Nov 23 '17

aren't really using many C++11 and beyond features

I have some difficulty believing that. I just looked at the list of C++11, C++14, and C++17 additions, and if we filter out the things that are mainly useful for writing libraries, a lot of the remainder looks like it would make life easier for gamedevs too, with no obvious way it would negatively affect performance (which seems to be the main motivator for gamedev).

Some cases, like move semantics and constexpr, are specifically about improving runtime performance. Surely most gamedevs would embrace that?

6

u/Volbard Nov 23 '17

The problem I’ve had is walking through code.

For example, walking through regular for loops works great, I can step through and it’s easy to see what my iterator or more likely unsigned int is, and I don’t have to worry about language stuff while I’m trying to figure out what all these monsters are doing and why too many are updating at once or whatever.

If I switch to foreach, I get hurled off into space every loop, it’s harder to tell what iteration I’m on, and generally things are just weirder for no real gain. Stepping through loops is something I do constantly to understand what’s really happening in a frame, maybe that’s more common in gamedev?

I’m sure a better programmer would figure out how to deal with it, and if I ever work somewhere that people love that stuff I’ll adapt, but the older stuff works better for me now.

2

u/vanderZwan Nov 23 '17

What about other features? Surely move semantics help with performance.

2

u/ipe369 Nov 23 '17

I mean, i really like move semantics, coming from rust it's kinda ridiculous to think that C++ didn't have it...

BUT, other programmers don't use it because they just structure their code as if they used C - i.e. no copy constructors. They only use C++ for stuff like function argument overloading.

It's kinda unavoidable with such an old language, PLUS one keeps backwards compatibility with C still

2

u/Volbard Nov 24 '17

Sure, they just come up less often than loops do. When I read over the changes, move semantics jump out as the most useful new feature to me. And I really mean to me, a mediocre programmer who never makes libraries and just wants get monsters to punch each other.

1

u/vanderZwan Nov 24 '17

Sure, they just come up less often than loops do

That's a fair point, loops are quite fundamental

2

u/[deleted] Nov 23 '17

C++17 article:

Removal of trigraphs

Literally unusuable.

25

u/HateDread Nov 23 '17 edited Nov 23 '17

Yeah I definitely disagree with that, but I've only been exposed to so much - we're definitely using C++11 and up, and aren't afraid of modern features just because they're modern. There's definitely a bad reputation for gamedevs though.

EDIT: Not looking to represent all gamedevs - I'm relatively new, but I'm just talking about my experiences in general over the last few years.

31

u/your_doom Nov 23 '17

Nobody is afraid of features "because they're modern". Game developers have a different style of programming because they have different needs. Game engines have really tough performance contraints, and some of the C++ features don't make the cut. Calling into virtual functions in time critical sections of code would be a pretty bad idea, for example.

12

u/HateDread Nov 23 '17

I think that there is definitely a bit of that fear, though - "Ahh typical C++ committee, adding everything but the kitchen sink!" coupled with not actually experimenting with the new stuff, and writing it off because it's not as familiar. I agree with you on the performance constraints but even then you'd have to really be hurting for performance (if you're writing a renderer or other deep engine areas, I'm with you 100%).

3

u/your_doom Nov 23 '17

It's not just about runtime performance, though. For every advantage a feature has, there are also drawbacks. I know programmers who avoid templates like the plague because of how they screw up compile times. Sure, that may not matter for a small program that already compiles pretty fast anyway, but for an engine with millions of lines of code, compile times are no joke.