• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 00:20
CEST 06:20
KST 13:20
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
[BSL20] Non-Korean Championship 4x BSL + 4x China2Flash Announces Hiatus From ASL63Weekly Cups (June 23-29): Reynor in world title form?13FEL Cracov 2025 (July 27) - $8000 live event22Esports World Cup 2025 - Final Player Roster16
StarCraft 2
General
Program: SC2 / XSplit / OBS Scene Switcher The SCII GOAT: A statistical Evaluation Statistics for vetoed/disliked maps Weekly Cups (June 23-29): Reynor in world title form? PiG Sty Festival #5: Playoffs Preview + Groups Recap
Tourneys
RSL: Revival, a new crowdfunded tournament series FEL Cracov 2025 (July 27) - $8000 live event Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays Korean Starcraft League Week 77
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma
Brood War
General
SC uni coach streams logging into betting site Player “Jedi” cheat on CSL Flash Announces Hiatus From ASL BW General Discussion Practice Partners (Official)
Tourneys
CSL Xiamen International Invitational [BSL20] Non-Korean Championship 4x BSL + 4x China The Casual Games of the Week Thread [BSL20] Grand Finals - Sunday 20:00 CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile Nintendo Switch Thread What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Summer Games Done Quick 2025! Trading/Investing Thread Things Aren’t Peaceful in Palestine
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion 2024 - 2025 Football Thread NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 671 users

Game Programming Primer - Page 5

Forum Index > General Forum
Post a Reply
Prev 1 2 3 4 5 6 7 Next All
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
November 28 2012 21:10 GMT
#81
On November 29 2012 03:48 CecilSunkure wrote:
Show nested quote +
On November 29 2012 01:56 spinesheath wrote:
On November 28 2012 05:29 CecilSunkure wrote:
As for optimization, I only talked about delayed construction and said not to pass-by-value. These are the sort of things I learned my first semester working in C. They aren't really something you can get lost in while programming in a bad way as you'll be learning fundamentals essential to programming in general.

Not using pass by value to improve speed is a trap too. Sometimes you want to pass by value, sometimes you don't.
See: http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/


Generally you never even want to think of optimization until after you ran a detailed performance analysis. Before that point all your efforts should be spent on producing simple, readable, understandable, reusable, testable and maintainable code.

You know, intentionally setting up RVO is in and of itself programming while being mindful of optimizations. Some optimization really is just low hanging fruit you can be sure of.

It's stuff that you'll do automatically more and more as you gain experience, but it still has pretty much zero impact on performance for the vast majority of code. You will still need to optimize bottlenecks, and only those matter.

For example, I always write ++i instead of i++ unless I specifically need i++ (and even then I prefer to split the statement into two lines because it's easier to read/understand and maintain), but it never makes a difference with most of it being optimized by the compiler, and the rest simply not being in a critical section.

All I'm saying is: The optimizations without drawbacks are nice and all, but it's not something one should prioritize (especially beginners!). Optimize bottlenecks after performance analysis. Saves time, money, and your sanity.
If you have a good reason to disagree with the above, please tell me. Thank you.
Ender2701
Profile Blog Joined January 2012
United States581 Posts
November 29 2012 07:59 GMT
#82
On November 28 2012 03:43 Random() wrote:
While this is a great article, I think you are overemphasizing the "internals" of game programming. Those parts that work with the hardware and all the low-level implementation details are, of course, quite important, but in all honesty they have little to do with your actual game.

When you look at it this way, then game development (as in implementing the actual gameplay mechanics) is very often done in a higher-level language. People use all sorts of languages (Python, Lua, Java, C#, ...) to abstract themselves away from the engine internals and the horrors of C++, and that is a very good thing. Writing good C++ programs is extremely difficult, and even the state-of-the-art engines written by the most talented programmers in the world are ridden with bugs. C++ programs written by average programmers are a minefield.

So unless you are determined to be a very technical sort of developer, working on the engine, I don't agree that you HAVE to use C++ for game development, in fact I would argue that you should try to avoid it at all if that is possible within your workflow.

Also, you write "there are a few different simple guidelines that one can follow to ensure their code isn’t running sub-optimally" as if running sub-optimal code is something to be ashamed of. Saying such things, especially to new programmers, is a recipe for disaster. Premature optimization is the root of all evil, and for whatever reason many people really seem to like spending their effort "optimizing" absolutely unimportant stuff which they don't even know to be the bottleneck, while at the same time their program is not working correctly overall.


As far as I know most big name games are done in C++. It's actually not bad if you follow good coding practices and code reviews. Starcraft II for instance is primarily C++, and I also know for sure that every game that comes out of http://www.vvisions.com/ and http://www.1stplayable.com/. At the very least, games on console will likely remain primarily in C++ due to the limited hardware specs.
Kerm
Profile Joined April 2010
France467 Posts
Last Edited: 2012-11-29 14:49:59
November 29 2012 14:47 GMT
#83
On November 28 2012 03:43 Random() wrote:
While this is a great article, I think you are overemphasizing the "internals" of game programming. Those parts that work with the hardware and all the low-level implementation details are, of course, quite important, but in all honesty they have little to do with your actual game.

When you look at it this way, then game development (as in implementing the actual gameplay mechanics) is very often done in a higher-level language. People use all sorts of languages (Python, Lua, Java, C#, ...) to abstract themselves away from the engine internals and the horrors of C++, and that is a very good thing. Writing good C++ programs is extremely difficult, and even the state-of-the-art engines written by the most talented programmers in the world are ridden with bugs. C++ programs written by average programmers are a minefield.

So unless you are determined to be a very technical sort of developer, working on the engine, I don't agree that you HAVE to use C++ for game development, in fact I would argue that you should try to avoid it at all if that is possible within your workflow.

[...]


This is just plain wrong. Game programmers do work on C++ too, and although their are more concerned with iterating fast on a feature so that the game designer is happy than with raw performance (as are engine programmers), they need to be excellent at C++. Just read any gameplay programmer job offer (see http://www.gamasutra.com/jobs/board.php?category=16 for instance) you will see than "strong C++ skills" are a pre requisite in 95% of the cases.

Please do avoid to misinform people around here, that are not necessarily schooled with the inner working of the game industry.


[Edit: Ooops actually Cecil already answered pretty much the same thing, sorry about that]
What i know is that I know nothing - [http://twitter.com/UncleKerm]
bbm
Profile Joined April 2011
United Kingdom1320 Posts
November 29 2012 15:39 GMT
#84
Not bad (though rushes through a bit quickly but whatever)

as a note, there's no good reason I can think of to use #define for global ints and things. Use enums or const variables.

You can't for example call the following code snippet:

#define NUM_MAX 256
//...
SomeFunction(&NUM_MAX);

But you can do

const int NUM_MAX = 256;
//...
SomeFunction(&NUM_MAX);



not to mention better error checking and reporting with const vars, and problems if you define the same thing twice.

The only time I'd use #define is when creating some kind of debug and i might want to use ugly macros like __LINE__. something like this:


#define ERROR(x) \
do { \
std::cerr << "ERROR: \"" << x << "\" - Line: " << __LINE__ << ", File: " << __FILE__ << "." << std::endl; \
}while(0)


Or of course if you have a bunch of different flags, you should probably use an enum instead for better type safety and less confusion in parameters and such.
By.Sun or By.Rain, he always delivers
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
November 29 2012 15:50 GMT
#85
Macros are for actual preprocessor operations like include guards and stuff where you select some code based on the architecture you're compiling for (note: use this very sparingly) or debugging (although you should use a logger for that). In some rare occasions you might want to use it to greatly improve readability (for example Typelists). Macros as a replacement for functions, constants, inlining or templates are bad.
If you have a good reason to disagree with the above, please tell me. Thank you.
Random()
Profile Blog Joined August 2004
Kyrgyz Republic1462 Posts
Last Edited: 2012-11-30 17:15:40
November 30 2012 17:09 GMT
#86
On November 29 2012 23:47 Kerm wrote:
Show nested quote +
On November 28 2012 03:43 Random() wrote:
While this is a great article, I think you are overemphasizing the "internals" of game programming. Those parts that work with the hardware and all the low-level implementation details are, of course, quite important, but in all honesty they have little to do with your actual game.

When you look at it this way, then game development (as in implementing the actual gameplay mechanics) is very often done in a higher-level language. People use all sorts of languages (Python, Lua, Java, C#, ...) to abstract themselves away from the engine internals and the horrors of C++, and that is a very good thing. Writing good C++ programs is extremely difficult, and even the state-of-the-art engines written by the most talented programmers in the world are ridden with bugs. C++ programs written by average programmers are a minefield.

So unless you are determined to be a very technical sort of developer, working on the engine, I don't agree that you HAVE to use C++ for game development, in fact I would argue that you should try to avoid it at all if that is possible within your workflow.

[...]


This is just plain wrong. Game programmers do work on C++ too, and although their are more concerned with iterating fast on a feature so that the game designer is happy than with raw performance (as are engine programmers), they need to be excellent at C++. Just read any gameplay programmer job offer (see http://www.gamasutra.com/jobs/board.php?category=16 for instance) you will see than "strong C++ skills" are a pre requisite in 95% of the cases.

Please do avoid to misinform people around here, that are not necessarily schooled with the inner working of the game industry.


[Edit: Ooops actually Cecil already answered pretty much the same thing, sorry about that]


EDIT: Nevermind.
zak_attack
Profile Joined November 2012
Wales6 Posts
November 30 2012 19:14 GMT
#87
yeh man nice thread i have a Bsc in computer game development
'I am the punishment of God...If you had not committed great sins, God would not have sent a punishment like me upon you.
LunaSaint
Profile Blog Joined April 2011
United Kingdom620 Posts
December 03 2012 03:08 GMT
#88
Yikes. This is impressive.

I've dabbled in Python and C++, but I'm still a complete novice. Brilliant stuff.
dae
Profile Joined June 2010
Canada1600 Posts
December 03 2012 23:07 GMT
#89
Wow.. this is like the entire contents of first and 2nd year CSC in one spot. Amazing.
Incze
Profile Blog Joined December 2011
Romania2058 Posts
December 04 2012 17:28 GMT
#90
Posts like your help give me motivation to pursue programming. I'm actually going to buy those books.
Thanks a lot!
Religion: Buckethead
ShadowWolf
Profile Joined March 2010
United States197 Posts
December 06 2012 16:02 GMT
#91
Tons of people use Java all the time - there are plenty of hobbyist games built in Java. I absolutely think making a few smaller games in e.g. Python or Java is a great idea. Arguably, while you're learning, the python/java implementation can be faster than your C++ implementation as long as you do things somewhat reasonably. You will be a far better programmer (especially in C++) by experiencing what other languages can do for you. Even getting in to some functional concepts is powerful because a lot of those ideas fit really well in to building parallelizable systems.

Plus, let's face it, there's a really solid chance most people in this thread won't enjoy doing gamedev for a living. It's a very taxing, very difficult, and very competitive industry with low pay and horrific hours. Very rewarding if you're the type of person who likes making games, but, as someone who is strong in C++, I can assure you having a C++ background isn't really an ultra-desired skill set right now. You can make do (and good money) but your industries are limited (basically you can kiss startups goodbye).

Arrays cannot be passed around from one location to another directly. If attempted, the name of an array will be converted to a pointer to the first element in the array. This incurs a loss of information, as a pointer stores information about location and type, whereas an array stores location of first element, type of the elements and number of elements. This “feature” of C and C++ can actually be viewed as a “language bug”.


In C++, references to arrays are not decayed when passed. This allows you to eliminate this decay at no cost with a parameter that looks similar to the below. Just a sample from an implementation of one of those internet question things, but demonstrates the prototype:
template <size_t Sz>
Node* TreeFromSortedArray(int (&arrayList)[Sz], int start, int end)

With this, sizeof does work correctly (which means you can use _countof or ARRAY_SIZE). You can even replace int with a template if you wanted and that works, too.

I'd probably suggest striking the optimization section entirely; I agree with everything in it but I think it would be stronger in a "Coding for the future" type of section. i.e. postfix/prefix - I use the prefix operator too but it hasn't reasonably mattered in years and I've literally never had a line of code's speed increased by any measurable factor by a postfix ++ operator even in the one situation I can think of where it create unnecessary copies, delayed construction is more just a code organization thing - it can be the right answer in some situations but only if you've done the necessary legwork (profiling and analysis) to know why. And so on with the remaining things. They're all great suggestions but also they're all premature optimizations. More important is focusing on complexity (avoiding n^2 or worse - especially in a loop), profiling, and timing. Every foray in to game making I've made usually involves a section where I forget I only have like 15ms or something to complete the game loop.

Overall it's a great article. I liked the sections on design patterns and data structures. I definitely feel like the #1 mistake I see at work is people overlooking both of those things.
MChrome
Profile Joined May 2011
Netherlands201 Posts
December 07 2012 10:36 GMT
#92
One thing... Do you need to learn C and C++ side by side or is learning just C++ enough?
If you do things right, people won't be sure you've done anything at all.
iaretehnoob
Profile Joined June 2004
Sweden741 Posts
December 07 2012 17:45 GMT
#93
I would advice learning either C or C++, not the abomination that is C/C++ or C with classes.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
December 07 2012 17:58 GMT
#94
Just learn C++. C is used only in some rare and very specific circumstances nowadays.
If you have a good reason to disagree with the above, please tell me. Thank you.
LTY
Profile Joined November 2012
United States223 Posts
December 08 2012 18:14 GMT
#95
oh my, i'm working on whac a mole program in java, i'm totally lost now..
Known as Miso or LTY
Azerbaijan
Profile Blog Joined January 2010
United States660 Posts
December 10 2012 09:58 GMT
#96
I have Visual Studio 2012 and I can't figure out how to set it up for C programming. Options for C++ and C# are pretty obvious but allegedly I can use it for plan C ( I think). I was using codeblocks on my old computer, which I liked a lot, but I have a class that is using C# and I would like to us VS for both languages if I can.
e-Goh
Profile Joined January 2012
New Zealand18 Posts
December 10 2012 14:00 GMT
#97
On December 10 2012 18:58 Azerbaijan wrote:
I have Visual Studio 2012 and I can't figure out how to set it up for C programming. Options for C++ and C# are pretty obvious but allegedly I can use it for plan C ( I think). I was using codeblocks on my old computer, which I liked a lot, but I have a class that is using C# and I would like to us VS for both languages if I can.


Create a C++ console project, and code away in C. You may get warnings for including C headers like <stdio.h> instead of their C++ counterparts <cstdio>, but it won't be a big deal for the foreseeable future.
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
December 10 2012 21:31 GMT
#98
On December 10 2012 18:58 Azerbaijan wrote:
I have Visual Studio 2012 and I can't figure out how to set it up for C programming. Options for C++ and C# are pretty obvious but allegedly I can use it for plan C ( I think). I was using codeblocks on my old computer, which I liked a lot, but I have a class that is using C# and I would like to us VS for both languages if I can.

Just create your file as a .c file.
Azerbaijan
Profile Blog Joined January 2010
United States660 Posts
December 10 2012 22:06 GMT
#99
Ah, thanks. And thanks for the article; I'm hoping to pick up the C and C++ books for christmas and I've just grabbed the Code one from the library. Should keep me busy for a while.
3FFA
Profile Blog Joined February 2010
United States3931 Posts
Last Edited: 2012-12-11 22:49:52
December 11 2012 21:48 GMT
#100
CecilSunkure just curious, what compilers do you use to program with and what compilers have you used to program with in the past? Any short reviews you would be willing to give of a few?

edit: Also, when reading through this I noticed this odd sentence
In the first sentence about Heap:
The heap is memory is a large location of memory that dynamic memory can be requested from.
"As long as it comes from a pure place and from a honest place, you know, you can write whatever you want."
Prev 1 2 3 4 5 6 7 Next All
Please log in or register to reply.
Live Events Refresh
Next event in 6h 40m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 314
ProTech65
Ketroc 23
StarCraft: Brood War
Leta 404
Shine 61
Noble 53
Mind 37
ajuk12(nOOB) 14
Bale 5
Dota 2
monkeys_forever1256
Counter-Strike
Stewie2K1225
Super Smash Bros
Mew2King146
Other Games
summit1g8978
ViBE243
Maynarde139
Organizations
Other Games
gamesdonequick40074
BasetradeTV93
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• Berry_CruncH314
• Hupsaiya 64
• practicex 28
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Azhi_Dahaki33
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• masondota2596
League of Legends
• Lourlo1037
Upcoming Events
Wardi Open
6h 40m
Replay Cast
19h 40m
Sparkling Tuna Cup
1d 5h
WardiTV European League
1d 11h
MaNa vs sebesdes
Mixu vs Fjant
ByuN vs HeRoMaRinE
ShoWTimE vs goblin
Gerald vs Babymarine
Krystianer vs YoungYakov
PiGosaur Monday
1d 19h
The PondCast
2 days
WardiTV European League
2 days
Jumy vs NightPhoenix
Percival vs Nicoract
ArT vs HiGhDrA
MaxPax vs Harstem
Scarlett vs Shameless
SKillous vs uThermal
uThermal 2v2 Circuit
2 days
Replay Cast
2 days
RSL Revival
3 days
ByuN vs SHIN
Clem vs Reynor
[ Show More ]
Replay Cast
3 days
RSL Revival
4 days
Classic vs Cure
FEL
4 days
RSL Revival
5 days
FEL
5 days
FEL
5 days
Sparkling Tuna Cup
6 days
RSL Revival
6 days
FEL
6 days
Liquipedia Results

Completed

BSL Season 20
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
CSL Xiamen Invitational
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.