# Unity When to learn c++?

This topic is 1600 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Let me start off by saying I know the "Should I learn c++?" question has been done to death. I'm aware of the pros and cons stated by multitudes of folks on the internet. However, the answer to my question, alluded to in the title, has come up empty me in a google and forums search so I figured I would start a thread on it.

QuestionWhen should I start to learn c++?

That's the brief version, and if you want to, you can stop there and give a general answer to when someone should venture into the land of c++. And I'd like to thank you in advance for any reply or advice you can give. However, for those who wish to know more specifics of my case, I'd like to provide some of my personal history that may aid in determining what advice to give me. I hope this does not become a giant wall of text.

I have grown up around computers, my dad did some programming in fortran, pascal, basic, and some CNC languages when I was a kid. So we've always had a computer around that I was able to mess around on. I started with some pascal myself, then later ventured into javascript when I wanted to do some web stuff. In the early 2000s, I was enrolled in a computer science program at a college near me. They started us in Visual Basic and a little c++, though in c++ I didn't get much past cin/cout. I had to drop out due to financial and personal reasons. Later, I was able to go to a different college and finish a degree, but since the closest they had to CS was electrical engineering, which didn't really hold my attention, I ended up getting a BS in physics. I use python regularly for computational physics problems, and I feel comfortable enough with python that I feel that if I'm given something to program, even if I'm not familiar with the modules to do it with, I could delve into the documentation and find a way to do it. It may not be elegant, short, or efficient, but I feel I could find a solution. I am by no means an expert in python, there is far too much that I don't know in python to convincingly claim to be, but I feel I know enough at least to be dangerous, as the saying goes.

Lately though, I have been dabbling in C, mostly just taking old programs I've written in python to see if I can make them work in C, and get the same results. Ostensibly to see if there is a computation time benefit to learning C, but mostly to start learning it just because I'm a little curious about it and have the time. I have done a little game programming in python, mostly just the standard hangman, tic-tac-toe, and text based games. I haven't dabbled too much in pygame because I don't like it, I don't know where my dislike for pygame stems, could be the obnoxious colour of the pygame website, could be the overuse of underscores in method names, I'm not sure, but I'm just not a fan.

Obviously, with this history, I'm not just starting out learning to program, and I'm comfortable enough to say that I could probably pick up c++, so I'm not worried about can I learn it. I also know that at 30, with no real formal training in CS, and at this point, no real portfolio to speak of, at least that I'd be proud enough to share with a prospective employer, me becoming employed at a AAA studio, and actually needing c++, is really unlikely to happen.

Since I doubt that I will realistically ever need the lower level and efficiency of c++, is it even worth it to try to learn c++, or would I be better off just messing around with c# and an engine like Unity or something of the sorts? Furthermore, since I'm already trying to learn C for scientific computing purposes, would it be better to just learn c++ for that since that's just a superset of C anyways?

Thank you for taking the time to read this.

-Jared

##### Share on other sites

I'd say... anytime you want.

I started with Java/C# and web development, and when I decided to make a game I decided to use C/C++ since I considered it as the "main" language for programming games.

It's been nearly a year or two that I started, and I'm quite glad I did.

I still haven't got nowhere near getting a complete game, where I probably would have if I sticked to XNA (unfortunately deceased) or Unity, but I got to learn so many things about computers, graphics, languages and hardware in general, how they work, and this helped gave me conviction that I can manage to get anything, anywhere.

Lines I used to see often in C# such as:

MyClass mA = new MyClass();
MyClass mB = mA;


Now give me some shock before I realize "Oh, it's C#".

So, for knowledge I think it was a good thing, but for production value x time spent, not so much.

If you want to develop games and only focus on developing games, I'd recommend to stick to using an existing engine or learning C++ just for using the minimum required for these.

Another thing is, there's just too much about C++. Learning the syntax might take less than a day, it's techniques and such less than a week, but that alone isn't much, really. Learning C++ I think it's learning how things work and studying constantly for new things, how a certain app works, how you use a certain library, etc

As for C or C++, please disregard C completely.

In the past year that I started learning it, I was completely fixed on the idea that I wasn't going to use strings at all. I had (still have) the idea that with better functionality comes worse performance, so I always used char pointers (array of chars to represent strings), among other things.

After various questions and tutorials I've read around, I noticed how silly that was. In some (most, actually) cases the C++ classes and containers were even BETTER than my C implementations.

Now, the language has been upgraded to C++11, so there's a bunch of new stuff and I'm still going through the same thing. Should I use the new features, are they better? Are they worse?

I'll keep coding in C++, and I'll be slowly changing towards C++11 as I see these new features aren't so bad as I think (and I'm pretty sure they aren't).

##### Share on other sites

Since I doubt that I will realistically ever need the lower level and efficiency of c++, is it even worth it to try to learn c++, or would I be better off just messing around with c# and an engine like Unity or something of the sorts?

Is it worth it is a personal question.  Is it worth it FOR YOU?

Good game programmers will learn many languages. C++ is generally one of those languages. Other frequently used programming languages include Java, C#, Python, Perl, JavaScript, SQL, PHP, Ruby, ActionScript, and shell languages. Markup languages you will likely want to learn include things like HTML, XML, JSON and YAML.  Neither is an all-encompassing list. Some languages are good to know in depth, others will require just a cursory understanding; talented professional programmers will end up knowing twenty, thirty, fifty, or more programming languages over their entire career.

The order you learn them is not very important, although some are much easier to learn that others.

If you intend to work on game consoles and game engines you will need to know C++ before you get the job.  If you intend to develop any high performance software, including game servers, you will need to know C++ before you get the job.

If you intend to work on web games in JavaScript or Flash or Java Applets you might never look at C++ code.

Furthermore, since I'm already trying to learn C for scientific computing purposes, would it be better to just learn c++ for that since that's just a superset of C anyways?

Let's clear that up for you.

C and C++ do not have a superset/subset relationship.  There was a time in the 1980s right after C++ was created that you could run C code through a C++ compiler, but those days are long gone.  Any significant C code is incompatible with C++ code and will generate large numbers of errors in a C++ compiler.

Implicit conversions through void pointers, boolean values, tentative definitions, implicit casts, VLAs, designated initializers, and many other differences make code that is valid C not compile in a C++ compiler.  The simple act of making an object with malloc() through C idioms will result in a compiler error in C++.

C and C++ are different languages.  They had a common ancestor but diverged almost 30 years ago.

mostly to start learning it just because I'm a little curious about it and have the time.

That's all the reason you need.

##### Share on other sites

"me becoming employed at a AAA studio, and actually needing c++, is really unlikely to happen"

I dont work in the industry (Still a student), but I would have to say I disagree with the above statement.

I have no idea what your physics degree consisted of, but I guess you have a solid understanding of motion, forces, vecotrs, etc. In addition, you may have all sorts of maths knowledge which applies to 3D games / graphics / physics engines. At the very least, you will easily be able to learn the 3D math stuff - and at a *MUCH* better level than a student. Maths is a key skill in the games industry without a doubt. Mathemetics For 3D Games Programming and Computer Graphics by Eric Lengyel is a good place to start looking/comparing your skill sets.

Personally (as I did in formal education) I would start with C (Being able to make some console apps/games) and then learn C++. C and C++ are similar and most books dont go in to classes from chapter one (Unlike Objective C, for example, which is a class heavy language).

From their, the world is your oyster. You can apply your degree and aim to develop some physics systems. Can learn Direct3D/Open GL and go down the graphics route. Learn sound programming, networking, etc.

No Games Programming degree/Computer Science degree can teach everything. Mine teaches C++ and thats literally about it (and we have a decent employment rate within the first 6 months). The best games programming degree in the UK (Teesside if im not mistaken) hasnt tought any content that I havnt been able to do in 4/5 months of studying Direct3D11 by myself (And I would say that learning something yourself is more important than the degree - indeed, everyone I have spoke too says the first question in an interview centers around things you do outside of education. Plus, imo, teaching something yourself gives you a much more rounded knowledge whenever you finally get it. Uni has wayyyyy too much hand holding to be good for you).

My mate did Computer Science (Newcastle) and, well... I wasn't impressed tbh. Defenatly not for games programming anyway.

So yeah, why not? If your looking for a career change, then your not in a terrible position. Most junior jobs state that they are looking for people with "Computer Science (and games programming) or maths related degree" - You do have a maths related degree.

Finally, learning c++ and games related programming can take time to do correctly. C++ is a hard language. Its of course worth noting that learning C++ as a second language is MUCH easier than it being your first. C#/Java (I did objective C. But I'm a mini mac fanboy ) I have heard is a good start if you want another langauge first .

Edited by Dbowler92

##### Share on other sites

C and C++ do not have a superset/subset relationship.  There was a time in the 1980s right after C++ was created that you could run C code through a C++ compiler, but those days are long gone.  Any significant C code is incompatible with C++ code and will generate large numbers of errors in a C++ compiler.

CAVEMAN is 70,000+ lines of C code, compiled in MS Visual Studio C++ 2012, warning level 4 (to suppress inline-ing notifications), zero errors, zero warnings.

##### Share on other sites

The simple act of making an object with malloc() through C idioms will result in a compiler error in C++.

object, or just a buffer?

buffer works fine:



int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{

unsigned char *p;

nCmdShow=0;
lpCmdLine=0;
hPrevInstance=0;
if (!initprog(hInstance)) { Zmsg("Error initializing program","Caveman v3.0"); return(1); }

p=(unsigned char *)malloc(1000);
free(p);

titlescreen();
runprog();
Zshutdown();
PostQuitMessage(0);
return(0);
}


Edited by Norman Barrows

##### Share on other sites

would it be better to just learn c++ for that since that's just a superset of C anyways?

C and C++ do not have a superset/subset relationship.

For C++ to be a superset of C, then any valid C program must also be a valid C++ program.

Such is not the case. Earlier I listed just a few examples of things that are present in C that will not work in a C++ compiler. A web search can find many more differences.

Yes it is possible for people to use a constrained portion of the C language, add a bunch of casts that would be unnecessary in C but are required in C++, and write code that can compile in both.  But it is also possible for me to write functions that I can copy/paste into Java, C#, python, and other languages. That establishes that the languages are similar, but not that it is a subset.

For example, in that code listing:

p=(unsigned char *)malloc(1000);

That cast is not a C idiom.  There is no reason for a C programmer to write that cast.  It was written only to shoehorn the code into a C++ compiler.

Frequent variable names in C include "new" and "old", that would break in C++.  Occasionally when I work in C I will have names like "template" only to remember that the name is a keyword in C++ and shouldn't be used.

That's not to say you cannot write large programs that are constrained to work with multiple languages. With carefully-crafted constrained writing people have done exactly that. Just as people have also written constrained books like Gadsby without the letter E, or The Exeter Text that only uses the vowel E; yet you wouldn't claim that because of those books the English language does not have those vowels. Just because someone chooses to constrain their writing to a subset of the language does not mean that the properties of their constraints apply to the language as a whole.

##### Share on other sites

C and C++ do not have a superset/subset relationship.  There was a time in the 1980s right after C++ was created that you could run C code through a C++ compiler, but those days are long gone.  Any significant C code is incompatible with C++ code and will generate large numbers of errors in a C++ compiler.

CAVEMAN is 70,000+ lines of C code, compiled in MS Visual Studio C++ 2012, warning level 4 (to suppress inline-ing notifications), zero errors, zero warnings.

msvc++ will use a C89 compiler to compile any files with a .c extension (if you mix in c++ code it will most likely fail to compile, if you tell the compiler explicitly to compile it as c++ it will most likely fail, and if you rename the files to *.cpp or *.cc it will most likely fail to compile (unless you explicitly tell it to compile the file as C89 despite the .cpp file extension)

gcc will do the same thing for C,C++,Objective-C, Objective-C++, Ada and Fortran (Fortran most definitely is not a subset of C or C++)

Edited by SimonForsman

##### Share on other sites

That cast is not a C idiom.  There is no reason for a C programmer to write that cast.  It was written only to shoehorn the code into a C++ compiler.

so then i'm not doing c code, i'm doing c++ without the oo extensions? now i'm confused...

trying to remember when i learned c, and what compiler...

it was for school, systems i think, you had to write a vm, a compiler, a  linker, and a loader in C, and you had to learn C on your own. they taught you pascal and figured you could figure out the rest. kinda weird, because while there i was also taught stuff like forth, smalltalk, lisp, motorola 68000 assembler, fortran, cobol, god the list just goes on. worked out ok though, i got an A in the class.

ok, the C was on a sun sparc workstation running bsd unix and x11 windows. does that sound right?

and an Emacs editor, and GNU C (i think).

then for games, i switched from borland pascal 7 to i guess borland C (or c++ ?) v4 (?). then i switched to watcom. then microsoft.

but as i recall, i switched to C for games before the C++ extensions came along.

so would borland c 4.0 be c or c++ ?

seems to me i've been writing exactly the same code since i switched from pascal to C (++ ?) for games.   its not like the stuff stopped working when the c++ compilers came out. or perhaps they needed a mod or cast or two, been a long time.

Edited by Norman Barrows

##### Share on other sites

msvc++ will use a C89 compiler to compile any files with a .c extension (if you mix in c++ code it will most likely fail to compile, if you tell the compiler explicitly to compile it as c++ it will most likely fail, and if you rename the files to *.cpp or *.cc it will most likely fail to compile (unless you explicitly tell it to compile the file as C89 despite the .cpp file extension)

i use .cpp and .h, and in the compiler settings i tell it to compile as c++ code (for the stronger type checking).

##### Share on other sites
I'm not sure the OP started a thread to discuss the vagaries of C/C++ compatibility. ;)

@jared0169
Have you done much object oriented programming? Using C++ as intended means using OOP and learning OOP at the same time as C++ can be difficult if you've only really done procedural programming before. This is particularly the case if you're familiar with C - you'll tend to think of procedural C solutions and C++ will let you to implement them which will prevent you from learning to take real advantage of C++. If that is the case, you might be better looking at a pure OOP language first - at least until you get the hang of OOP.

##### Share on other sites

i use .cpp and .h, and in the compiler settings i tell it to compile as c++ code (for the stronger type checking).

Then you are writing a program in C++ without classes. You are not getting the benefits of your actual language (C++) and also not getting the features of the C language.

That must be frustrating, like when a constrained writer removes a key from his keyboard to help remind them about the constraint.

Obviously, with this history, I'm not just starting out learning to program, and I'm comfortable enough to say that I could probably pick up c++, so I'm not worried about can I learn it. I also know that at 30, with no real formal training in CS, and at this point, no real portfolio to speak of, at least that I'd be proud enough to share with a prospective employer, me becoming employed at a AAA studio, and actually needing c++, is really unlikely to happen.
If that is the attitude you take, it certainly can be a self-fulfilling prophecy.

One programmer I worked with inside a game studio started out as a self-trained artist. In his 30's he became interested in programming, transitioned to programming art tools and exporters, then was hired at a game studio to program them, and then transitioned at the studio to become a game programmer. He is only one person and it is a nearly unheard-of career path, but the point is that IT IS POSSIBLE.  You need to do the work first but the career is not fundamentally excluded to you.

The question was "When?" The answer is "Whenever you want to."  If you want to do it, that is sufficient reason. Go for it.

##### Share on other sites

C++11 is just incredible, beautiful and powerful. What else do you need to start learning it right now?

• 10
• 9
• 14
• 16
• 10
• ### Similar Content

• Chamferbox, a mini game asset store has just opened with some nice game assets,
Here you can find a free greek statue asset

Also check their dragon, zombie dragon and scorpion monster out:

They're running the Grand Opening Sale, it's 30% off for all items, but for gamedev member, you can use this coupon code:
GRANDOPEN
to get 50% off prices What are you waiting for, go to
http://chamferbox.com
and get those models now!

View full story
• By Dafu
FES Retro Game Framework is now available on the Unity Asset Store for your kind consideration!
FES was born when I set out to start a retro pixel game project. I was looking around for an engine to try next. I tried a number of things, from GameMaker, to Fantasy Consoles, to MonoGame and Godot and then ended up back at Unity. Unity is just unbeatable in it's cross-platform support, and ease of deployment, but it sure as heck gets in the way of proper retro pixel games!
So I poured over the Unity pipeline and found the lowest levels I could tie into and bring up a new retro game engine inside of Unity, but with a completely different source-code-only, classic game-loop retro blitting and bleeping API. Months of polishing and tweaking later I ended up with FES.
Some FES features:
Pixel perfect rendering RGB and Indexed color mode, with palette swapping support Primitive shape rendering, lines, rectangles, ellipses, pixels Multi-layered tilemaps with TMX file support Offscreen rendering Text rendering, with text alignment, overflow settings, and custom pixel font support Clipping Sound and Music APIs Simplified Input handling Wide pixel support (think Atari 2600) Post processing and transition effects, such as scanlines, screen wipes, screen shake, fade, pixelate and more Deploy to all Unity supported platforms I've put in lots of hours into a very detail documentation, you can flip through it here to get an better glimpse at the features and general overview: http://www.pixeltrollgames.com/fes/docs/index.html
FES is carefully designed and well optimized (see live stress test demo below). Internally it uses batching, it chunks tilemaps, is careful about memory allocations, and tries to be smart about any heavy operations.
Please have a quick look at the screenshots and live demos below and let me know what you think! I'd love to hear some opinions, feedback and questions!
I hope I've tickled your retro feels!

More images at: https://imgur.com/a/LFMAc
Live demo feature reel: https://simmer.io/@Dafu/fes
Live blitting stress test: https://simmer.io/@Dafu/fes-drawstress
Unity Asset Store: https://www.assetstore.unity3d.com/#!/content/102064

View full story

• Ho ho ho
Tis the season of Christmas surprises, and we have a awesome one for you! 🎅
Sponsored by all your favorite Unity Asset Store developers, Nordic Game Jam, Pocket Gamer Connects, and co-hosted by Game Analytics, we (Joris and I – Devdog) are launching the second edition of our yearly Christmas Giveaway Calendar for all Unity game developers!

For the past weeks, we’ve been collecting sponsored gifts related to Unity (asset vouchers, product keys, conference tickets etc.), and throughout each day of December leading up to Christmas Day on the 25th, we will be sending out these sponsored gifts as early gamedev Christmas presents via e-mail to hundreds of lucky winners.
The total prize pool is at \$35,000, with over 1200 presents donated by the awesome sponsors!

Merry Christmas from Devdog, Game Analytics, and every single one of the sponsors.

View full story

• itSeez3D, a leading developer of mobile 3d scanning software, announced today a new SDK for its automatic 3D avatar generation technology, Avatar SDK for Unity. The Avatar SDK for Unity is a robust plug-n-play toolset which enables developers and creatives to integrate realistic user-generated 3D avatars into their Unity-based applications. SDK users can allow players to create their own avatars in the application or integrate the SDK into their own production processes for character design and animation.
“Virtual avatars have recently become increasingly popular, especially in sports games and social VR apps. With the advance of VR and AR, the demand to get humans into the digital world is only increasing”, said Victor Erukhimov, itSeez3D CEO. “Our new Avatar SDK for Unity makes it super-easy to bring the avatar technology into any Unity-based game or VR/AR experience. With the Avatar SDK for Unity now every developer can bring face scanning technology into their games and allow players to create their own personalized in-game avatars, making the gameplay much more exciting and immersive.”
Key features of the Avatar SDK for Unity:
Automatic generation of a color 3D face model from a single selfie photo in 5-10 seconds (!). Works best with selfies, but can be used with any portrait photo.
Shape and texture of the head model are unique for each person, synthesized with a deep learning algorithm crafted by computer vision experts
Head models support runtime blendshape facial animations (45 different expressions)
Generated 3D heads include eyes, mouth, and teeth
Algorithms synthesize 3D meshes in mid-poly resolution, ~12k vertices, and ~24k triangles
Six predefined hairstyles with hair-recoloring feature (many more available on request)
Avatar generation API can be used in design-time and in run-time, which means you can allow users to create their own avatars in your game
Cloud version is cross-platform, and offline version currently works on PCs with 64-bit Windows (support for more platforms is coming soon)
Well-documented samples showcasing the functionality.

Availability
The Avatar SDK for Unity is offered in two modes - “Cloud” and “Offline”. The “Cloud” version is available at http://avatarsdk.com/ and the “Offline” version is available by request at support@itseez3d.com.
###