Why companies still use C++ and what should I learn then

Started by
45 comments, last by kop0113 10 years, 8 months ago

Again, I definately sound like a C++ zealot but I am just worried that if people take the easy route and learn things like Unity / C# only, then the indie gamedev scene will really stagnate. Then it only takes one company like Microsoft to make something "really easy" like C# but only for the Windows platform (C++/CX for example) and the whole industry will be back in the stoneage again.

That's an extremely unrealistic and pretty much pointless fear.

There are many people out there that make games in languages like C# that are not only more advanced but much more performant compared to many C++ games because the developer utilizes their skills, knowledge, and proper design methodologies to make reusable code that takes advantage of the tools the language gives you.

I always find it funny when people think that "if I use something that is easier I will produce worse code." No, you'll just produce it faster. I've used C# and C++ pretty much equally throughout my time programming and C++ used to be my favorite language, but after using both I can say C# is almost a better means to an end in every single way. The only reason I'm not even using it is a combination of the fact that C++ is standard usage in game dev, the fact using C# cross platform requires relying on mono and a few other minor things.

In terms of writing in a language, more modern languages than C++ are just so absurdly easier to use that I really think anyone that is disagreeing just hasn't -tried- them. But people have this unrealistic almost elitist fear that "if I stop using C or C++ or something then I will grow lazy and stagnant and never innovate." Really I was talking to someone about C# compared to C++ yesterday involving smart pointers vs just being able to create everything with new and throw it to the wind, and for some unknown reason he got all defensive and said to the effect of: "Well when you're lazy and don't care at all about performance its fine to use a language that babies you like that." Like really people, drop the elitist 20th century view.

A language is just a tool, if you give a hammer to a skilled craftsman he's going to do a better job in a week than a guy with a nailgun will in a month because he knows how to use that hammer and how to apply it to that building structure.

Advertisement

Many of the recent posts are acting as though there is One True Language.

There is not.

Programmers should be comfortable with many languages.

Just as a side point, look at the recent Programming Merit Badge from the Boy Scouts. They must come up with 10 languages and list why different languages are preferred in different fields. They must also write programs in at least three different languages. When they announced it some people felt three languages was too many. My response was "Only three?"

Personally, I recommend that every professional programmer be comfortable coding with at least five. My five recommended languages for aspiring game developers are C++, C#, Java, JavaScript, Python, and Perl. Assorted other programming languages, like SQL, PHP, ASP, are also good to know even if you never touch them for your day job. Bonus points for picking up a few functional programming languages like Lisp, Scheme, or Haskell, or for picking up domain specific languages for topics like AI and graphics shaders. There are scripting languages (e.g. shell scripts, batch files) and markup languages (e.g. XML, HTML, YAML) that you will pick up at some point along your educational journey.

I feel like if you only know one language, if you ONLY know C++, or ONLY know C#, or ONLY know Java, you aren't much of a programmer. You might be employable, you might even keep a career writing code in that one language. I've known and worked with a lot of these people, and while they certainly can work as a grunt they tend to be blind to most of the programming world. The same individuals seem to be first on the chopping block when layoffs come around. If you can easily jump from game engine to tools to scripts to whatever else the company needs, your skills are far more valuable to an employer.

As a consequence of this, it make sense to pick an easier first language (C# and Python are great for beginners). After getting comfortable with the first, add a second language, then a third, then a fourth, and so on.

-snip-

There is something to be said though for picking a language and getting good at it. But I totally agree that trying new things is important. In fact if you talk about a language like C++ I found that going to C# taught me a lot about how the languages both approach different aspects of compilation and design differently. Which is important because it helps you understand the code better on each end and also helps you formulate new ideas about how you can work it into your code on other platforms.

Interfaces are a good example, they became common in languages like C# and Java and people have started to use them more in C++ since they're more of a concept than specifically being a language construct. How things like threading is handled is also important.

tl;dr: Broaden your horizons people, it's fun.

It isn't so much as "trying new things" as "absolutely required to be competent".

Over the course of the past several hours, I have used C++, C#, Python, Perl, SQL, plus two in-house tools languages, and quite likely a few other languages that I didn't even notice.

Looking back over the past month I have used about 20-25 languages just to do my job.

Good programmers will think nothing of writing code in C++, editing an HTML + JavaScript display since the GUI relies on WebKit, and maybe have a PHP or JSP or ASP page open to see what the server gives them, looking over the YAML data, and coming up with an SQL script that finds corresponding data. When they're done they may add a few lines to an XML list and update a Python script to include their work. There's eight or more languages involved just with a single task.

We have a few people at the studio who only know enough to get by. When they were hired they only knew C++ and it was expected that they would learn the additional necessary languages on their own. Most learn everything they need. A few have either not learned the languages or struggle to do so; those few will probably be replaced soon.

C++ happens to be the primary language of major game engines, so you must know it.

C# happens to be the primary language of tools, so you must know it.

Python and Perl are indispensable for build scripts. You must know them.

Java happens to be the primary language of many web games, Android, and other systems, so you must know it.

etc.

I agree almost completely with frob with a gigantic butt... er, but...

As a successful programmer, you will be exposed to a number of languages, the good programmers embrace this and come to look at languages like a carpenter looks at tools. As it would be folly to try and nail down a board using a screw driver, the same is true for programming languages. Certain language excel in certain situations, while other languages excel in other situations. Learning one language will make it a great deal easier to learn another language, while learning multiple languages will probably change the way you approach languages you already know ( for good or bad... theres a lot of Java-fied C++ out there because of this... ).

BUT...

This is the beginners forum, and telling someone to learn multiple languages is a very bad suggestion... initially.

Pick one, stick to it and learn how to program. THEN pick another language. With your first language you are going to also be learning programming at the same time. This is why many of us ( myself included ) recommend a more learning friendly language when you are just starting out, the more streamlined your learning experience is, the better. Trying to learn more than one language right off the bat is just dumb. DONT.

Down the road, once you've (honestly) hit a roadblock with your current language, then start looking at other languages. When I hear someone come into these forums ( the beginner forums ) and make claims like "I know C++, C# and Java... what _____ should I do" or worse "I don't like ____ language, it's not powerful enough". News flash for you... for the first, to completely make a number up... say.... year of your programming career *YOU* are the limiting factor, not your language.

Thing is, down the road learning new languages becomes a bit of a joke. Hell, any scripting language worth it's salt, you shouldn't even have to "learn"... you should be able to pick it up, read a bit of the language manual and get to work accomplishing 90% of what you need to accomplish. Once you've got one language down, the next language is infinitely easier, and then the language after that is easier still. Then you try to learn functional programming, have a brain anurism, then come back thinking... "hey, ____ wasn't so hard after all!". ( BTW, functional programming isn't that hard... it just requires a completely different approach ).

So yes, learn multiple languages, learn as many languages as you can. Hell, if you are any kind of a programmer, you will probably start learning new languages simply because they interest you. I certainly know everytime a new language ( Loom, Typescript, Dart, Ruby, etc... ) pops up, I spend at least a few days with it... it's a compulsion of sorts.

But for the love of all the is holy, don't learn multiple languages until you've actually learned to program!

In terms of writing in a language, more modern languages than C++ are just so absurdly easier to use that I really think anyone that is disagreeing just hasn't -tried- them. But people have this unrealistic almost elitist fear that "if I stop using C or C++ or something then I will grow lazy and stagnant and never innovate." Really I was talking to someone about C# compared to C++ yesterday involving smart pointers vs just being able to create everything with new and throw it to the wind, and for some unknown reason he got all defensive and said to the effect of: "Well when you're lazy and don't care at all about performance its fine to use a language that babies you like that." Like really people, drop the elitist 20th century view.

Age grants one many things. In my particular case, my visions getting worse, I yell at people to get off my lawn even though I don't have one, things hurt that never used to hurt and... you start to see patterns in things.

The attitude towards C++ is nothing new, only the actors on stage change in this particular play. When I started programming, well technically I was using BASIC because that was the only option available to me ( which was a very good thing btw... ), but once I started programming "for real" there was a huge backlash against people that used C, because real programmers used assembly. There were actually gaming companies that wrote programs completely in assembly welllll after that was a patently stupid thing to do. ( I think Novalogic fit this description, but age also clouds the brain... ).

Of course, over time hardware got a bit faster, C compiler got a bit better and people started favoring programmer productivity over RAW speed, especially when the speed difference became incredibly narrow. So naturally C supplanted assembly as the primary language of games and assembly, while still used, became a bit less common, then eventually became downright niche.

A very similar thing happened again eventually with C++. C programmers looked down their noses at people that used C++, although C++ starting as a superset of C did lesson the friction a great deal. Eventually though, C++ became the defacto choice and C is now a bit more niche, or I suppose, domain specific is a better way of putting it.

The key is though, every single time a language transition happened, there was an ego factor involved, an e-peen waving that really had no place in all of it. Plus, every time a transition did in fact happen, the old code never did go away, nor did the older languages completely disappear. Plus, amazingly enough, after the transition occurred, life amazingly enough went on.

We are at another interesting point, where the demands of the system are lessening. John Carmack just recently said that programmers aren't really going to be able to easily max out the next gen hardware. I'm paraphrasing him brutally, so here is the direct quote:


"I think that the writing's on the wall that pushing things to their absolute limit is not really tenable for the most part in development," he said. "There's just too much you can do... Nowadays no one person even has the entire capabilities of one of these modern platforms in their head...

"There's too much to wind up with this crystal jewel of perfection like you might have at least have deluded yourself into thinking you were approaching in previous years. So development is a lot more about trying to get the good value out of the time that you can put into it."

Times change, priorities change, needs change... and so do programming languages.

I think C hit off because it was more source portable than assembly.

Something like C# however is not more source portable than C or C++ (since the runtime source is written in those two languages for a start)

It may be more binary portable but frankly phones and tablets are so limited and restricted these days anyway that you cant simply drop the .exe onto their memory cards and run it, so is a completely useless feature.

For this reason, C#, Java, etc... don't offer me any benefits I care about. I can still only target every device out there using C and C++.

Heck, (and referring to another thread) Microsoft couldn't even write an operating system in C#, they had to develop in sing# in the end to add "low-level programming language constructs, which are necessary for implementing system software" to actually do anything useful (based on spec#) (http://en.wikipedia.org/wiki/Sing_Sharp)

Don't get me wrong, the managed languages are quite pleasant to use. If they output native assemblies (and there is no reason to suggest one day that a compiler to do this wont exist) then I would indeed seriously consider using it. If more third party libraries supported being compiled using the the native Java compiler (gcj), I would probably use it with no issues.

For me personally, it isnt about the language but more the platform that they force you to use. For example I wouldnt use C++/clr, C++/cx, managed C++ or any of that either.

http://tinyurl.com/shewonyay - Thanks so much for those who voted on my GF's Competition Cosplay Entry for Cosplayzine. She won! I owe you all beers :)

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.

This topic is closed to new replies.

Advertisement