Why C++ for Unreal 4?

Hi All.

I too am familiar with BASIC and FORTRAN…gawds I hate that language. haha!!

I have been watching this topic as well as watched the two above vids…thank you by the way.

Since it has been brought to the front as a C++ Hybrid or more Elegant Language…I will have to say that NWScript is basically that language. Very powerful, elegant, easy to figure out and use. Looks like C/C++ in format. There is even a Lexicon for all the internal functions and descriptions. How the scripting language actually functions between the lines is the development to speak with memory and game specifics. If anyone has programmed in NWScript will know that productivity is extremely high…and if we were allowed to access more of the ‘Internal’ BioWare Aurora engine specifics the language could have been even better. I still enjoy programming in it.

As for UE4 I would be a huge advocate for a Middleware that has commonality to NWScript that makes thing simple for all sorts of UE4 uses.

**I did this to a large extent in Unity but in C#

For any curious programmers :slight_smile: NWN Lexicon

Some of the craziness in this forum topic is just silly, however, I have very much enjoyed watching this and reading 's opinions. I agree on both fronts on this.

Thanks!
K

@Krixa

Don’t forget UDK/UE3 was build around a script language called UnrealScript. There are many reasons why they removed this UScript from UE4.
Seems for some of the guys, C++ is not enough and want to bring in lots of obscure scripts languages, for the sake of “elegant” coding reason. Absurd… totally absurd.

[=EruArnold;156483]

So, seems like even Modern C++ is the “middle-man” that no one likes - it takes too much and returns very little benefits…
Too slow for game-engines, too unproductive for scripting game-logic.
[/]

C/C+ is not here for games, and was not made only for games dev. And is fast enough, if you want the ONLY fastest route over C/C++, go ASM and good luck with that finishing a game/application.

[=TDoro;156788]
@Krixa
C/C+ is not here for games, and was not made only for games dev. And is fast enough, if you want the ONLY fastest route over C/C++, go ASM and good luck with that finishing a game/application.
[/]

I was paraphrasing the cppcon talk above, and in it’s context.
I was not making a general statement - I agree that that would be silly…

At least from the perspective of the speaker in that talk, he basically only uses C-level features out of C++, and combines that with some ASM that he writes manually - you should really watch this talk, it’s quite different then most other conference-talks I have seen of late. He states up-front right at the beginning of the talk that writing in ASM exclusively is not an option, for obvious reasons that we all know. The question is thus, could there be a more ‘modern’ version of C that can replace C++ for game-engine writing. My guess is that this is starting to happen, with promising contenders like D and Rust. Just in terms of compile-time, nothing nowadays beets D as far as I know, and I think both D and Rust have support for in-line ASM block, so they just seem like a much better fit for next-gen game-engines.

But the reason I brought it up, is because I am learning ‘Modern’ C++ these days, and UE4 is the only game-engine that I know of that supports it (binary-compatible, due to it being developed and compiled in MSVC of VS2013), and I was really disappointed to discover that game-engines generally don’t use any high-level C++ language features, on the count of them being ‘too slow’… For example, I would have liked to see much less wide-spread reliance on ‘macros’, as they are not type-safe and are very difficult to debug (plus, most intellisesnse don’t work with them correctly, don’t auto-completes them, etc.). So, if you’re coding against a ‘practically C’ API, what’s the point of it supporting ‘Modern C++’? It makes it look like ‘vaporware’ - a false-promise on behalf of Epic… Sure, you ‘could’ use templates and such in your own code, and that’s cool and all, but it’s one thing to ‘consume’, say, the STL, but it’s quite another to consume a game-engine library/API that is written using templates (which it seems most game-engines don’t, including UE4). So, you also ‘could’ write your own templates and build your own library, but that is way overkill for what you ‘should’ be expected to do… Templates are for library-authors and API designers - the likes of the people who write game-engines - it is NOT intended (or rather shouldn’t be considered to be intended) for game-designers and game-logic coders. One would expect a Modern C++ game-engine to provide with high-level abstractions that are conveniently consumable by anyone wanting to code game-logic against that game-engine, and iterate on design-ideas quickly. Alas, it seems these high-level productivity-enhancing features of Modern C++ are too expensive for game-engine to design their APIs around, and the only thing that shields a game-developer from having to interface with a game-engines “C like” API (type-unsafe, leaky/dangerous, etc.), are a slew of ‘macros’ that are very unproductive to work with… This just comes as a very grossly unfortunate predicament for the games-industry, and I think that most game-developers know this reality and it’s frustration very well - which comes with sharp contrast to what ‘C++ Zealots’ (like here and others) are preaching to themselves and others…

The situation is much less rosy than the way it is being presented, and it just makes the whole story seem very disingenuous - is my general point.

[=EruArnold;157830]
So, if you’re coding against a ‘practically C’ API, what’s the point of it supporting ‘Modern C++’? It makes it look like ‘vaporware’ - a false-promise on behalf of Epic…

The situation is much less rosy than the way it is being presented, and it just makes the whole story seem very disingenuous - is my general point.
[/]

While I agree it may not be as nice, I don’t consider it a false promise and I appreciate what Epic has provided. If Epic used all “Modern C++” the engine and compilation would be slower, which would mean less effects that could be supported, less actors, less detail, slower speed, etc. The whole reason modern game engines use C style with some C++ is because it is faster. Bottom line.

C style isn’t really bad at all. In some cases I prefer it for it’s speed, macro’s are iffy though, lol, but they are used as a neat hack for the editor as well. In programming you use whatever you have to, to achieve your goal reasonably well. A game engines goal is to push as much data as it can through the CPU and GPU, and if you’re talking about speed you’re talking about C. C++ in quite a few cases can get just as fast, but not everywhere. The C++ standard libraries are developed to be as fast as they can for general programming, but not all of them are fast enough for game programming (or at least engine programming). The D language is the only language which looks like it has a hope of competing in the future, but they have to straighten out their memory management.

To a decent programmer, it doesn’t matter if the language is C, C++, ASM, D, C#, Java, Perl, PHP, Python, JavaScript, Ruby, etc, they can make it work. Some have some nicer features and make things a little easier, but when it comes to good engines and games you have to expect it’s going to take professional level work.

I don’t say it’s a false promise when they say that you can “Quickly create a wide range of surfaces that hold up visually under close examination…”, and I try it out and find out that the tool is complex. Of course it’s complex for me, I’m not an artist. I can’t expect a drag and drop scene with just a few clicks and sliders and all of the sudden I have an amazing scene. Nice games with a lot of detail and powerful technology are complex, it’s just part of the job.

One can program in C++ in a wide range of styles, covering procedural, object orientated and then some things living in spheres mere humans might write but not really understand anytime soon again aftwards (worse if someone else wrote it). Template metaprogramming is on the verge of beeing unreadable (can only talk about me. Heres the chance to let everybody know what a superporgrammer one is and thats really easy to do. lol), so Im quite happy UE4s codebase doesnt look like WebKit :wink:

Thanks for the links EruArnold, even if they arnt directly on topic I still think they are very useful for programmers. I know Im constantly complaining about the complexities of C++, that there are too many nuances and that more global scope standards are better. I see far too often in C++ people breaking their own rules, not sticking to the standards set by the API they are interfacing with let alone the standards set by the language itself, I know its a powerful language but as they say with great power comes great responsibility. For me, I dont want that responsibility, I do want to be able to create DataTypes but I dont want to require a degree in quantum thermodynamics to be able to do it, I love auto-initialization, I love auto-exposing variables in a manner that allows WYSIWYG editing, there are a whole host of things that are great about Epic’s API that arnt directly related to C++ such as Garbage Collection. I do appreciate some people want the performance end but Im sick of having to write so many extra lines because one of these watch makers decided that IntVector shouldnt be used with UPROPERTY, I think that people who want those things should be the ones who have to do the extra defining, to remove the layers they dont need rather than me piling them on, especially since my goal is to work with Epics API first and foremost not with the core C++ language or any other libraries.

One example Ive used recently is this, to expose a variable to the editor in UScript:

Var() int ThisX;

in C++ with Epic’s Headers:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “”)
int32 ThisX;

Now I know different platforms can have different sizes for int and whatnot, I know that complexity exists but I really dont care about it, Im not asking for people to not have that level of access just stating that I really dont need it, I never have, not even back modding Quake, all the way up and till now and in the future. I like blueprint because it hides some of the complexity but it really isnt a replacement for UScript, the only way to get that type of level is to do C++ but then you have to take all the complexity that comes with the entire C++ language ontop of the API and interop complexities ontop of that. Epic have done a really good job with what they have to work with, there are some amazing mathematicians/programmers working at Epic but we cannot ignore the fact that we need to get simpler tools into the hands of designers so that programmers can focus on Engine level code and that is why Blueprint exists. My issue is that Im being told that I should use C++ for any serious programming when in all honesty alot of what I do in Blueprint could be converted into C++ text by the editor and then compiled out, if that is too complex to happen, if machines have trouble writing C++ then you can sure as hell think humans would too. I must admit, the core C, when its stripped down and used as in GLSL for example, Nvidia have some great examples too of some really solid math libraries, unfortunately Epic’s maths libraries are overshadowed by the other complexities.

Basically the gist of it is that people using Blueprint shouldnt be treated as second class citizens, that C++ is useful but it should be used sparsely and effectively, especially to expand the abilities of Blueprint.

Thanks again for the links :cool:

, Node.js has struck a nice balance that would work well in a game dev platform. When you have at least a clue about both languages and how the platform itself works, there are things you would never want to do with one that you should do with the other. The key to keeping your scripting platform from getting twisted with all of your lower-level performance critical stuff, is to split the two across an event loop with the one on top being a language that only executes one function at a time. That maintains the distinction that things like thread management and lower-level performance critical tasks are not the scripting language’s job.

Node.js, like JavaScript ? I wouldn’t unleash JavaScript on my worst enemy. Not to say about normal people.

I have not read the entire thread but saw references to D and Rust. I’m curious if there are any technical reasons that those languages can’t be used with UE more or less out of the box?

Can’t you call C/C++ functions from Rust/D?

Can you compile UE assets using UE tools, then compile your Rust code using Rust compiler and then link the two binaries?

Guess this is common knowledge now, but…

Unity users can program in C#, JavaScript, or Boo. The development environment runs on Mono, an open source version of the .NET Framework.

Unity itself is written in C++.

“The code that has to run super-fast like the physics and animation, all that is C++, but the code that should be easy to write, you can write in .NET.”

(Cite from Helgason, one of Unity’s pioneers.)

Hey guys, sorry to necromance this thread, but I have some questions:

First I wanna say that I’d really love to replace the current engine I’m using (Unity) with UE4, not only because of the features but also cause of opensauce. I however simply can’t start doing the things I do in Unity quickly. I admit that part of the problem is because I don’t know the API very well but I’ve been hitting wall after wall because of C++, mostly because of the kind of nonsense seen in that Scott Meyers video (assuming things should work consistently while there are exceptions for every case).

I know that Mono is full of licensing nonsense (that’s the reason why Unity still uses a methuselanic version), and I don’t like Mono very much personally, mostly because of performance, although it’s orders of magnitude better in recent versions, is not very good compared to JVMs(hotspot/openjdk’s) or MS’s CLR.

That however brings me to the actual question: Recently MS opensourced their CLR (CoreCLR, incl. JIT/GC/etc) along with mscorlibs and msbuild. Everything was released under the very permissive HIT license. There are efforts to port all of that to a cornucopia of different platforms, and I’m sure it’s not gonna take too long to have them up and running at least on the main platforms and architectures out there (Win/Mac/Lin - x86/ARM).

I wonder if there’s any interest, perhaps not officially, in creating something (perhaps a ) that allows you to code in the good ole C# using that newly open technology… since both are opensource I think eventually something will pop out, I’d like to hear different povs on the subject.

Personally, I’m very excited about the opensourcing of MS’s CLR. It’s soooo fast and memory efficient :). I’m sure good things are coming soon. (Unless there’s something shady I’m not aware of, like something fundamental that’s missing :stuck_out_tongue: ).

Well you could start new thread instead of resurrecting this hell :stuck_out_tongue:

There is consistent interest in C#, there some project poping in and one, one of them got cancelled due to some UE4 EULA issues… but i don’t remember names of those projects ^^’ just search in forums you should find it.

Also what exact walls you hitting in C++? You know C# in UE4 will not be much different in terms of APIs, or else creator of implementation will go some crazy route

I want to put my 2 cents in and I am sure that I am just restating what some one has already stated. Unity only uses C# for scripting which in my opinion is better, however just like someone stated Unity is programmed in C++ which is the language of choice in high end game engines. Can you make a game engine in VB and or C#? yes but it will not be on the same level. C++ isn’t really that hard to learn, or at least enough to work with Unreal.

To use UE4 well, as a C# scripter, all you need to become comfortable with are dealing with pointers/references + minor syntax:
(learn when and why you should use “obj", "obj”, “obj&”, etc; learn when and why you use “::”, “:”, “.” or “->” while in C# every access is just “.”)
Close to anything else inside of UE4’s C++, which is different from regular C++, is just a matter of reading docs, Answers.com and accumulating experience.

[=;396512]
Well you could start new thread instead of resurrecting this hell :stuck_out_tongue:

There is consistent interest in C#, there some project poping in and one, one of them got cancelled due to some UE4 EULA issues… but i don’t remember names of those projects ^^’ just search in forums you should find it.

Also what exact walls you hitting in C++? You know C# in UE4 will not be much different in terms of APIs, or else creator of implementation will go some crazy route
[/]

The problem is not only that I’m not very used to what said, but also the kind of nonsense in that video. I don’t aim to be a full-time specialized programmer, so perhaps that’s why I’m not very happy with C++. The fact is, as a solo developer, I found in Unity the best ‘overall game designer’ experience. It’s easy for one person to accomplish all the tasks needed to put a game together, like scripting, importing models (I model in Blender these days, and they are imported much more nicely than UE4), configuring settings like texture compression for your assets, some basic level editing (although I don’t like it personally), and to do all of that I don’t need a specialization in all these areas. The ‘advanced’ topics I learned was mostly by experience and for necessity.

Unreal unfortunately is not that friendly, perhaps for a small team, say, at least 3 (programmer, artist, designer), the experience is good, but as a single developer I’m sorry but it’s overwhelming.

[=BIrvin;396672]
I want to put my 2 cents in and I am sure that I am just restating what some one has already stated. Unity only uses C# for scripting which in my opinion is better, however just like someone stated Unity is programmed in C++ which is the language of choice in high end game engines. Can you make a game engine in VB and or C#? yes but it will not be on the same level. C++ isn’t really that hard to learn, or at least enough to work with Unreal.
[/]

I don’t agree… Unity is a high performance C++ engine with C# scripting, and as I said, Mono really sucks in Unity, but still, it’s somewhat the best of both worlds. I’m very sure that since MS opensourced their CLR, we are going to see some quite good pure-C# engines/frameworks pretty soon. My guess is C++ still rules because of the inertia in the industry. It’s faster, yes, but if you really needed that extra speed you won’t be using a general purpose engine at all.

[=;408270]
The problem is not only that I’m not very used to what said, but also the kind of nonsense in that video. I don’t aim to be a full-time specialized programmer, so perhaps that’s why I’m not very happy with C++. The fact is, as a solo developer, I found in Unity the best ‘overall game designer’ experience.

[/]

In that case it would make sense for you to switch back to unity.
If you could handle C#, you should be able to handle C++ in Unreal as well, because you don’t NEED advanced features here and there are facilities in place to make your life easier. Failing that, there are blueprints.

[=NegInfinity;408295]
In that case it would make sense for you to switch back to unity.
If you could handle C#, you should be able to handle C++ in Unreal as well, because you don’t NEED advanced features here and there are facilities in place to make your life easier. Failing that, there are blueprints.
[/]

I hear people saying that all the time, but so far I didn’t actually find anything (guide/tutorial or docs) that doesn’t make me feel I’m going backwards in terms of technology.

If you were able to learn basic C# you can learn enough C++ to do UE in a very short time. It’s pretty trivial and lots of help and information is available. The UE framework itself is far more difficult to comprehend and that wouldn’t change regardless of what language it used.

If you’re comfortable limiting yourself to last-gen stuff then Unity is fine for your needs.

Since you’ve resurrected this dead horse, I will beat it again by saying that if you are gonna try UE4, you should give Blueprints a chance; you will be genuinely surprised how much you do not need code. BPs are more or less a visual wrapper of UnrealScript…writing BPs IS writing code!

[=bleeds187;408555]
Since you’ve resurrected this dead horse, I will beat it again by saying that if you are gonna try UE4, you should give Blueprints a chance; you will be genuinely surprised how much you do not need code. BPs are more or less a visual wrapper of UnrealScript…writing BPs IS writing code!
[/]

Too bad you can’t compile a out of blueprints. :slight_smile: