C/C++ and Unreal Engine FAQ’s from our Kickstarter Campaign

C/C++ and Unreal Engine FAQ’s from our Kickstarter Campaign

Our successful Kickstarter campaign funded the creation of a C++ and Unreal Engine 4 (UE4) online video course. This is a Q&A based on the C++ questions asked during the campaign.

What version of the Unreal Engine are you going to use?

We are starting the course with version 4.10 and we’ll keep an eye on major releases and changes for newer projects in the course.

However, one of the beauties of Object Orientation in C/C++ programming is that you can change the internals of the Engine and the Editor without affecting the developer/designer interfaces. Indeed, these parts of the Engine’s scripting system and the Editor, at least at the beginner level, tend to remain unchanged.

I’m impatient. Can you recommend any good C++ tutorials to get a jump start?

There are a lot of books out there and it can be very confusing which to pick.
For the impatient beginner I really like “C++ programming in easy steps”.
Note that strictly speaking C++ programming is a very different job compared with C programming, even though C++ build up on concepts from C and the two can be and are always intermixed.So the sister book “C programming in easy steps” would also give a great foundation to understand what the similarities and the differences are, and how/when one can or should use which features from either of the two languages.

After these books, there are a few very good books which can improve your skills but I would delay mentioning them to prevent any confusion.
However, as far as building a strong foundation goes, the next step would be building your skills in Object Oriented Programming and Design (OOP and OOD). Some might even argue this should come before any attempt at programming even though this approach is certainly not for the impatient! 🙂 this is the approach taken by “Thinking in C++ Volume 1” and “Thinking in C++ Volume 2”.
Note that there are newer versions of the C++ standard and in this course we will also include some newer C++ features which may or may not be mentioned in these books.

By the way, if you are that impatient why not use this link to signup to the course ASAP? 😉

How advised is it to interface with Unreal Engine 4 using C rather than C++? I know the UE4 library only has an interface to C++ so I’d still have to use G++ rather than GCC to compile it, but as for structuring the application itself, would you say things would become too complicated in C? Even though I know both, I have always felt more comfortable calling malloc instead of new. Any advice on that?

There are three parts to this question so I answer them one at a time.
But I think once you get used to C++ you will not feel the need for any C code. Today’s C++ compilers do a very good job! Though, I am still going through this process myself ;-)Please note also that my answers are going to be more C/C++ focused and it is best to leave the very specific cases to the tutorials because those would show you exactly where, how and why you can use UnrealEngine’s specific features.

1- How advised it would be to interface with UE using C rather than C++?
When an Engine (or a Virtual Machine such as Java or .NET) allows programmers access to interface with C/C++, it is offering them the absolute full control over every aspect of their code – otherwise there are many scripting solutions that are arguably much better than such a complex language. So from this point of view I would feel 100% confident using whatever suits me but would make sure that what I do A) does not crash the Engine on various platforms (this means heavy testing) B) and that it does not so called “leak memory” (lots of measurements) C) and that it does not perform inefficiently (lots of performance measurements and tuning). Either that, or always try and find a previously proven example of the custom solution that you are going to use from a trusted code/game.
But stay with me and keep reading the below answers.

2- I have always felt more comfortable calling malloc instead of new.
Only from a C/C++ point of view, using the C++ “new” keyword instead of malloc() does trigger operations such as calling a “C++ class constructor” which malloc() does not. So you cannot assume that they are interchangeable.

Furthermore, having said what I said in answer to the first question, when it comes to a mature product such as UnrealEngine, a rule of thumb is that if you are finding yourself doing something really low level such as a bare call to the standard C function malloc() then you are likely to be missing an already existing feature of the whole package or code base. UnrealEngine (or, again, Virtual Machines in general) would certainly have not left such a fundamental concept such as memory management out. Furthermore, built-in features in such systems are usually designed and optimized to perform as efficiently as possible on as many platforms as possible. One good example is that the system may allocate a large lump of memory upfront to prevent any jittering during the gameplay when you actually need the memory. So from this point of view I would try and find out what solution the UnrealEngine itself provides (which may well be a C-only solution wrapped in a C++ class).

A quick search through Unreal’s documents would show you these two pages:

https://wiki.unrealengine.com/Garbage_Collection_%26_Dynamic_Memory_Allocation

https://docs.unrealengine.com/latest/INT/API/Runtime/Core/HAL/FMemory/index.html

This takes us to your other question.
3-1- Would you say things would become too complicated in C?
3-2- I’d still have to use g++ rather than gcc to compile.

I think with my comments above I can leave this mostly to your own judgement 🙂
One of the books which I mentioned in one of my previous comments (“Thinking in C++ Volume 2”) certainly thinks so, yes.

In any case, you are always free to do what you want as long as you can ensure you are doing what the C++ code base does [take the compiler into account] which makes me think what is the point.

Technically speaking you can even go all the way to writing pure C source code (yes in “.c” file format), compile it with GCC (yes, without the need for G++) and still interface it to UnrealEngine’s C++ libraries. This is not such a “Beginners” task though.

However, the fact that you are doing this, as you can imagine, does not mean that the engine itself performs any differently (so back to the first answer!).
This depends also on exactly what we mean by C vs. C++ (are we referring to function calls such as malloc() only or speaking about the [binary object] file formats and compilers too?).

Keep in mind that, in order to completely avoid using the engine’s C++ object hierarchy, you will also always find yourself having to do a little extra work to wrap those C++ actions or C++ objects in pure C functions to make them available to your C source code. These pure C functions would need to simulate what C++ does (which can get a bit hairy).

Visual Studio 2015 added support for some C++17 features. Are they used in this course? What about C++11 and C++14? I wish to see some of these features. In Unreal Engine 4.10 will soon support VS2015. So are you going to use the newest standards?

With regards to newer versions of C++, we are limited to what the “current” version of UnrealEngine accepts within its source code and specially its build system during the course. The engine itself doesn’t make use of too many C++11 features (even though C++11 has been out since 2011! – large code bases move very slowly); however the build system does support C++11 which means we can indeed teach C++11 features (where appropriate for beginner C++ programmers, as Ben mentioned).

With regards to C++14 or newer, please note although the standard is out not every compiler supports it (UnrealEngine makes use of several different compiler toolchains to target different platforms). The few compilers that do support C++14 also do not implement the full standard _yet_, not to mention that the compilers themselves are also limited by what the operating system vendors (such as Google’s Android) decide to support – OS vendors don’t always jump for the latest language standards. So it’s really early to expect much when it comes to C++14.
Last but not least, C++17 is still a work in progress due in 2017. We all really hope that this course will finish long before compilers, OS and game engine vendors adopt that version. Most notable new features in the C++17 standard are also way too advanced or not really applicable for our purposes.

May be we’ll do an advanced C++ course in the future to cover crazy new features in the language – who knows!? 😉

I’ve been following along with the video tutorials that Unreal has on their site, it seems pretty easy making environments and I hope that I don’t see this course as a repeat of that material?

You will not see a repeat of any material that you have seen before. This is, first and foremost, about teaching C++ and teaching C++ using UE4; after that, for me personally, this is about being original because I am religiously keen on doing original work and without it I will have simply wasted my time that I could have spent on making a work worthy of mention; and just to reassure you, I have never watched any of the videos you mentioned. Maybe I take a look once we are finished making this course. 🙂

For several years I was afraid of C++. Now with this course, I will give it a chance. 🙂

Yes quite often if someone starts off with other more modern languages or systems the idea of using C/C++ can be a little overwhelming. But don’t listen to the Internet telling you it’s complex and hard. True, C/C++ give you a lot of power, and with its power comes the side effect that there are many ways to do the same thing (not always a good possibility) and so a lot of learners think of them as “hard”.

However, it is really all about how you approach learning it. A good teacher or a good teaching method at the right pace can turn seemingly complicated subjects into east-to-understand concept for the beginner. We’re taking this approach and if you still find one of the videos not as easy as you’d like we are here to change the delivery of the content over the course of the coming months to make the course suitable for the beginner.

So I encourage you and all the other current backers or future audiences of this course to unreally engage with us, give us feedback, ask questions and hep us approach the subjects the right way…

What is the best programming language to learn for App design?
I have very little knowledge of programming languages. My primary aim is to design Apps. I want to also be able to design games even though that is not my primary aim. It looks like I should learn C++, C# and Apple’s Swift but I am not so sure where to start.

Learning programming languages and general programming concepts is always a must and most “modern general purpose programming languages” quite often resemble each other (a lot of them are actually inspired by or derived directly from C itself).

So what differentiates these languages, programmers and applications you might ask.

I would argue that the answer is ”the libraries” that each of these languages support, “the platforms” that they target, and last but not least the “implications or side effects” of using each if these languages.

In other words you can, for example, easily learn to write programs in C# if you know Java or C++ well. However, for example, a C# programmer cannot be easily replaced with a C++ programmer (same goes for all languages) because when you spend a lot of time with one language you get very well versed in its libraries and its pros & cons. These skills are not easily transferrable between languages.

In general, Java is good for cross-platform networking applications because of its libraries that are heavily focused on this kind of application. It’s also the one to use for Android.

C# is good in banking applications, front office, Unity3D gaming, rapid Microsoft Windows development, and also cross platform GUI Apps using “Mono”.

C/C++ are very suitable for system software, game engine development, high performance systems in endless applications, writing code to run on hardware without an operating system and what not. Of course, in our case, C/C++ are used for scripting the Unreal Engine.

Please leave any other questions you have in the comments below.
 

Leave a Reply

Your email address will not be published. Required fields are marked *