Earlier quoted context omitted.
Is Rust available on consoles? (AFAIK, no) Is it going to be around? (Who can tell?)
https://twitter.com/rustlang/status/598945014824173569
Why I Write Games in C
41–50 of 303 posts
Re: Why I Write Games in C
#42I understand funny things happening under the hood (garbage collection) might not look attractive ; However you can't require everything to be explicit and, at the same time, keep your programs simple/small.
The more you want your code to be small, the more you're gonna need a programming environment (language/API/runtime/framework) doing things for you under the hood. And there's nothing wrong about it!
Re: Why I Write Games in C
#43The article mixes up the virtues of a programming language with the quality of the environment. C might very well be the best language in our current environment, which says little about the language itself. One major point certainly is, that it is that good compilers are available everywhere and almost any library can be used from C. There are a lot of historic reasons for that. If he wants strict typing, C is actua…
The Google Go team lives in a completely different environment. Their perspective of performance is not the same as a game dev. Go 1.5 stated their goal was 10ms GC latency. A game loop is 16ms for a 60fps game. 10ms is not close to acceptable. Fast for a web server backend, but not fast for a game.
Re: Why I Write Games in C
#44If by "strict typing" you mean strongly typed then you are factually incorrect. By virtue of casting C is weakly typed, as is Java, C++ et al. If your understanding of strict typing is statically typed, i.e. that types are checked at compile time then C still has some flaws as you could write a whole slew of C that is "typeless" using void * although that would be terribly misguided. I understand your intent, but I d…
Java's casts are dynamically checked, memory-safe and only work through the inheritance hierarchy, if you try to cast to an invalid type you'll get an error. Putting it in the same class as a C-style cast makes your usage of "weakly typed" as meaningless as it ever is.
For C++ — ignoring C-style casts — it depends which cast you use, dynamic_cast requires RTTI but IIRC it offers the same guarantees as Java's cast; static_cast should check that the types are related and the conversion is valid at compile-time, reinterpret_cast is the "weakly typed" one (essentially a simpler version of a C-style cast).
> I understand your intent, but I dislike the ambiguity of the phrasing.
Yet you use the expressions "strongly typed" and "weakly typed"?
Re: Why I Write Games in C
#45Re: Why I Write Games in C
#46C is very simple and it's missing a Hindley-Milner type system.
If that was a part of it, I'd use it.
C++ wins now, every time. Type safety in C is a pain.
Re: Why I Write Games in C
#47What about Rust?
I like Rust, but sometimes it is pretty difficult to convince the compiler that one's code is safe. And this does not mean that the compiler is preventing unsafety; there are many safe programs that the compiler rejects. Also, the OP said that compile time was a priority, and compiling Rust code is closer to C++ speed than C.
It's often less about being safe currently and more about being resilient to breaking after further changes in code. I've worked with some C++ codebases that rely on complicated invariants to be safe (so the code looks safe now), and stuff breaks down when certain changes are made. Programming with a C++11 style greatly reduces but does not eliminate this.
It takes a while to get a hang of this, but once you figure out the "Rust way" of moving data/references around you tend to hit these errors very rarely. Of course, this takes time to learn which you may not have :)
But yes, there are things which Rust could improve upon here, like nonlexical scopes and SEME regions. Which may come soon.
Re: Why I Write Games in C
#48The thing I miss most in C when I don't cheat and use a couple C++ features is templates. Specifically, a dynamically sized List implementation that is type-generic. If you do this in pure C, you have to pick your poison: 1. preprocessor abuse 2. void * 3. multiple redundant implementations of the data structure Dynamically sized lists are used so often, that this tends to be a problem in almost every C project. I wo…
Just use queue.h, as do all the BSDs. https://github.com/freebsd/freebsd/blob/master/sys/sys/queue...
Re: Why I Write Games in C
#49The thing I miss most in C when I don't cheat and use a couple C++ features is templates. Specifically, a dynamically sized List implementation that is type-generic. If you do this in pure C, you have to pick your poison: 1. preprocessor abuse 2. void * 3. multiple redundant implementations of the data structure Dynamically sized lists are used so often, that this tends to be a problem in almost every C project. I wo…
Apparently, the implementation is complex enough to drive an ordinary mortal like myself insane, but it is hidden behind a very simple interface, and it is blazingly fast. It only gave me problems when trying to use boehmgc, because it does not detect pointers stored in a Judy tree.
Re: Why I Write Games in C
#50Earlier quoted context omitted.
If you're going to write a TL;DR for others, you should at least read the article yourself, don't you think?
I did, it is so abstract to pretend you can do better that there is no way to discern. He didn't even mention "unity" in his post, thats just ridiculous in 2016, but yeah, keep down voting, your implementation of 2d graphics, sound, collision, physics, plugins, marketing, sprites, menus is gonna be so much better than hundreds of engineers at unity withing 10 years straight.