Why C++ for Unreal 4?

I still play CRPG mod for M&B :slight_smile: good times.

I have spent the past couple of days reading through this very long, sometimes-interesting, and mostly-tedious thread, and would like to share a summary of what I see.
*( For the record, I know C++, C# and Python, and have experience using all 3 and more )
*

I just started watching a course I bought from 3DBuzz, about developing plugins for UE4, and was thoroughly-horrified…
They spend the first HOUR AND A HALF, about 25% of the entire course, just composing the most basic of scaffolds…
It involves a huge-mess of stuff:

  1. A very complex folder-hierarchy that one MUST manually create and maintain (doing things from within visual- brakes everything and it doesn’t work)
  2. A custom file that is used to be a manifest, which you MUST manually create and fill-out, with tons of cryptic data.
  3. A custom C# file that is ONLY used to guide their custom build-tooling - and again, you can’t use VS properly for managing that, as it needs to be injected into a solution-file that UE itself needs to re-generate.
  4. Tons of headers you must #include, that must manually-match the ones you already noted in your C# file.
  5. IntelliSense doesn’t even work - not for the MANDATORY C# file, and not even later for the C++ code - it CONSTANTLY brakes-down, as well as having tons of “squiggly” lines all-over the place, because VS can’t reason-about the solution, since the entire reference-mechanism is heavily-macro’ed and relies on an external custom build-tool. So, you CAN’T see you mistakes (as you can’t trust non-squiggly-lines) AND you don’t have IntelliSense at all AND you have to re-compile all the time AND it takes a lot of time each time you do, which would more-often-then-not result in it eventually failing, and giving you errors…
    They actually had to stop the video when compiling, and fix things on-camera when it’s done trying to compile, and do so without any help from VS, which resulted in them having to go through ~7 cycles of such non-sense in a row, just to get a foot in the door of UE4 ans seeing their show-up…

What a complete nightmare…

How can anyone in their right-mind could possibly fathom such a process as being anything even remotely-reminiscent of being ““productive”” - is completely beyond me…

The fact of the matter is, that using a heavily-template’d and macro’ed flavor of C++, with a custom and non-standard build-process that brakes all of VS strengths, just for doing simple-to-moderately-complex non-performance-critical game-logic, makes ZERO pragmatic-sense - it’s a huge encumbrance, and adds such a productivity-overhead that is very difficult to justify FOR THAT TASK.

Let me tell you what it REALLY is meant for, if your’e actually interested:

Big Game-Studios (!)

When you have a staff of hundreds, many of them experienced C++ programmers, and you have a huge budget to invest in paying them for a few years, than having something like a code-base of UE4 all accessible for them to study and build-upon, is a god-sent - it very-well may save them many millions of dollars and a few years development of their own equivalent (if they had had to start from scratch…) - This is very welll worth the 5% revenue, and Epic knows that, and that’s why theiy are charging it - THIS is the REAL target-audience of this code-base!

For the rest of us, it SHOULD be - at best - a “necessary-evil” of LAST-RESORT, when ALL else fails with Blueprints/other-scripting-languages, either in terms of flexibility or performance-critical parts - end EVEN-THEN, it would be for just a small number of pain-points, that should be relatively rare.

As for the people posting here on this thread:
On one camp, there are those who are content with the current situation, and looking forward to writing their games in C++.
For the most part, it seems to me that NONE of them have had ANY experience using higher-level languages, so they can only speak out of what they know, and not what they don’t know (that’s just how the human-brain works - it’s not magical, it’s simple physics). It seems that anyone that has posted here that has experience in both C++ AND higher-level languages, either has trouble justifying using C++ in the context of coding “most” general game-logic for “most” games, or is actually in the second camp that is NOT comfortable with the current situation, and is actually willing to leave his ego aside and acknowledge that publicly.

I would further sub-categorize this first camp into 3 sub-camps (DISCLAIMER: Much scorn on this part… Sorry…):

  1. The Noobs : People who are new to the whole fiasco, and just know that “AAA games are written in C++”… They just regurgitate mantras, without necessarily knowing what they are talking about (I can live with those - they are cute…)

  2. The Wannabees : People who have little-to-no experience in C++, who are just comparing d***-sizes, and shouting in favor of the biggest-one - they want their Ferrari… It’s Fast… It’s Sexy… (This is so immature… But a little amusing… I can live with those also, because it is easy to disregard them…)

  3. The Zealots (These are the worst of the three…): People who actually have experience using C++ and know it well. They obviously like very-much the fact that they have full-access to the source-code in their preferred language. The thing is, I am having real trouble buying their “act”, as if they are “actually enjoying” the prospect of coding in C++ against a heavily-template’d and macro’ed API - whatever it may be - you have to be clinically-masochistic to enjoy that, and the only way I can explain that otherwise, is a very deep-state of “denial” on their part. And that is actually understandable - Unreal Engine 4 is by-far the best thing that has ever happened to the game-industry - period, full-stop. - and the prospect of having full-access to the C++ code of the engine and the editor, is nothing short of “sexy” (IN THEORY! In “practice”, it is VERY painful… Hence the “denial”…). Probably, some barely-conscious-part of them secretly wishes there were better alternatives, but since it’s UE4 and is so cool, and since they already know C++, their conscious-mind can-not acknowledge that fact… It just doesn’t register… Their entire “identity” and self-esteem is by now very-much wrapped-around their amazing-skills as C++ developers, and they can not hear anything jeopardizing their world-view in which C++ is the ultimate-language, and their proficiency in it makes them grate. (These I just hate… They would have their time better-spend at a shrink, then posting long-comments in forums…)

As for the second camp - I would call them “the pragmatic” or “the reasonable” or at all “the rational”:
These people know what C++ IS and what it IS NOT, what it IS FOR and what it IS NOT FOR, and also know what managed-languages ARE and what they ARE NOT, and what they ARE FOR, and what they ARE NOT FOR. Some of them explain it remarkably well (These I like a lot…) - but some less then others…

These people (myself included), are rightfully and justly frustrated, for now…
They KNOW in their “gut” that there is currently a missing piece in the UE4 puzzle, and they can’t wait to get the gap filled…
They are anxious to start learning to use UE4, but not wanting to have to go the deep dive just yet into the C++ (which is currently a huge pile of mess…)

My suggestion for them and myself is:
Start learning what you can about the Blueprints and experiment a lot - by doing so, we would get comfortable and familiar with the API. This would take many months anyways, and by that time, hopefully, there would be language-bindings for one of your preferred managed-languages, and perhaps even a better build-story for C++, with more/better starter-projects (for plugins and other use-cases) and perhaps even a wizard/GUI-tool for managing build-definitions, as well as faster compile-times and/or a more fully-featured “live-reloads” story… (Hell, we might even get IntelliSense working for us…)
Maybe Epic-engineers would even jump-the-wagon at some-point and go for re-factoring much of their macros into more powerful and concise templates, using some of the new C++14 features in the next VS release… (Dream…)

In general, though, I think learning the API and the event-model is going to be beneficial down the line anyways, as it is going to be useful for whatever language one may ultimately choose to use to develop UE4 games with (of which there are bound to be plenty in years to come…)

And remember - these are STILL very early-days for UE4 - Things WILL get better for in the years to come - I have no doubt!

Cheers!
:slight_smile:

[=EruArnold;103107]
I have spent the past couple of days reading through this very long, sometimes-interesting, and mostly-tedious thread, and would like to share a summary of what I see.
*( For the record, I know C++, C# and Python, and have experience using all 3 and more )
*

I just started watching a course I bought from 3DBuzz, about developing plugins for UE4, and was thoroughly-horrified…
:slight_smile:
[/]

Not sure that bashing C++ in UE4 is justified when you look at development specifically. From what I gathered, it’s still very much a work in progress. To develop your game you don’t need to develop your own plugins.

Or in other words, if the engine was developed in C# that doesn’t mean that development would necessarily be so much easier. It could still be a mess.

Intellisense not working is mostly an issue of Visual unable to handle a huge code base like that. VisualAssist does a much better job.

I vote to have this thread locked. answered it. It’s just a waste of internet ink now.

[=Bino;103156]
I vote to have this thread locked. answered it. It’s just a waste of internet ink now.
[/]

But where would we then get our drama from? Soap operas on TV just won’t do.
In any case, to add my two Zimbabwean dollars for those who feel intimidated by C++, hang in there baby, it’s just a programming RPG - just keep playing, you will eventually level up.

[=EruArnold;103107]
…
[/]

Actually, to the intellisense part - it works for me, raise the number in VS which is responsible for the limit of memory used by intellisense.

To the c++ part, actually I didn’t have problems yet, I was using the old engine (udk) a lot, so I’ve got experience with UScript too,and I must say that, if you know the api, c++ is not so much difference.

To the compile times, yep they are pretty long, but if you’ve got a decent pc it’s not that long, and epic is working on compile times so you can expect it to be better in the near future.

[=EruArnold;103107]

I just started watching a course I bought from 3DBuzz, about developing plugins for UE4, and was thoroughly-horrified…
They spend the first HOUR AND A HALF, about 25% of the entire course, just composing the most basic of scaffolds…
It involves a huge-mess of stuff:

  1. A very complex folder-hierarchy that one MUST manually create and maintain (doing things from within visual- brakes everything and it doesn’t work)
  2. A custom file that is used to be a manifest, which you MUST manually create and fill-out, with tons of cryptic data.
  3. A custom C# file that is ONLY used to guide their custom build-tooling - and again, you can’t use VS properly for managing that, as it needs to be injected into a solution-file that UE itself needs to re-generate.
  4. Tons of headers you must #include, that must manually-match the ones you already noted in your C# file.
  5. IntelliSense doesn’t even work - not for the MANDATORY C# file, and not even later for the C++ code - it CONSTANTLY brakes-down, as well as having tons of “squiggly” lines all-over the place, because VS can’t reason-about the solution, since the entire reference-mechanism is heavily-macro’ed and relies on an external custom build-tool. So, you CAN’T see you mistakes (as you can’t trust non-squiggly-lines) AND you don’t have IntelliSense at all AND you have to re-compile all the time AND it takes a lot of time each time you do, which would more-often-then-not result in it eventually failing, and giving you errors…
    They actually had to stop the video when compiling, and fix things on-camera when it’s done trying to compile, and do so without any help from VS, which resulted in them having to go through ~7 cycles of such non-sense in a row, just to get a foot in the door of UE4 ans seeing their show-up…

[/]

To add more to the drama.
I completely disagree with all this. Visual was never good for C++ to begin with, Intellisense for C++ was always sloppy at best. And huge code bases (regardless of software type), are always bringing visual to it’s knees.

Custom Build Tool-Chain is here to allow easy portability between platform, to build naively on the platform you happen to develop your game.

Is the Build Tool Chain very easy to use ? No. Is it hard. You must have never used make, if you think that UBT is nightmare (;.
For added benefit os portability, I could even use make, if I had to.

I honestly don’t see where you have problem. Or Unreal Engine is the first game engine you had work with, using C++.
I can tell, it’s easiest to use from engines I have used so far.

As a side note. I find C++ in UE4 much more confotable to use than UnrealScript in UDK.
I can honestly say, I could never get anything done in US ;).

[=;103564]

I honestly don’t see where you have problem. Or Unreal Engine is the first game engine you had work with, using C++.
I can tell, it’s easiest to use from engines I have used so far.

As a side note. I find C++ in UE4 much more confotable to use than UnrealScript in UDK.
I can honestly say, I could never get anything done in US ;).
[/]

I have to agree with inside on this one. Since using UE4, I have only worked on the C++, I rarely use blueprints (except for my 2D game, and that was an experiment to only use blueprints, I much prefer the C++ side) except to prototype some basic functionality before I write it up in C++.

Just to mention C/C++ compilers are more than 30 years old and are very highly optimized!
Why would you develop a game and graphics stuff in javascript/C# or in any other language that is not as highly optimized as a compiler?
Also if you use some good practices developing in c++ is not memory management.
Both C# and c++ has their disadvantages but if you need more power you will decide to use c++.

[=;103668]
Just to mention C/C++ compilers are more than 30 years old and are very highly optimized!
Why would you develop a game and graphics stuff in javascript/C# or in any other language that is not as highly optimized as a compiler?

[/]

Modern optimizing JIT compilers like Java’s HotSpot and LuaJIT offer performance that can often match or even beat statically compiled code. Add to that no waiting for compiles and live in-game debugging tools that scripting languages can offer and scripting languages often make sense for development.

Not every game needs AAA FPS type performance. Do you think a game like should be written in C++?

[]

Also if you use some good practices developing in c++ is not memory management.
Both C# and c++ has their disadvantages but if you need more power you will decide to use c++.
[/]

A good software developer should have many tools in his toolbox and know how and when to use each.

[=;103564]
To add more to the drama.
I completely disagree with all this. Visual was never good for C++ to begin with, Intellisense for C++ was always sloppy at best. And huge code bases (regardless of software type), are always bringing visual to it’s knees…
[/]

I think this is important for many to understand, one can find complaints about this on other frameworks going back some time. For Epic’s sake, sometimes feel as if this particular issue is directed wrongly at them. Otherwise…

Seems like there are plenty of arguments to go around no matter which side you prefer. I have my preference and it’s not C++, but what’s the point of complaining if we are using UE4? It’s not like programming games is easy in any language. If those here are looking to build in UE4, then C++ is what you have and blueprints which IMHO are about as innovative and advanced as it gets. There was some talk from some developers about adding more language interfaces, I’d recommend finding those threads for those who are interested to lend support and suggestions since the debate over languages will never be settled. In an effort to be neutral on the subject, there are probably better outlets in helping to add new features than an attempt to change another’s opinion.

Could be that this thread may have a happier home under General? Maybe it’s more fitting in this group, but this is a topic that generates more anger than being informative.

[=jCoder;103692]

Not every game needs AAA FPS type performance. Do you think a game like should be written in C++?

[/]

Well 10-15 years ago a style game was written in c, for a good reason.

[=jCoder;103692]

A good software developer should have many tools in his toolbox and know how and when to use each.

[/]

It’s true but if youre making a game that must run on any device and it needs the best performance you may consider to write it in c or java.
But it’s your choice what language you use. I prefer to write my things in C++ or C#.

[=jCoder;103692]

Modern optimizing JIT compilers like Java’s HotSpot and LuaJIT offer performance that can often match or even beat statically compiled code. Add to that no waiting for compiles and live in-game debugging tools that scripting languages can offer and scripting languages often make sense for development.

[/]

Eh?

[=;103668]
Just to mention C/C++ compilers are more than 30 years old and are very highly optimized!
Why would you develop a game and graphics stuff in javascript/C# or in any other language that is not as highly optimized as a compiler?
[/]

Did you even read the thread? Performance has been discussed to death already, and wasn’t even one of the reasons Sweeney cited.

[=;103719]
Well 10-15 years ago a style game was written in c, for a good reason.
[/]

The last I checked, it’s not 10 or 15 years ago.

All I’m really waiting for is for JetBrains (who do absolutely fantastic IDE’s and Plugins) to finish working on their C++ IDE, and for Epic to allow us to generate MAKE files for different IDE’s. In the meantime, if you have VSPro, you can buy a great called Visual Assist X from WholeTomato. It certainly offsets the pain a little.

[=furrykef;103722]

The last I checked, it’s not 10 or 15 years ago.
[/]

If by that you mean to say that was written in C++, you’re wrong. It was done entirely in blueprint.

Stop crying and get to work. Seriously.

“Why C++ for Unreal 4?” - Why are you crying? If you don’t like it, fix it or use something else.

Unreal Engine 4 is one of the best engines and a Engines with all possibilities that we have to day needs c++.

And by the way… for game programers is c++ one of the main languages what you learn at the universitiy.

So if you want create a game just4fun… you don’t need the unreal engine 4 or you use blueprints… more then easy as unreal script :wink:

I don’t see any problem with the engine’s C++. Honestly, C++ is a fact of life in professional grade game dev. At some point or other you will need that level of access and performance. Do you always? No. But when you do it needs to be there, or it potentially means grinding your entire project to a halt, because without that access you have zero capability to get it fixed yourself, and are totally at the mercy of the engine developers fixing what might amount to a very specific problem.

Experienced devs will understand why that’s not something they even want to touch.

Further I don’t really see the problem with the split between BP and C++. If you need more BP functionality - expose it via C++. If it’s too slow in BP, same thing, etc. That’s not really an unusual paradigm for any engine - almost all of them feature some sort of scripting functionality which must have underlying engine code exposed to it. It’s the same thing here.

If you want some specific scripting language for another reason, there’s facility for doing that via plugins.

I agree that most language-debates are futile, but I am frustrated that most people here don’t even understand what is being debated here, and mistakenly think this is a language-debate - it is not.

Let me say it loud and clear so people won’t have the slightest chance of continuing to misunderstand:
“Unreal Engine 4 - like ANY modern game engine - MUST have been programmed in C++ (!!!)”
No one in their right-mind would fathom coding something of this magnitude and quality in any other language! (at least not yet…)
THAT IS NOT WHAT IS BEING ARGUED HERE, SO EVERYBODY PLEASE STOP REACTING AS IF IT IS!!!

What IS being argued, is something entirely different - “What should be the ideal way of coding GAME-LOGIC?” (!!!)

Let me give some analogies:
Networking-code is very difficult to do right (by “right” I mean fast, efficient and flexible).
So some smart people got together and coded a library called Zero-MQ (a.k.a: zmq, or 0mq), which implements the lower-levels of networking-code in an extremely optimized way, and exposes a pretty high-level API for system-engineers to be able to build whatever network-topologies they could even need (publish/subscribe, request/response, in-process, inter-process, etc.). After they had done so, many developers started to use it (by “use” I mean, “build-upon”), instead of starting from scratch and implementing lover-levels themselves. What’s the benefit? You get many man-hours of development and many years of experience, already coded-in for you so you don’t have to go through the pain of making all the past-mistakes all over again. Now, since it is C++, it is VERY fast always, and also very easy to “be wrapped” and “bounded-into” other languages. Nowadays, there are upwards of 40 different languages binding to it! 40!!! All the way to the “slowest” ones like Python and Ruby… And applications using it in these last 2 languages are, guess what, “every bit as fast as systems coded in C++ that are using it” (!), at least in terms of networking-performance and resiliency/stability. The idea is not new at all - the execution still happens at C++ native-speeds, but the input/output of the execution is routed to another language - whatever it may be.

This is how you get the best of both worlds.

I recently had performance issues with a server I was developing in Python, and I ended up solving it by using PyZMQ, which is a thin-layer of python around a ZMQ C++ compiled core. I went one step further, and optimized the encoding/decoding process by using another such solution, called Messagepack (a.k.a: msgpck). There is another example of such arrangement - you got a highly-optimized very target-focused library that does one thing and does it well, and you got thing-layered wrappers around it, that “binds” it to other languages (last I checks, msgpack had around 17 language-bindings) - it’s fast, it’s efficient, it’s easy-to-use, even when you are using it from a “slow” language.

Other examples may include:

  • simplejson - A Python package, that is a C-extention - is also C++ code compiled to efficiently decode/encode formatted text, and wrapped in a thin layer of Python.
  • The Qt UI-Toolkit - Python has 2 binding-packages (PySide and PyQt) that are equally as performant as their C++ counterparts, because guess what - THEY ARE THE SAME CODE COMPILED IN C++ UNDERNEATH, AS ONE WOULD USE FROM A C++ APPLICATION(!)
    …
    (I could go on forever with such examples…)

Now, imagine people in the ZeroMQ forums, or the Qt forums, arguing about why it was good that the library was “written” in C++ and not Python…
Then you would get how I feel when reading such posts here…
Can you see where the confusion lies? Can you see why I am saying that “…this is not what is being argued here”?
It’s a total misunderstanding of the entire story.

It’s NOT about what langue to “write” a game-engine, it is about what other languages it should be “bound-to” (!!!) HUGE DIFFERENCE (!!!)

I ended-up being able to code my server in Python (using ZMQ and msgpack), in a FRACTION of the amount of code and in a FRACTION of the time it would have taken me to do in C++ (using the same libraries without the binding-layer), and guess what - IT IS SCREAMING FAST (!!!) EVERY-BIT AS IT WOULD HAVE BEEN CODED IN C++ (!!)

So, I say again - and please get it through your skulls already:
It’s NOT about what langue to “write” a game-engine, it is about what other languages it should be “bound-to” (!!!)

95% of game-logic code is non-performance-critical (at the very least) - most-if-not-all of the code that IS performance-critical, has already been coded in C++ by Epic… Physics, collision-detection, rendering, particles, path-finding… Even AI stuff is on the way and will get better GUIs…

Most of game-logic is a huge pile of “glue-code” to put-together these awesome already-performance-optimized systems in all sorts of new and exciting ways - the essence, if you will, of the game-play.
And NO, you DO NOT need C++ to write glue-code - there are MANY languages which are leaps and bounds superior FOR THAT TASK(!) then C++, no way around that, it’s just a fact.
And NO, for 95% of it is just NOT performance-critical by itself - you would NOT notice it AT-ALL, even if you REALLY-TRY with advanced profiling-tools…
It is just a clever use of resources, and much more efficient and pragmatic to do that - it is simply silly not to…

And just one note to finish this up:
Epic engineers themselves has already stated on multiple occasions (I can provide references…), that “compiled” Blueprings are roughly 10X “S-L-O-W-E-R” (!!!) then coding the same in pure C++(!) Why? Because of the way their data-model is designed: To fit a Node-Based GUI. They are NOT (I repeat “NOT”(!)) “compiled” down to C++ native code(!) They are compiled to a binary format that is then (wait for it…) “INTERPRETED” (yes, you read it correctly…) by the UE4 run-time… And guess what - NOBODY NOTICES(!) You know why? Because it DOESN’T MATTER(!!!) It is non-performance-critical pieces of logic, that use otherwise “idle” cpu-cycles (for the most part…). NOW I want somebody to tell me why this same thing can-not be accomplished by a X2 (or even X3) “slower” programming-language run-time such as C#, or (god-forbid…) Python…

There is simply NO reason whatsoever…
Absolutely no reason, and some people already understood that and are working to fix the situation - please support them in any way you can, and stop posting BS posts about irrelevant-arguments that are not even being made…

[=EruArnold;103892]
It’s NOT about what langue to “write” a game-engine, it is about what other languages it should be “bound-to” (!!!) HUGE DIFFERENCE (!!!)
[/]

So, then use a to provide a different binding?

[]
Epic engineers themselves has already stated on multiple occasions (I can provide references…), that “compiled” Blueprings are roughly 10X “S-L-O-W-E-R” (!!!) then coding the same in pure C++(!)
[/]

That doesn’t jive with you saying it needs to have other bindings - most scripting languages are even slower than 10x less than C++. By a lot.