Why C++ for Unreal 4?

[=;19802]
Gratz. You pretty much described every possible programming language in existence. Maybe with exception of assembler. (;.
[/]

I am programmer since ZX81 times, I know every programming language is about same, you just use different keywords, every loop is mutation of checking condition and jump (because how assembler works).
And everything gets to asm level soon or later.

And blueprints are best invention since sliced bread. Really! Editor slapping my wrists when i try multiply text string by 5 is something that helps to learn faster.

edit:
I had not enough of force in me to learn unreal script, but now its totally different story with unreal 4

also ++! to this:

[=MC ;22111]
as a starting point, stick with the Blueprints and good luck :wink:
[/]

I found this thread by coindence. Though I am a game server programmer, I have ideas about this thread.

Here is a score starting from zero. I will increase value to the score for oppotunity of using C++, or decrease it for drawback of using C++.

C++ is faster: +10. It is known that C++ is not so faster than script language, because script runtime has optimized JIT/AOT compiler. (However, in average, C++ is 30~70% faster in my experience.) Processing game logic takes <20% of total time so scripting is enough. But in engine core world, C++ is mandatory because of the incomparable speed. For example, P/Invoke for complex parameters of Direct3D render state functions is a hell.
So far, the score is 10.

C++ is harder to develop: -100. Although the most language I still use is C++, it is devil’s language. It disappears some of programmer’s life. C++ has no reflection functionality, cumbersome for accessing metadata of data types, awkard smart pointers. Lambda expression? Get lost. C++11 is just following other languages. C++ programmers does not need Pomodoro Technique. Executing compilation itself is five minute rest. C++ with boost library is lacks compared to C# basic library.
So far, the score is -90.

C++ makes no frame rate hiccup: +10. Realtime apps such as games treats frame rate as important, as well as its equality. Script languages is followed by garbage collection aka. GC. For example, Java and C# GC runs in stop-the-world manner, which consequences frame rate hiccup. (A disgression: A game server processes many players, but does not for rendering. So game logic processing takes major time in server. Stop-the-world by GC itself causes latency hiccup, so that is why game server for latency-sensitive games are written most in C++.)
So far, -80.

C++ has no clue between different languages: +50. Developing a game program whose goal is high and wide sometimes encounters limit of script language. For example, there is a need to import C++ auxiliary module. Once this situation occurs, a clue code between two different languages is unavoidable, and this is a sh** to performance and maintanance. Those who worked with P/Invoke, C++/CLI or UnrealScript Native Binding will understand what I mean. Due to its bottleneck, it even affects program design. For resolving this problem from the scratch, engine itself should be written in C++, but the train has already left.
So far, -30.

Script has thicker layer: +10 for small projects, +100 for larger projects. Thickness of layer is a double-edged sword. We have no way but to wait until people who treat other layers resolve the problem. The more layer thick, the longer to find the cause of the problem. Let me show one example. One of game engines affords C# script environment, and its base is Mono. We found that BeginSend() in iPhone4 affects frame rate seriously. We looked in the source code of Mono and found that its base was implemented in very alternative way to meet up to the requirement of Microsoft .Net framework implementation, but it works not so nicely. Nevertheless, people developing Mono are magician. For the workaround, we chose other way not to use BeginSend() but it throws many System.Exception, but it is even faster. The root resolution is to modify Mono by ourselves and contribute it to Mono community, but it would have taken much more days. Thicker layer gives efficiency to development for earlier stages, but it sometimes conceals problems, but it appears more annoyingly on later stages. Needless to say that thicker layer takes more memory, which sometimes crucial on mobile devices. In short, thinner layer is like a insurance.
So far, -20 for small projects or +70 for larger projects.

Conclusion: Anyway, negative score for small projects :slight_smile: (What am I speaking?) In overall, C++ has pros than cons for commercial development projects.

[=Devlin Kain;15318]
I was just curious, why did Unreal 4 decide to go with C++? I know Unity is in C#, and a lot of other games utilize C# as well as javascript. I was just curious, new programmer on engines here, only about a year and a half/2 years in, so go easy!

Dev
[/]

C# only runs in the .Net framework (Windows) and C++ runs on all operating systems. C++ runs better and you can do more with it than C#. Overall C++ is better than C#.

[=trdwll;23389]
C# only runs in the .Net framework (Windows) and C++ runs on all operating systems. C++ runs better and you can do more with it than C#. Overall C++ is better than C#.
[/]

That’s wrong. It doesn’t need .Net. You can use for example mono and run it on whatever you like.

[=;23534]
That’s wrong. It doesn’t need .Net. You can use for example mono and run it on whatever you like.
[/]

If i were EPIC, and i would need to implement a scripting program, i would add something like Python or Java instead of C#

[=vblanco;23539]
If i were EPIC, and i would need to implement a scripting program, i would add something like Python or Java instead of C#
[/]

I never said I want c# , actually, in my opinion there isn’t really a need for a scripting language as we have blueprints. And as we have c++, if someone really wants/needs it, he can implement it himself. My workflow for example got much faster in comparison to unrealscript with the change to c++ and blueprints.

[=MC ;22111]

(…Blank Stare…) You’re kidding me right?! I don’t think you even understand what you just said. Now all joking aside, if you are referring to how the dev environment is setup, you can change it so that C# is not your default dev environment in VS and C++ is. If that’s not what you meant, then you aren’t making any sense as C#'s integration into VS doesn’t have any affect on the IDE in a negative way or in any if you are coding in C++. You do realize there is option when you install to ā€œNot install Visual C#ā€ā€¦ when you install Visual ?

[/]

He meant that new versions of VS are .NET applications and now it is much slower (intellisense…) and uses much more CPU and RAM compared to VS 2008 that was a C++ app.


I hate C#, nice language design but vendor lock-in into MS world (don’t come with mono). The last place you want to be as a programmer (with a future). In the (big) business world it is mostly Java except in the USA where MS used their money to promote C# (paying schools and giving ā€œgoodā€ deals to companies). And Java wins any benchmarks I know (by a wide margin).

But for game scripting there are better alternatives (LUA, AngelScript, Python,…). I did my own engine coding in C++, but still added a scripting layer. It’s about productivity, use the right tool for each job.

I’m sure many AAA epic customers still add a scripting layer. You don’t do all gameplay logic in the scripting layer, but for certain event based (so not per frame) things it is just more productive to have that layer.

It is smart of epic to not add a scripting layer, because prefers another scripting language. And with the C++ API many different bindings will be created by the users anyway.

[=nettention;23362]
Lambda expression? Get lost.
[/]

That made me laugh :slight_smile:

[]
I hate C#, nice language design but vendor lock-in into MS world (don’t come with mono). The last place you want to be as a programmer (with a future). In the (big) business world it is mostly Java except in the USA where MS used their money to promote C# (paying schools and giving ā€œgoodā€ deals to companies). And Java wins any benchmarks I know (by a wide margin).
[/]

But Unity produced lot of C# game developers… thats why pople ask for C# and nothing else even thu theres wide selection :stuck_out_tongue:

[=Nawrot;22661]
I am programmer since ZX81 times
[/]

Wow! Haha, you got started a good 7 years before I did. Never got to use that device but that is pretty awesome. In some ways, it’s fond to think of the old tech and where everything started. I remember some of the old Orange-Black terminals that had the hard drives that were those huge cylinders that you had to rotate and lock into place and remember thinking that 32 Mb of RAM would be overkill. Lol, man how times have changed…

[=Nawrot;22661]
I am programmer since ZX81 times, I know every programming language is about same, you just use different keywords, every loop is mutation of checking condition and jump (because how assembler works).
And everything gets to asm level soon or later.

And blueprints are best invention since sliced bread. Really! Editor slapping my wrists when i try multiply text string by 5 is something that helps to learn faster.

edit:
I had not enough of force in me to learn unreal script, but now its totally different story with unreal 4

[/]

I couldn’t agree with you more. I was really skeptical about them at first thinking there is no way they are going to be as fast as raw C++ but the time that Epic spent getting the compiler in place is quite honestly amazing! It’s the first time I’ve ever been able to experience Visual Node-Based Scripting that isn’t a slow scripting extension. It’s true visual programming as best as I’ve ever seen. They may seriously be on to something here because this is a new way of programming that is actually efficient and powerful. It has a very artistic quality about it and it’s just the beginning for what they will do with it over the coming years.

In some ways, I think using C++ is a lot cluttered but I’m in love with Blueprints and the ease-of-use.

[=Nawrot;22661]
also ++! to this:
[/]

Thanks Buddy! :smiley:

[=Tarantula;23620]
He meant that new versions of VS are .NET applications and now it is much slower (intellisense…) and uses much more CPU and RAM compared to VS 2008 that was a C++ app.
[/]

That’s completely negligible considering the improvements and advancements in hardware over the years. There are also options I believe that you can just turn those things off if they are making your experience less productive. There have been serious advancements to Visual Studios performance more within the past 5 years and all the integration of using a hybrid of managed and unmanaged code for the IDE only greatly improved its feature-set with things like Intellisense, IntelliTrace, built-in perf analysis and managed profiling, etc. In order to support the growing enhancements in other frameworks and languages out there, it was a conscious decision that had to be made on their part to make VS a much more robust toolset.

[=Tarantula;23620]
… The last place you want to be as a programmer (with a future). In the (big) business world it is mostly Java except in the USA where MS used their money to promote C# (paying schools and giving ā€œgoodā€ deals to companies). And Java wins any benchmarks I know (by a wide margin).
[/]

I don’t agree with this one at all its just wrong. C# is definitely going to be around for at least the next 20-30 years so anyone who invests in it isn’t wasting their time by any means. An no, Java isn’t more widely used in the ā€œBigā€ business world as you think. Over the past couple years, I spent time working as a Senior Developer for 20th Century Fox and recently doing more Senior Development for another company creating apps and technology for companies like Microsoft and Disney. I won’t name the specifics but they were very big projects for very big companies and guess what… all C# w/ a pinch of C++ at times and not a lick of Java in sight :smiley:

[=Tarantula;23620]
But for game scripting there are better alternatives (LUA, AngelScript, Python,…). I did my own engine coding in C++, but still added a scripting layer. It’s about productivity, use the right tool for each job.

I’m sure many AAA epic customers still add a scripting layer. You don’t do all gameplay logic in the scripting layer, but for certain event based (so not per frame) things it is just more productive to have that layer.

It is smart of epic to not add a scripting layer, because prefers another scripting language. And with the C++ API many different bindings will be created by the users anyway.
[/]

That’s in the Eye of the Beholder. In regards to LUA, AngelScript, Python, C# to many is a much more powerful language and even though you can use it as a scripting language in things like Mono, at its core its a powerful language. It simply depends on the developer. But IMHO, I’m against having real-time scripting as it can limit how far you can push the envelope in what you are doing. Blueprints on the other hand completely negate the need for a scripting language as its not only easier than learning one but gets precompiled so you end up with the best of both worlds of ease-of-use/productivity and bleeding-edge performance.

The lack of a scripting language is a concern for me because I’m developing a strategy game and having a fairly extensive modding system is a must-have in my opinion. That means exposing a programming interface that is friendly to novice programmers. Blueprint is not an option because, if I understand correctly, you need the Unreal Engine SDK to use the Blueprint editor, and I’m not going to make people shell out $19 just to make a mod.

Of course, I don’t necessarily have to expose any direct UE calls in the modding interface anyway, and nothing prevents me from simply embedding (say) the Python interpreter. But I’ll admit it’d have been nice to have something I could use out of the box.

[=;18346]
The performance of C++ will always beat C# or Java. And yes, you can write **** in any language but **** written in C++ will always be faster than **** written in C#/Java.
[/]

This will probably be entirely irrelevant for 90% of the people here. I have written an entire game in Python, engine and all, that ran at hundreds of FPS on my old computer from 2006, to say nothing of today’s computers. I will grant that it was a simple sprite-based game and not some fancy AAA first-person shooter, but I’d wager more people here are making something closer to the former than the latter. The game I’m working on now will have a high budget by indie standards (I’ll need to raise at least $100k), but it will most certainly not be AAA. I’ll probably be lucky enough if it’s even one A.

Also, remember that 90% of the time will be spent in 10% of the code. If your code is too slow, and if it is due to your choice of language and not your algorithm, you still have the freedom to rewrite that bit in C++ at that time.

[=]
I genuinely don’t want to hear about python, javascript, java nor c# where games (AAA games) are involved.
[/]

In other words, ā€œLa la la la la I’m not listening!ā€

You said AAA games can’t afford scripting languages. Somebody pointed out a counterexample. Now you’re burying your head in the in the hopes the threat to your little worldview will go away. This means you have lost the argument.

[=vblanco;19516]
I dont think C++ is THAT complicated, after all i learn the basics in a week without prior knowledge.
[/]

C++ is a language of deceptive complexity, and my experience is, the more of it you know, the scarier it is. I have known and used C++ (albeit not constantly) for about 15 years and I would consider myself an intermediate C++ programmer at best, whereas I’d consider myself an advanced Python programmer (possibly even an ā€œexpertā€, but certainly not a ā€œwizardā€) even though I’m not sure I’ve used Python more than C++. For example, I still have no idea what the hell C++'s .* and ->* operators are for. I’ve looked them up before, and I could do it again, but I’d just forget again because I simply have not come across a case where I’d use them. Also, if I look through the code that makes up, say, the Boost library, I might as well be reading Greek. I do have a basic understanding of templates and I use them myself when I find them appropriate, but that stuff still goes way, way beyond my understanding. By contrast, I could probably understand all the code in any well-written Python module.

I am far from a unique case. I’d wager at least 90% of C++ programmers with at least five years’ experience cannot understand the code in Boost.

[=;16252]
The first three generations of the Unreal Engine included a sandboxed scripting language, UnrealScript, which provided a simple interface for gameplay programming that was shielded from the complexity of the C++ engine.

The scripting approach is very welcoming to new programmers, but eventually it breaks down and becomes an obstacle to innovation and shipping. We experienced this over time as the Unreal Engine grew until finally, in 2011, we moved to a pure C++ architecture. The causative factors were both pervasive and general:

  • As an engine and its community grows, there is increasing pressure to expose more of the its native C++ features to the scripting environment. What starts out as a sandbox full of toys eventually grows into a desert of complexity and duplication.

  • As the script interface expands, there is a seemingly exponential increase in the cost and complexity of its interoperability or ā€œinteropā€ layer where C++ and script code communicate through a multi-language interface for calling functions and marshaling data. Interop becomes very tricky for advanced data types such as containers where standard scripting-language idioms differ greatly in representation and semantics from their templated C++ counterparts.

  • Developers seeking to take advantage of the engine’s native C++ features end up dividing their code unnaturally between the script world and the C++ world, with significant development time lost in this Interop Hell.

  • Developers need to look at program behavior holistically, but quickly find that script debugging tools and C++ debugging tools are separate and incompatible. Seeing where script code had gone wrong is of little value if you can’t trace the C++ that code led to it, and vice-versa.

It is these reasons, ultimately, that led to Epic’s move to pure C++. And the benefits are numerous: UE4 is a unified and fully-debuggable code base, freed from Interop Hell and totally open to programmers to study, modify, and extend. There are side-benefits, too, such as increased performance in gameplay code, and ease of integrating other middleware written in C++.

Building Unreal Engine 4 as a unified C++ codebase has been very freeing, giving engine and gameplay programmers enormous flexibility to write code without unnecessary interop barriers.

This isn’t to say that C++ is the ideal language for simple gameplay code. It is more complex and more dangerous than UnrealScript, C#, and JavaScript. But that is another way of saying that it’s more powerful.

By making peace with complexity and writing code in C++, there is absolutely no limit to what you can accomplish, whether it involves debugging your entire codebase in-context, interfacing to low-level engine systems, modifying them, or talking to the operating system or advanced third-party libraries.
[/]

These are all very good points, of course, but why doesn’t the same logic apply to Blueprint? What makes it so different?

[=furrykef;45691]
The lack of a scripting language is a concern for me because I’m developing a strategy game and having a fairly extensive modding system is a must-have in my opinion. That means exposing a programming interface that is friendly to novice programmers. Blueprint is not an option because, if I understand correctly, you need the Unreal Engine SDK to use the Blueprint editor, and I’m not going to make people shell out $19 just to make a mod.
[/]

You really should make them pay the $19.

, Mark Rein, and all the folks whose lives are built around the Unreal Engine deserves your love and support.

Additionally, people should have to pay even MORE to use C++ or any scripting language, but Unreal Engine and are giving you and the gift of a Lifetime for $19.

Consider being grateful for the amazing gift you are being given, and recognizing that $19 is a smaller amount of money than its ever been before (it’s not 2006 anymore).

If people don’t want to pay the $19 then they can only use the tools you develop yourself.


**My Own Solution **

I've written my own entire in-game editor to allow people to make maps for my game without having the UE4 Editor. The maps people can make use all my game's assets. 

The scripting system used in my in-game editor is my very own 3d scripting system that I wrote from scratch (seen in video below).

I also wrote my own graphical AI scripting system so people can customize the AI without having any programming experience.

To add new assets and code to my game, people would need to get the $19 amazing Gift called UE4.

It's called being fair to Epic :)


**Video of In-Game Editor, with 3d scripting, entirely coded by me in C++**



https://www..com/watch?v=IJXcuOA8POo




Your Options:

  1. Do the work like me to make your own In-game Editor / scripting system

  2. Or make people pay the $19 for the Lifetime of Work of all the people at Epic.

  3. The most likely scenario for all of us UE4 developers is some combination of 1 and 2.

The largest set of modding features will only ever be available to people who obtain the UE4 license.

The Unreal Engine is after all, one big Engine that you modify (Thank You Epic!) :slight_smile:

So pay for the best and enjoy it :slight_smile:

Do. Or do not. Why all the cry?

[=;45765]
You really should make them pay the $19.

, Mark Rein, and all the folks whose lives are built around the Unreal Engine deserves your love and support.

Additionally, people should have to pay even MORE to use C++ or any scripting language, but Unreal Engine and are giving you and the gift of a Lifetime for $19.
[/]

You’re assuming they would actually pay the $19. Most people would either go, ā€œOh, I have to pay money? Never mindā€, or they will pirate it. Nobody wins in either scenario. The way I see it, requiring this would only serve to reduce the number of mods made for my game, and therefore the value of my game. I was talking to MooglyGuy (he works on Minecraft at Mojang) about what language I should use for scripting and mentioned I was strongly considering Dylan for its macro system, but I wasn’t sure what value those macros would bring to modders. His response could be summarized as ā€œNone.ā€ – using Dylan instead of Lua or Python would severely cut the number of modders because most wouldn’t want to learn something new. If using Dylan instead of Python would be chopping down a few trees, then requiring a $19 SDK license would be burning the whole forest down.

I don’t buy the argument that allowing modders some access to the engine would be in some way unfair to Epic. It would still not be a substitute for having the SDK; people would be unable to distribute any mods, even total conversion mods, without requiring a copy of my game, thereby limiting the extent to which they can spread their creations; and people would still not be able to make any money off their mod without buying a license from Epic.

As for developing one’s own tools for modders, it must be nice to have that kind of time and/or money to spend. Unfortunately, I don’t. I’m going to be facing a steep uphill climb even without having to spend man-months on modding tools.

[=furrykef;45983]
You’re assuming they would actually pay the $19. Most people would either go, ā€œOh, I have to pay money? Never mindā€, or they will pirate it. Nobody wins in either scenario. The way I see it, requiring this would only serve to reduce the number of mods made for my game, and therefore the value of my game. I was talking to MooglyGuy (he works on Minecraft at Mojang) about what language I should use for scripting and mentioned I was strongly considering Dylan for its macro system, but I wasn’t sure what value those macros would bring to modders. His response could be summarized as ā€œNone.ā€ – using Dylan instead of Lua or Python would severely cut the number of modders because most wouldn’t want to learn something new. If using Dylan instead of Python would be chopping down a few trees, then requiring a $19 SDK license would be burning the whole forest down.

I don’t buy the argument that allowing modders some access to the engine would be in some way unfair to Epic. It would still not be a substitute for having the SDK; people would be unable to distribute any mods, even total conversion mods, without a copy of my game, thereby limiting the extent to which they can spread their creations; and people would still not be able to make any money off their mod without buying a license from Epic.

As for developing one’s own tools for modders, it must be nice to have that kind of time and/or money to spend. Unfortunately, I don’t. I’m going to be facing a steep uphill climb even without having to spend man-months on modding tools.
[/]

I agree with this that most people aren’t going to pay for the privilege of modding so that’s not even worth considering if you’re serious about making your game modable, you’re gonna want to embed your own tools or scripting system.

I strongly recommend taking a look at LuaJit. It’s jitted lua on the fly, is super fast (almost as fast as compiled C) and has an incredibly easy to use dynamic binding to C/C++, you don’t have to write any marshaling on the C++ side to use it. I’ll probably use this for my own projects when I cross the same bridge. It would also probably only take a few hours to integrate it as a or a game project, where-as with Mono you’re looking at a much larger time investment when you think about actually deploying and bundling the mono runtime. Also, Lua is awesome if you like the dynamic typed languages.

@, wow, that’s pretty impressive! An editor within an editor :slight_smile: I’m sure it was a lot of work though.

But guys, they said that UT4 (definitely) and Fortnite (I think?) will have modding capabilities, so they will probably come up with an in-engine solution before too long.

[=gregdumb;46059]
@, wow, that’s pretty impressive! An editor within an editor :slight_smile: I’m sure it was a lot of work though
[/]

Aww thanks!

Hee hee!

:heart:

Also, let me add that you seem to be thinking of the question in the wrong terms. You were thinking that requiring the Unreal Engine SDK to mod the game is worth the $19 because of all the power of the Unreal Engine that gets unlocked. But that is not what a modder sees. A modder sees ā€œ$19 to mod this gameā€, and that’s it. Are there any games I would pay $19 to mod? There are few games I’d spend $19 on period. (Most of the games I buy are indie, old, or on sale. Often some combination of these.) I don’t think there are any games I’d spend even $5 to mod. Even $1 would give me pause, when $0 would mean I could get started right away without committing to anything.

If you can’t look at your game from a customer’s point of view, then I don’t understand how you can sell games.

[=furrykef;47382]
A modder sees ā€œ$19 to mod this gameā€, and that’s it. Are there any games I would pay $19 to mod? … I don’t think there are any games I’d spend even $5 to mod. Even $1 would give me pause, when $0 would mean I could get started right away without committing to anything.
[/]

I’m just asking, but you’ve never bought a tool to mod with? I paid $20 for Milkshape years ago just to make some simple geometry for a game. Blender is more powerful but at the time Milkshape was just plain easier to use. Later I spent thousands on development tools just for a hobby - that ultimately landed me a nice job, I’ll admit. My point here is that, while most won’t lay out any cash to mod a game there are some people who will, for whatever reason. And most customers aren’t buying a game to mod it, most are buying a game to play it. The number of modders is high enough that it should certainly be considered seriously, but one shouldn’t assume that a choice like has described was made without looking at it ā€œfrom a customer’s point of view.ā€

As far as this raging debate goes, the engine was provided as is. If you want to add a scripting language, go for it. If you don’t want to, then don’t. Arguing over which language is better is pointless - I use several, each for different reasons. Like speaking, you should use the language that allows you to express yourself most appropriately for your purpose.

While we’re at it perhaps we should ask ā€œwhy English for the primary language of these forums?ā€