What's the best alternative to C++ for real-ti

2019-03-10 16:22发布

C++ just sucks too much of my time by making me micro-manage my own memory, making me type far too much (hello std::vector<Thingy>::const_iterator it = lotsOfThingys.begin()), and boring me with long compile times. What's the single best alternative for serious real-time graphics programming? Garbage collection is a must (as is the ability to avoid its use when necessary), and speed must be competitive with C++. A reasonable story for accessing C libs is also a must.

(Full disclosure: I have my own answer to this, but I'm interested to see what others have found to be good alternatives to C++ for real-time graphics work.)

Edit: Thanks everyone for the thoughtful replies. Given that there's really no "right" answer to this question I won't be selecting any particular answer. Besides I'd just pick the language I happen to like as a C++ alternative, which wouldn't really be fair.

30条回答
放荡不羁爱自由
2楼-- · 2019-03-10 17:03

XNA is your best bet I think. Being supported by the .NET framework you can build for a Windows or Xbox 360 platform by simply changing a setting in Game Studio. Best yet, all the tools are free!

If you decide to go with XNA you can easily get started using their quickstart guide XNA Quickstart guide

It has been a rewarding and fun experiance for me so far, and a nice break from the memory management of C++.

查看更多
Ridiculous、
3楼-- · 2019-03-10 17:04

Objective-C looks like a good match for your requirements (the latest version with optional GC), although it is too dynamic and Smalltalk-like for my taste.

查看更多
forever°为你锁心
4楼-- · 2019-03-10 17:05

I disagree with your premise. When used carefully and properly, C++ is a great language, especially for a domain like real-time graphics, where speed is of the essence.

Memory management becomes easy if you design your system well, and use stl containers and smart pointers.

std::vector::const_iterator it = lotsOfThingys.begin()) will become much shorter if you use

using namespace std;
typedef vector::const_iterator ThingyConstIter;

And you can shorten compile times significantly by breaking up your systems into reasonably self-contained modules, by using precompiled headers, or by using the PIMPL idiom.

查看更多
\"骚年 ilove
5楼-- · 2019-03-10 17:05

You can look at Ada. There is no garbage collector but this language is oftenly used for real-time system needing high reliability. That means less debuging times for your 3D applications.

And, you can also look at Haskell, if you don't know the functional paradigm this language will look weird to you, but it's worth a bit of your time. Tim Sweeney (EPIC Inc) is considering this language as a C++ alternative.

查看更多
We Are One
6楼-- · 2019-03-10 17:07

What about D Programming Language?

Some links requested in the comment:

Win32 Api

Derelict (Multimedia lib)

查看更多
混吃等死
7楼-- · 2019-03-10 17:08

I wouldn't discard C++. In fact, I would consider adding Boost to your C++ library, which makes the language much more usable. Your example would become:

BOOST_FOREACH( Thingy& t, lostOfThingys ) {
    // do something with 't'
}

Boost has tons of tools that help make C++ a better language.

查看更多
登录 后发表回答