Live data from Hacker News

Why C++ for Unreal 4

forums.unrealengine.com

101–110 of 178 posts

Re: Why C++ for Unreal 4

#101

It will be interesting if any major game engines pop up using Rust as the core language, or even Go. C++ has been the king of highly optimised game engines for so long, I can't help but feel it has become so entrenched in the industry that it will take something monumental to disrupt it.

Can Rust code be compiled and debugged on PC, OS X, Linux, iOS, Android, PS4, and XB1? If the answer to any of those platforms is no then the answer to your question is no.

Re: Why C++ for Unreal 4

#102

Earlier quoted context omitted.

> Furthermore, there's some great tools out there to help prevent things like memory leaks. Combine that with good company practice, like code reviews, and it becomes a non-issue. The security track record of applications written in C++ disagrees with you.

Selection bias much? The 500,000 C++ applications that have never blown up in somebody's face aren't discussed on Hacker News.

pcwalton mainly works on web browser development (Servo), which whilst sharing some goals with game development, also differs in some respects. Although online security is more and more important in games these days, the real appeal of Rust in respect to game development is in providing an alternative to the 'death by a thousand cuts' that can plague large C++ projects.

I've posted a list of the things I consider the most relevant to game development: https://news.ycombinator.com/item?id=7587413 Any one or two of them alone wouldn't really be a compelling enough reason to switch, but put together they form a very compelling value proposition.

Re: Why C++ for Unreal 4

#103

It will be interesting if any major game engines pop up using Rust as the core language, or even Go. C++ has been the king of highly optimised game engines for so long, I can't help but feel it has become so entrenched in the industry that it will take something monumental to disrupt it.

Can Rust code be compiled and debugged on PC, OS X, Linux, iOS, Android, PS4, and XB1? If the answer to any of those platforms is no then the answer to your question is no.

iOS, PS4, and XB1 are missing.

I know it's not your point, just providing some answers in case someone is wondering.

Re: Why C++ for Unreal 4

#104

We've also been there done that (about 10 years ago though), we had a very powerful scripting approach integrated into our game engine which gave direct access to game play systems in order to let our level and game designers build scripted behaviour into the game. In the end we ended up with a terribly huge mess of script code (I think it was about a third of the actual C/C++ code) and the majority of the per-frame…

The biggest advantage of scripting for me has been 1. Co-routines Co-routines (co-operative multi-tasking?) mean you can do stuff like while (isWalking()) { advance(); yield(); } This is effectively 'yield' from Python, C#, etc.. You can implement this in C++ by swapping stacks and calling setjmp but there's usually issues. 2. Iteration time You can usually swap script code live. This project aims to fix that for C++…

The slightly obscure music programming language SuperCollider [1] added co-routines about 10 years ago and they became one of my beloved techniques. Was very glad to see them come to python and soon to mainstream javascript.

Boost has a c++ implementation but it looks quite different:

http://www.boost.org/doc/libs/1_55_0/libs/coroutine/doc/html...

[1] http://supercollider.github.io

edit: pythons new asyncio stuff looks very interesting:

https://docs.python.org/3.4/library/asyncio-task.html

Re: Why C++ for Unreal 4

#105
post #24
post #20

The whole C# vs C++ discussion going on the forum shows how little current generations understand of compiler design and language implementations, oh well...

Exactly. What's most distressing is people (as normal) are completely ignoring the garbage collection overhead, which is mostly where the advantage of having complete control is, in terms of micro-managing your memory allocation, e.g. using slab allocators, memory pools, pre-allocation, etc. C# code in theory (ignoring things like intrinsics support and inline asm) can be as fast as C++ for tight loops, but in my exp…

It doesn't have to be an all or nothing proposition with C# or C++ anymore if Windows is your target environment. You can write the portions you want to write in C# and mix it in with C++/CLI. Yeah, I know, a lot of people think C++/CLI is ugly, but in the .NET world, it is a very clean glue language if you can get past the strangeness of having two different type systems (native and managed.)

You can essentially choose and manage how you want to deal with memory by virtue of how you choose between native and managed types, as well as control the behavior of the garbage collector itself.

Re: Why C++ for Unreal 4

#106

Earlier quoted context omitted.

Can Rust code be compiled and debugged on PC, OS X, Linux, iOS, Android, PS4, and XB1? If the answer to any of those platforms is no then the answer to your question is no.

iOS, PS4, and XB1 are missing. I know it's not your point, just providing some answers in case someone is wondering.

I was making a point and asking a real question because I didn't know. I checked wikipedia and couldn't get a clear answer. So thanks!

Sticking with C/C++ also means you'll be able to more easily port your game to any platform of the future. It's just a safe bet that any future platform (either hardware or software) will support C/C++. Especially for games. Anything else is a dice roll. Sometimes a roll worth taking, but still a roll.

Re: Why C++ for Unreal 4

#107
post #97

Earlier quoted context omitted.

What's the appeal of Rust for gamedev?

- Fine grained control over allocation whilst maintaining memory safety (stack, heap, RC, GC, or roll your own) - No null pointers (with an Option type that compiles down to a nullable pointer) - Data race free concurrency - Zero cost abstractions - RAII and destructors - No exceptions - A modern, highly expressive type system - Generics that throw type errors at the call site, not deep in a template expansion - True…

I was being a bit flippant when I posted, but I'm really impressed with the list. I need to look into seeing where I can help on the compiler or runtime.

No exceptions is my only objection, but I know they're dubious for a systems language.

Re: Why C++ for Unreal 4

#108
post #75

This was refreshing. I'm struggling with the same problem...I've embedded Lua in my C++ engine for high-level scripting. Unfortunately, as my scenes became more and more complex, I found myself struggling with representing the inheritance hierarchies in Lua, as well as things like object ownership/gc (resorting to passing around shared_ptrs in Lua userdatas). And for each new data type, I had to write the same old C+…

Embedded scripting languages seem to work best on what I'd call a 90/10 model. Either your game is written in the scripting language inside a thin compiled shell (to provide access to system routines and the occasional optimization), or your game is written almost entirely in the host language and just configured using scripts. So: 90% Lua, 10% C++ or vice versa, but not 50/50 or the like.

In general, it seems to be a red flag if a single thread of logic runs back and forth between host and scripting contexts.

Re: Why C++ for Unreal 4

#109

Earlier quoted context omitted.

A safer language with higher-level, low-cost abstractions.

Honestly, I've made over 15 games in my career and safety with C++ really just isn't an issue with decent developers. The line between what's a programmer for games and what's a designer is narrowing, most designers are competent programmers. Furthermore, there's some great tools out there to help prevent things like memory leaks. Combine that with good company practice, like code reviews, and it becomes a non-issue.

It seems like it's hard to say if Rust really would have eliminated those bugs, the reports are vague and the ones that aren't, e.g. fixed framerate issues, would be an issue either way. My argument isn't solely get good developers and be done with it. It's a combination of things, and one of the most important things is getting good practices in place. I don't know if EA did this but having a good auto-test system in place probably would have caught those crash bugs and prevented the server issue, for example.

Re: Why C++ for Unreal 4

#110

Looking at the comments around the post, the amount of people who don't really understand pointers but who seem to be Unreal developers is a little surprising!

But then, the number of people who don't really understand pointers but who seem to be C/C++ developers is a little surprising...
Post reply on HN