[Semi OT] Language for Game Development talk

Manu via Digitalmars-d digitalmars-d at puremagic.com
Fri Sep 26 08:21:17 PDT 2014


On 26 September 2014 17:24, po via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
>> std::string tends to be more complicated because of the small string
>> optimization.  Most debuggers I've used don't handle that correctly out of
>> the box, even if sorting it out really isn't difficult.
>
>
>  Almost all game developers use Visual Studio, and VS has supported
> visualization of all STL containers(including string) since VS2005.
>
>
>> This is really missing the point. He knows RAII is useful and he knows
>> RAII solves freeing free'd memory. Maybe it's time to re-watch the video.
>
>
>  I watched it. None of what he said made much sense.
> His claims:
> 1. RAII is bad because exceptions.
>   -Nothing forces to use exceptions, so irrelevant
> 2. RAII is bad because you must write copy constructor,destructor etc each
> time.
>   -No you write a few basic template classes and reuse them.
>
>
>
>> Regarding exceptions, they can be used incorrectly, but I think they tend
>> to provide better error handling than return codes *because no one ever
>> checks return codes*.  And when you do pathologically handle error codes,
>> the amount of code duplication can be tremendous, and the chance for errors
>> involving improper cleanup can be quite high.  Though again, RAII can be of
>> incredible use here.
>
>
>  That is all true, I agree that exceptions are better than error codes.
> But for games, the general design is that errors are impossible.
> The game should never fail so exceptions serve little purpose.
>
> -ran out of memory? Shut game down, this should not happen
> -couldn't open a file? Shut game down, this should never happen
> -out of bounds array access, invalid iterator etc: abort game, found during
> development, fixed, should never happen.
>
> -networking? This is one place where you do need to handle errors, but do
> you need exceptions just to handle this one case? Probably not

This.
I've never used an exception before. I can't imagine a reason I would
ever want to.
Networking problems won't be solved with an exception, that requires
very comprehensive logic.


More information about the Digitalmars-d mailing list