Announcement

Collapse
No announcement yet.

Why C++ for Unreal 4?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Why C++ for Unreal 4?

    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

    #2
    I am pretty sure Unity is written in C++ actually. It provides it's users the choice of scripting languages, C#, JavaScript or Boo. But, you have to pay a lot to get a source license to the Unity Engine itself.

    UE4 has Blueprints for it's scripting environment built in. People in the community are making plugin's to add C# etc.

    Comment


      #3
      The Unity core is not written in C#, it's in C/C++, they exposed the public API via a C# wrapper. I don't have the latest benchmarks on just how much slower C# is than C++ these days, but with anything but a toy engine the performance hit you'd take by writing your entire engine core in C# is not going to be acceptable.
      Contact: enlight in #unrealengine IRC channel on Freenode, or @macagonator on Twitter

      Comment


        #4
        I'm glad they haven't layered on any other kind of 'scripting' - C++ is where it's at and my years of learning that won't go to waste. C++ is fast, and direct access to the source code is a dream come true for coders. Learning C++ was also rewarding (though I should point out I'm now rusty with it and I still had much to learn on more advanced topics even back 10 years ago when I wrote my own simple D3D8 engine before I tacked my own game engine onto Irrlicht).


        P.S I hate Javascript and C# doesn't do much for me either. I went from 'BASIC' (on the Amiga) to C++ (didn't even know 'C' before starting) and it wasn't too bad in the end. I figured if I'm going to spend years learning something I may as well shoot for the top of the tree (no, not assembly or machine code lol). With C++ I felt there was literally nothing I couldn't create, on a technical level, and knowing it was may more likely to run my code at far faster speeds than higher level languages was a massive incentive to roll my sleeves up and dig in. I became addicted to learning C++ as geeky as that may sound, I never felt that way about the other languages I've since dabbled with (which if anything I find frustrating for all their hand holding and so called ease of use)
        Last edited by Sharpfish; 04-12-2014, 01:44 AM.

        Comment


          #5
          As already mentioned C++ is the base to add other languages like C#, Java,...
          Now you have different layers that you can choose for your preference and purposes

          Comment


            #6
            @Sharpfish
            I am totally with you.
            C++ is the language to go for if you are interested in:
            a) performance
            b) flexibility
            c) power
            d) finesse
            e) beauty - yes! it is beautiful language which so much possibilities that no other (current) language can compare or even come close to.

            And may I just say that gaming industry is the industry where every "tick" matters and C++ is simply unbeatable where it comes to performance.
            If someone asks me why do I prefer C++ over anything else I simply reply:
            If I have a choice between ferrari and ford fiesta and the likes why on earth would I choose anything but ferrari?
            And just to post short disclaimer:
            I'm not a language zealot, fanatic or kid who thinks only the toy he has is best. I am not looking to start any kind of "language war". On the contrary. I programmed in many languages apart from C++: C#, Java, Javascript, AS2, AS3, you name it, and after using all those languages for some time and being able to compare them with C++ my conclusion is this:
            No modern language compares favorably to C++, in any respect really. C++ is the most powerful, the most flexible modern language, and now after getting updates and hard work from ISO commitee and new C++14 update on horizon and another major update foreseen for 2017 this is simply the language every professional game programmer should go for.

            Comment


              #7
              This is awesome, thanks everyone for the information. Good to know all the C++ classes I have been taking in my Game Programming degree won't go to waste.

              Comment


                #8
                There is some great work happening by the community to bring Javascript and C# as scriptable languages to UE4.

                Comment


                  #9
                  The main problem with C++ is that programmers think too highly of themselves, run out of talent, and introduces multiple memory stomps that other guys have to spend time tracking down and resolving.

                  I do believe C# is the future going forward without a doubt. But for now, C++ is still king of performance and memory management. I think it's a great idea for the core of the engine to be written in C++ but game code can be higher level (byte code, etc)

                  Where Epic Games went wrong in the past was UnrealScript. Which kept me away from UDK. It couldn't be debugged, couldn't rapid prototype, took awhile to compile, etc. It had all the disadvantages of a scripting language and none of the bonuses lol
                  Godz for UT '99 / UT 2003

                  Comment


                    #10
                    Originally posted by sandboxgod View Post
                    Where Epic Games went wrong in the past was UnrealScript. Which kept me away from UDK. It couldn't be debugged, couldn't rapid prototype, took awhile to compile, etc. It had all the disadvantages of a scripting language and none of the bonuses lol
                    I wouldn't necessarily say that they went wrong with UnrealScript. It was a language that was a bit more straight forward than quite a few languages. Also because of UnrealScript, I was able to jump right into the C++ code quite comfortably. I would be quite lost if I didn't practice UnrealScript before UE4 came out.
                    Portfolio/Tutorials: http://chadreddick.com

                    Comment


                      #11
                      I worked on a project where we had Unity source access, indeed it is written in C/C++.

                      C++ is useful but having access to a scripting language would be nice. C# is a very nice language with very good features, javascript is also becoming the most popular programming language in the world (if it is not already) and I would seriously help bringing new talent onto a project.

                      Ideally there should be some mechanism to use whatever scripting language you want beit LUA, Python or whatever.

                      I disagree that C# is the "future" though - it's pretty much tied to Microsoft and we're seeing less MS popularity not more.

                      Comment


                        #12
                        C# isn't tied to Microsoft. Unity for instance, uses Mono.

                        And don't get me wrong, I got my modding start in UnrealScript as well with Unreal Tournament. However, back in those days Epic Games provided some C++ source as well. Mods could provide DLLs etc. And it wasn't gimped like the UDK version, the native DLLs were directly tied into the engine (unless my memory is failing me). I stopped modding somewhere around UT 2004 and went into games industry where we able to use a debugger with UnrealScript. But the community didn't get the debugger with UDK for whatever reason (only licenses).
                        Godz for UT '99 / UT 2003

                        Comment


                          #13
                          Agree with all the things everyone said. I program in C++, C#, python and sometimes touch javascript, LUA and even assembler. There is no doubt that C++ is king for game programming languages and will stay that way for many moons to come. Generally garbage collection doesn't have the determinism needed to understand the performance required of game, robotics, or general real-time coding. If people are making C++ code that 'stomps' memory they need to work on becoming better coders. Especially in C++11 or with smart pointers using RAII such memory management is far more automatic than it was in the past, you shouldn't be dropping new's and delete's everywhere.

                          I love the decision to go with C++ for many reasons: less of a divide between some "game code" and "engine code", a great world of tools to work with/test/debug C++, so many external libraries for niche hardware devices and sensors, bringing all the skills already learned along, and for new users the ability to use general (stackoverflow) information to understand language issues... I could go on
                          VR R&D @Shopify

                          Comment


                            #14
                            Originally posted by sandboxgod View Post
                            The main problem with C++ is that programmers think too highly of themselves, run out of talent, and introduces multiple memory stomps that other guys have to spend time tracking down and resolving.
                            C# on the other hands has memory leaks and you simply have no control over them. C++ gives you power. With that power comes responsibility.
                            And you know it is not that it is easier to write non - leaking programs in C#/Java - simple example, file management:
                            In C++ if you use memory management technique called CADRe or RAII - (Constructor Acquires Destructor Releases ) then you put opening file code in constructor, releasing that file to memory in destructor and your done. No more worrying. In C#/Java you have to actually manually close every file you've opened. So how is this for easy / hard.
                            And guys, don't fool yourself that working with C#/Java is easier than with C++.
                            It is like with toy tools and real tools really. It is much easier to build castle from sand than real castle but after the work mounts up, you realize that only real castle is actually livable. The sand one is unusable.
                            C# destroyed Visual Studio. Once my beloved IDE, now I simply cannot look at it.

                            Comment


                              #15
                              Average studio these days utilize C# for Tools at the very least. Out of all the issues I've seen over the years in C# memory leaks has never been one of them

                              Now I have seen some C# apps accumulate a lot of memory and then it becomes a little trickier to find out where the memory is going due to the lack of a sizeof operator on managed objects. For those cases I hookup a profiler to see where the allocations are going
                              Godz for UT '99 / UT 2003

                              Comment

                              Working...
                              X