Scripting Language Pros and Cons

Hello,

I am currently working on designing my own game and I’m very torn at the pros and cons of each language.

Unity 5 uses C# but using IL2CPP it converts it to C++.

Unreal Engine 4 uses C++.

Yes, I know C++ in general is faster then C#. Do we know how well IL2CPP works vs straight C++? Is there any real benefit to use C# over C++?

Any direction here would be wonderful, performance optimization is something I am paying close attention to.

Afaik it would be very hard as the variables will be mangled, first iteration of il2cpp will focus on webgl only and ios & console next.

Thanks for the reply, is there a reason why Unity even uses C#?

And I’m not trying to be mean in this question, what is the specific reason why Unity choose C#?

It’s much harder to shoot your foot off in C#.

5 Likes

Lol, can you explain a bit further?

In my opinion managed languages (in general) usually have better tooling, are easier to use than C++, are more productive, have faster compilation times and also (as Tautvydas pointed out) it’s harder to make silly mistakes (or at least the silly mistakes are not so dangerous as in native languages).

BTOH, there are some potential issues (like GC latency and hidden costs) when you use a managed language.

2 Likes

Some extremely hard to solve bugs are almost impossible to make in C# - for example, heap corruption. Such bugs are a huge time waste, as it can take days or even weeks to track it down in a large codebase. When your iterating fast, you really don’t want distractions, and when something like this happens, it’s just a huge waste of time.

Also, if you really need extreme performance in specific code place, you can always drop down to C++ anyway - C# allows that.

2 Likes

C# is a lot more fun. End of Story for me! :smile:

can use resharper for C# :slight_smile:

although, i guess they are working on a C++ one

I went from c++ to c# and the fun began :slight_smile:

4 Likes

Thanks for all the replies, I’m getting a lot of great insight to the pros and cons of C#.

I like the point that you can add C++ when needed for performance sections, is their a terminology for that so I can research it a bit more?

Even more so, does this mean you could indirectly code your whole game in C++ using C#?

A whole game, I wouldn’t think so…

What programming languages are you familiar with?
Are you only interested in C++ for performance reason ONLY?

Development wise, I can’t imagine a scenario where a game made in Unity(C#) would take longer to do than in UE4 than in C++. A language such as C#, speeds up the development so much. Development time has to be taken into consideration, doesn’t it ;).

For performance reason, native will always be more fast, there is no way around that… But to what extent?
IL2CPP will help lower that gab, significantly.

But honestly your game performance hiccups will most importantly come from high memory usage and too many drawcalls, not from the language you used to develop it.

I believe you can only use native DLLs at the moment if you want C++. But from that talk on IL2CPP they mentioned being able to drop in a C++ file and it will compile with the rest, without needing a plugin. I guess that’s kind of like being able to code in C++ as you wish, right? Difference I guess would be that you can’t talk to the Unity API with it.

Also another question came up from a college of mine, is C# used for Server Development and Client Development, or just client (with Unity)?

If not, what does Unity use for Server Development?

Due to the nature of my game right now performance is everything but development time is definitely a factor I’m considering (which is why I’m doing so much research on the differences between the two languages).

I will always lean towards performance - I want my game to look as outstanding as possible with as little resources as possible. A big factor to WoW’s success was how it could run on nearly anything.

I’m not insanely familiar with C++ or C#, I’m just weighing options right now between Unity 5 and Unreal 4. Creating Plan A and Plan B scenarios and what my team will expect based on those choices.

Again - thanks for all the feedback everyone!

It’s my experience that the focus on the speed difference of a language is a beginner’s mistake. It’s pre-optimization, which is the death of success. Very often the thing that kills your performance has nothing to do with language and everything to do with algorithm choice, or loop structure, or draw calls.

Write clean readable code, optimize when your profiler shows you need to.

2 Likes

Good to know, thank you.

From my experience, C++'s implementation of classes feels very primitive and like its been forced onto an existing language(which it was, C) compared to C#. Go watch an Unreal programming tutorial to see how it gets in the real world. If could only choose one language to program in, it would be C# every time, its clean, concise, strongly typed yet not overly verbose and now it runs onto of a mostly open source framework :slight_smile:

1 Like

They are both good choice, in my opinion.
What is important, I think, is that when you make a decision, you stick to it throughout the learning curve.

For me, I don’t see a reason switching game engines at this moment. Unity is everything I need (and more!)

@Gidiolf , let us know your decision and why. It can help others it the same dilemma as yours! Cheers

1 Like