Hacker Newsnew | past | comments | ask | show | jobs | submit | Pombal's commentslogin

Most studios wouldn't consider changing from C or C++, but the only other realistic options as of 2020 are D and Rust.


You are describing 'zero cost abstractions'. Except that they are anything but zero cost. Game developers and low level programmers shy away from them because of their impact in compile and build times, debug build performance and stack trace bloat, increased cognitive load, reduced refactoring ability. Even std::unique_ptr has runtime costs in release builds that a raw pointer does not.

In game development performance is a feature and anything that makes performance and memory usage less deterministic is frowned upon, like a GC. But iteration times are still paramount and things that make compile, load and link times longer and make it more difficult to debug are also frowned upon. Yes, we'd like to have our cake and eat it too :)


> You are describing 'zero cost abstractions'

No, that's a different (and orthogonal) concept. The point is that in C++ "you don't pay for what you don't use" - whether it's a cheap or an expensive abstraction, if you don't use it then its overhead won't affect your code's performance.

However, many of the C++ abstractions are zero-cost in many common cases.

> Game developers and low level programmers shy away from them

No, they don't. They shy away from abstractions which are too expensive; or whose scope of optimization doesn't fit the game's use; or which don't combine well with out-of-standard-library code used in the game etc.

But game developers use _lots_ of C++ abstractions; and fancy non-C-like C++ features.


> Even std::unique_ptr has runtime costs in release builds that a raw pointer does not.

O RLY ? https://gcc.godbolt.org/z/QhbUjI


Yes, really. It's fine for simple types but for more complex types in more complex situations, you pay the price.

Unique pointers carry around not just the type but also a default deleter, if you provide one. That deleter has to be copied around, checked for nullptr before execution and set to nullptr when ownership changes.

For even more examples of this have a look at this talk when it comes out: https://cppcon2019.sched.com/event/Sfq4/there-are-no-zero-co...


Only if the deleter you define has any state, which is very rare and in that case you would need to copy that data around anyway...

(for example: https://gcc.godbolt.org/z/mU7hub)


It's pretty stupid to compare a unique_ptr with a deleter that contains state to a pointer - obviously those two things are completely different and the unique_ptr contains way more information.


How would I create the pointer to int in the unique_ptr case without initializing the int? I tried this: https://gcc.godbolt.org/z/SfVxzU

I expect there is a way, just I don't know it.


See the docs : https://en.cppreference.com/w/cpp/memory/unique_ptr/make_uni...

For C++ < 20 replace `std::make_unique<int>()` by `std::unique_ptr<int>(new int)` (which with all explicit uses of `new` can end up not being safe in some cases (in that case, only if you've not enough memory to allocate an int which should not really be a common occurence...)

For C++ >= 20 you get std::make_unique_default_init which does that properly.


Have created a Stackoverflow question focused on this point:

https://stackoverflow.com/q/58050872/1593077


I would recommend you learn by doing, one step at a time.

Here is an example path that builds skills on top of each other, mostly geared towards programming, based on the background info you provided:

1. Create Tic Tac Toe. This will get you familiar with the core game loop. Read input, update game state, draw, repeat. It is a bounded project so you can finish it. Finishing projects is a skill on its own. If you want to use C or C++ have a look at Simple DirectMedia Layer (SDL) or Simple and Fast Multimedia Library (SFML). These libraries abstract OS functions like reading inputs and putting pixels on the screen so you can focus on the core game mechanics. If you want to use Python look at PyGame, for example. The industry mostly uses C++ with Visual Studio so keep that in mind if you want to join a company later on. Here you can find some tutorials on SDL: http://lazyfoo.net/tutorials/SDL/index.php

2. Create Pong or Breakout or any such 2D game with familiar mechanics. Then asteroids. Then battle city. Then super mario land. Each of these on its own teaches you a skill that you didn't have before. If you find yourself repeating the same code, abstract it away. This is the beginning of a game engine - a small framework of reusable components from game to game.

3. Once you have done enough 2D projects that you feel like you have a good grip on most components individually and how they come together as a whole, move on to 3D. Read Game Engine Architecture. Read good open source game code like the doom3 http://fabiensanglard.net/doom3/index.php Create small graphics demos where you can learn how to use shaders - shaderToy is helpful here. Create 3D Tetris.

4. By this point you will know enough about games to be dangerous. You will know what is most interesting to you. Maybe it's AI, or graphics, or physics, etc. Create demos and games that showcase that field you are really interested in. Try and partner up with people with complementary skills to yours.

There are many ways to learn game development, the one I'd recommend the most is the one that seems most interesting to you and gets you actually creating and finishing games.


Yep, see polystream.com


I believe there will be of more interest now for two main reasons:

- Ubiquitous frictionless headphones with built in mics like the AirPods.

- More demand and access to remote working where people are alone at home.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: