Live data from Hacker News

Why I Write Games in C

jonathanwhiting.com

21–30 of 303 posts

Re: Why I Write Games in C

#21
The 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 actually much worse than many languages of its time. But it is certainly stricter than Javascript.

GCs and gaming are of course a challenge, but with the new GC of Go1.5 and hopefully futher improvements, it might actually become a very good language for gaming, especially if there is a better support with libraries. But if one wants good type checking, a simple language model and fast compilation times, it checks all the boxes.

Re: Why I Write Games in C

#22
Incidentally, all of his reasons that don't misrepresent C are all the same reasons I write games in JavaScript. Mostly, it's about speed of development, understanding, and platform compatability. Performance is good enough and almost always my fault when it isn't.

I wish for a strictly typed language, but OP isn't using one, either. I've tried several of the transpilers and have generally found the workflow lacking in one way or another.

Re: Why I Write Games in C

#23
If 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 dislike the ambiguity of the phrasing.

Re: Why I Write Games in C

#24
post #11

I thought Lua was great for games development, the author does not mention it. http://www.lua.org

Lua is widely used as a scripting layer on top of a game engine. The intense calculations needed to generate a high-fidelity simulation like graphics and physics are usually implemented in the engine in C++, and then the game logic/item behavior/etc. is defined in Lua. I haven't heard of anyone using pure Lua for a whole game, including the engine. It'd be really interesting to see what it looked like if someone did…

there are plenty of games using pure Lua. www.love2d.org :)

Re: Why I Write Games in C

#25
post #20
post #13

Did anyone break it to him that when he writes C, he is writing C++?

C is not a true subset of C++ so no, when he is writing C he is writing C.

Given he is calling C a strictly typed language, I'm not sure the OP really knows C that well. Sure, it's strictee than, say, PHP. But in the pantheon of languages, it's not objectively strict.

Re: Why I Write Games in C

#26

What about Rust?

Maybe in ten years. Great thing about old mature technology such as C is that all gotchas have been tripped over innumerable times and are all well known and codified. Meanwhile new exciting technology like Rust contains unknown number of bugs like http://www.wabbo.org/blog/2014/22aug_on_bananas.html, undiscovered antipatterns and subtleties.

My comment is not meant to bash Rust, on the contrary it is very promising and the fact that it is used to write Servo is likely to significantly speed up its maturation. But as author notes, if you are developing a project under a deadline you don't have time for bugs you didn't cause yourself. So old boring technology is the way to go.

Re: Why I Write Games in C

#28

The 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…

The trade-off with templates is much slower compilation times. Often slow C++ compile times can be traced to enthusiastic use of templated types, particularly given that standard types like std::string are often defined as templates themselves.

Re: Why I Write Games in C

#29

Earlier quoted context omitted.

Lua is widely used as a scripting layer on top of a game engine. The intense calculations needed to generate a high-fidelity simulation like graphics and physics are usually implemented in the engine in C++, and then the game logic/item behavior/etc. is defined in Lua. I haven't heard of anyone using pure Lua for a whole game, including the engine. It'd be really interesting to see what it looked like if someone did…

there are plenty of games using pure Lua. www.love2d.org :)

No, Only the scripting is Lua. The engine is all in C++.[1]

[1] https://bitbucket.org/rude/love/src/tip/src/

Re: Why I Write Games in C

#30
post #20

Earlier quoted context omitted.

C is not a true subset of C++ so no, when he is writing C he is writing C.

Given he is calling C a strictly typed language, I'm not sure the OP really knows C that well. Sure, it's strictee than, say, PHP. But in the pantheon of languages, it's not objectively strict.

I mentioned this in another comment, as has many others.
Post reply on HN