Skip to main content
GameDev.net gamedev.net
🔒 Locked

Modern Programming Language for Game Engines

Started by LifeIsGood Dec 3, 2016 at 12:25 PM 20 replies 14.1k views
Original Post
LifeIsGood
LifeIsGood

Hey, I just found this forum so I'm pretty new here.

First at all, let me introduce myself real quick.

I'm not a beginner. I'm a relatively experienced game programmer.
I've started programming games around 6 years ago, spending 5 years with Unity & C#.

I just hope to get some advice from some Guru's.

Just to have it mentioned, I don't plan to compete with engines like Unity, Unreal or CryEngine, I just want to start writing my own engine for fun & learning purpose.

In fact, I already made a few early experiences with DirectX & some basic drawing based on WindowsForms using C#.

But, I'm just not sure which language I want to use.

I love C#, but I worked for 5 years with it, so learning something new seems to be a good idea to me.

Here are some Languages I took a few looks at:

-> C++ (of course)

I messed around a little in C++, mostly writing Console Applications, but also trying some stuff in the CryEngine & I'm not going to argue the facts, C++ is for a reason one of the most used languages for game programming, but, coming from C# & just looking at the style of the language, C++ seems to be a little outdated to me. Just all the combinations of operators & keywords like "const" make me feel like "Do I really want to use this language ?", it doesn't seem to be that much of fun for me.

-> F# (a little surprising, I guess :D)

Same as C++, just a few hours of tutorials, throwing basic stuff in consoles. But, I kinda like F#. It's just a completly different thing & a completly new style of programming (it's pretty difficult to understand though, for someone who has no experience in using functional programming languages) & I like the fact that F# is managed land (Though, I don't mind managing memory by myself, that C++ is native land is no real downside for me)

-> Rust

Rust is the language I have the least experience with. I just had a little talk about it with a friend (who is also a quite experienced programmer & to mention, also more experienced than I am.) & he seems to be pretty convinced of the language. Rust looks like it is pretty close to C++, but also combines functional programming in it (reminding me a little of F#) which seems pretty cool to me.

-> Java

I know Java a little more than the other languages listed here, because I used to help a friend who studied Informatics & had to write some simple applications in Java. But Java is no option for me, it's a kind of Half-hearted OOP Language & I just don't like it's style.

Based on my few experiences with these languages, is there some advice you would like to give me ?
Or even a completly new language I haven't mentioned ?

bioglaze
bioglaze

One option is to use the D language. Fast compile times, modules, package system, array slices, readable templates, compile-time functions, unit testing, variables initialized by default etc. make it a good, modern language. At least one commercial game, Quantum Break, uses it.

mychii
mychii

C++ isn't outdated. It's just old. If your reason to not use C++ because it's outdated, then I guess it's not valid. If you like C++ then use it. C++ can be used on most platform and can get closer to metal when you need it so... I see no reason not to use it, if it's one of your choice. You haven't mentioned on what platform that this program will be, though.

2nd of all, personally, if your reason to make this engine is to reallllly want to have fun, you're going to have LOTSSSS of fun with C++. I tell you that. I mean C# is managed, C++ is unmanaged, you handle things yourself. Despite how things going to be (bad or good), you'll have more fun doing these things, I tell you that. Some translates this "fun" as frustrating though, me for instance. However, despite of my frustration, I can't deny the fact I'm having fun throughout all my unnecessary troubles, more than any other language I have used before.

Spinningcubes
Spinningcubes

C++ fun is the same type of fun found in Dwarf Fortress :wink:.

For Engine coding i would recommend you go with C++. The jump from C# to C++ should not be to hard. Never used to other languages. Select what your focus is, it is learning a new fun language pick one of them. Is it engine coding go with C++.

Bregma
Bregma

You missed Ada, Fortran 2017, OOCobol, and LISP. All of them have better syntax than C++ and are powerful enough to write OSes in, so something like a game engine should be no problem for them to handle.

Stephen M. Webb
Professional Free Software Developer
Satharis
Satharis

C++ may be old but the rules are generally there for a reason. Stuff like const is in the language because it controls access to things, gives the compiler hints on things it can resolve at compile time, or gives hints to programmers as to whether values can change. There's quite a big difference between C++ and any of the GC'd languages like Java or C# if that's all you are used to.

Is it the language you need to use? Who knows. You can certainly write a game engine in any language, different languages just have different pros and cons. C++ lets you get very bare metal and people are very experienced in it, that's why it is king for the side of game development that needs to be super speedy.

Budowalski
Budowalski

Every single good 3D game engine is written in C++. There is no other reasonable choice.

l0calh05t
l0calh05t

You missed Ada, Fortran 2017, OOCobol, and LISP. All of them have better syntax than C++ and are powerful enough to write OSes in, so something like a game engine should be no problem for them to handle.

Fortran 2017? The newest standard I'm aware of is Fortran 2008 (released in 2010...)

LifeIsGood
LifeIsGood

Thanks for all the answers !

One option is to use the D language

At least one commercial game, Quantum Break, uses it.

D looks indeed interesting, thanks for that.
Also, that it is being used by a quite fresh game sounds awesome.

C++ isn't outdated. It's just old

Yep, I gotta agree with you there, outdated might be the wrong word to descripe what I meant.

you handle things yourself. Despite how things going to be (bad or good), you'll have more fun doing these things

No doubts about that ! That's one of the main reasons for me to even start writing my engine, earning some more background knowledge.

Have you heard about .Net Native?

I haven't, I was aware of the "common" .Net way to compile into IL Code, however, I didn't know there was an approach to avoid this. It sounds a bit against the whole idea of .Net in the first instance to me.

The jump from C# to C++ should not be to hard.

I wouldn't bother if it was, as long as I like the language & it makes sense to me in the end. I got enough time, no deadline in the background :)

You missed Ada, Fortran 2017, OOCobol, and LISP.

All of these seem to be preeetty old, with a lot of history. But I'm definitly going to look them up, thanks !

C++ may be old but the rules are generally there for a reason.
There's quite a big difference between C++ and any of the GC'd languages like Java or C# if that's all you are used to.

Absolutely, I didn't meant to say there isn't a good reason for them to be, just that I don't like all of these combinations. Using the same keywords / operators but with quite different meanings.
To be honest, when I dived into C++ I was kinda surprised that the difference doesn't seem to be that great.
I thought you would have to manage every bit of memory, instead of "just" the things that you want to be (or even have to be) on the heap.

Every single good 3D game engine is written in C++. There is no other reasonable choice

I wouldn't say that, Xenko for example is written in C#, and I know a good friend who's also writing his own Game Engine completly in C#.
I guess that especially C++ Guru's tend to say that, but I'm not quite sure if I can agree there.

Navyman
Navyman



When someone ask me what the best language is i say that i hate them all and i hate to one I'm using at the moment a little more.

LOL, this really made me laugh, but is very true.

Developer with a bit of Kickstarter and business experience.   YouTube Channel: Hostile Viking Studio
Twitter: @Precursors_Dawn    
fleabay
fleabay

Go. The garbage collector is now fast enough (and gets faster each release) for games and it produces native binaries. Plus the job market for Go looks to be huge in the near future.

It was designed for system programming and it has a large following for creating web server software.

IMHO, it's the next great language. Good times ahead for Go. :)

And slightly off-topic, here is a very interesting talk on concurrency and parallelism in Go by one of the creators, Rob Pike.

Slides are here... https://talks.golang.org/2012/waza.slide#1

🙂🙂🙂🙂🙂<←The tone posse, ready for action.
Ravyne
Ravyne
Keep in mind that a big part of the reason that C++ can seem old-hat is that the majority of resources are pre-C++11 -- there's just a lot of material, resources, and code out there that reflects an earlier state of the language. Things are getting much better though, and if you know where to look, you can find current-day and even forward-looking resources. C++14 made significant strides in language ergonomics, and C++17 and surrounding technical specifications are bringing some long-overdue libraries into the standard ecosystem.

I do like Rust a lot as well. I've been meaning to play with it more myself. It's got possibly the most amazing community, especially considering its modest size. The tooling is great, the error messages are awesome, there's really a lot to like. The challenge with Rust, I think, is that it demands quite a lot from people as they approach it -- more understanding and possibly more patience than a lot of other languages.
throw table_exception("(? ???)? ? ???");
sirpalee
sirpalee

I wouldn't deviate much from C++, it's a great and flexible language, and quite modern if you are using c++11, c++14 and such. As others said, most of the code online is usually made with c++03 including tons of boost, but those times are slowly going away. Finally. :)

I guess that especially C++ Guru's tend to say that, but I'm not quite sure if I can agree there.

Well, it all boils down to performance. You always want to write your core engine in a language that's precompiled, does not enforce the use of a garbage collector and gives you low-level access to data structures and their layouts. Right now there are only two languages that fit these requirements, and also have lots of 3rd party libraries, good compiler support. That's C and C++. From the two, C++ is the better choice.

Personally, I'm using more and more rust during my daily work and personal endeavors. It's great so far, clearer syntax than c++, no garbage collector, great compile time analysis passes and good performance. 3rd party libraries are getting there, so it's starting to become a good choice for writing an engine's core and communicate with the rest of the world through a C-like interface.

shaken, not stirred
l0calh05t
l0calh05t

I wouldn't deviate much from C++, it's a great and flexible language, and quite modern if you are using c++11, c++14 and such. As others said, most of the code online is usually made with c++03 including tons of boost, but those times are slowly going away. Finally. :)

I guess that especially C++ Guru's tend to say that, but I'm not quite sure if I can agree there.

Well, it all boils down to performance. You always want to write your core engine in a language that's precompiled, does not enforce the use of a garbage collector and gives you low-level access to data structures and their layouts. Right now there are only two languages that fit these requirements, and also have lots of 3rd party libraries, good compiler support. That's C and C++. From the two, C++ is the better choice.

Personally, I'm using more and more rust during my daily work and personal endeavors. It's great so far, clearer syntax than c++, no garbage collector, great compile time analysis passes and good performance. 3rd party libraries are getting there, so it's starting to become a good choice for writing an engine's core and communicate with the rest of the world through a C-like interface.

There are still plenty of reasons to use boost. multi_index containers are awesome.

In any case, wrt new languages I'm really liking Rust so far.

WozNZ
WozNZ

I love F#, I have been playing with functional languages for a while and keep coming back to the ML based ones as they fit my mindset best. In the web space I can see Elm taking off big. Not sure F# would fit 3D engine that well as you could end up with a lot of object churn due to the immutable nature of data if you get your structure wrong. Immutable collections are an order of magnitude slower than mutable ones, the trade off if thread safety and object reuse that can minimize churn.

If you are doing this to learn then Rust might be a good idea, it aims to compile to fast code and is pushed as a C alternative. So you get to play with a new language and code an engine.

_Silence_
_Silence_



Just all the combinations of operators & keywords like "const" make me feel like "Do I really want to use this language ?

const is as important as class, or virtual. It drastically helps to understand if an object will have its state modified or not. Whether when using a "simple" variable in a function or whether when calling to a member function to an object. It has also other important semantics.

I did very few C# but I'm almost sure that const also exists for this language...

Happy SDE
Happy SDE
keywords like "const" make me feel like "Do I really want to use this language ?

There is entire section in a C++ FAQ devoted to const correctness: https://isocpp.org/wiki/faq/const-correctness

In five words: it is very useful feature.

BTW, if you want to explore Modern C++, it's better to look at entire FAQ, especially on "Overview Topics".

LifeIsGood
LifeIsGood

Go looks really promising and parallelising seems to be pretty easy. I'm a bit afraid of the lack of generics though. Definitly going to have a closer look at that one, thanks alot !

Keep in mind that a big part of the reason that C++ can seem old-hat is that the majority of resources are pre-C++11

Right, guess the tutorials I did were a few years old. Luckily I received a key for VS 2017 Enterprise yesterday, so I can get my hands on the newest standards of C++ :)

so it's [Rust] starting to become a good choice for writing an engine's core and communicate with the rest of the world through a C-like interface.

Thanks for sharing your experiences :) Rust is definitly one of my favorites so far.

Not sure F# would fit 3D engine that well as you could end up with a lot of object churn due to the immutable nature of data if you get your structure wrong.

Yep, I found the "Nu Game Engine" which is based on F#, so at least it is possible, but I'm not quite sure if it's a good idea either.

I did very few C# but I'm almost sure that const also exists for this language

There is entire section in a C++ FAQ devoted to const correctness: https://isocpp.org/wiki/faq/const-correctness

In five words: it is very useful feature

Yes, I think you got me wrong there. I'm not questioning whether it is useful or not, I know it is, but I don't like how the same keyword has quite different meanings.
Const exists in C#, but you will never see something like this:


int x;
const int * const pX = &x

or this:


void SomeFunc(const SomeType& params){}

Which, I know, has somehow the same meaning in usage, but not really.

Anyways, I didn't meant this to become a discussion about C++ and / or C# keywords :D & I don't want to downplay C++ either. Just wanted to mention that I'm not sure whether I'm going to use C++ or not, because I don't like it's style so far (which might change when growing more confident with the language)

Kylotan
Kylotan

Const there has exactly the same meaning in all 3 places. In each case it says that the object in question does not change. Your issue is really with the fact that C++ has references, pointers, and things-being-pointed-at.

Anyway, if you don't like C++ - which is fair enough, it's a mess - Rust seems like a fun language to try and write an engine in. If it truly is a cleaner, safer C++, it seems ideal for the task.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.