Live data from Hacker News

I write games in C (yes, C) (2016)

jonathanwhiting.com

31–40 of 288 posts

Re: I write games in C (yes, C) (2016)

#31
post #28

Earlier quoted context omitted.

DirectX is C++ (technically a set of COM interfaces) and most game engines are also C++. Unlike, say, Linux programming where C is the standard, almost all games have been written exclusively in C++ for a long time now, probably three decades.

There are a few exceptions though, like most mobile games, visual novels (many of which use Python of all languages, due to an excellent framework called ren'py), and of course games written using Unity or XNA, which use .NET languages. Also, three decades is going a bit too far back, I think. In the mid nineties, C was still king, with assembly still hanging on. C++ was just one of several promising candidates, with…

In J2ME feature phones Java was all there was, and even today many indies do use it on casual titles on Android.

Which is why after so much resistance not wanting to use the NDK for Vulkan, and keeping using OpenGL ES from those devs, Google is bringing WebGPU to Java and Kotlin devs on Android.

Announced at last Vulkanised, there is already an alpha version available, and they should talk more about it on upcoming Vulkanised.

Re: I write games in C (yes, C) (2016)

#33
Plenty of people cycle on a fixie too. So what? C, especially modern C, does provide metaprogramming and abstraction facilities. In practice, you can even get things like the "defer" construct from other languages: https://lwn.net/Articles/934679/

The question isn't "Can I write a game in C?". Yes, of course you can, and it's not even that painful. The question is "Why would you?", and then "Why would you brag about it?"

> C++ covers my needs, but fails my wants badly. It is desperately complicated. Despite decent tooling it's easy to create insidious bugs. It is also slow to compile compared to C. It is high performance, and it offers features that C doesn't have; but features I don't want, and at a great complexity cost.

C++ is, practically speaking, a superset of C. It being "complicated"? The "insidious bugs"? It being "slow to compile"? All self-inflicted problems. The author of this article can't even fall back on the "well, my team will use all the fancy features if I let them use C++ at all!" argument pro-C-over-C++ people often lean on: he's the sole author of his projects! If he doesn't want to do template metaprogramming, he... just doesn't want to do it.

I don't read these sorts of article as technical position papers. People say, out loud, "I use C and not C++" to say something about themselves. ISTM that certain circles there's this perception that C is somehow more hardcore. Nah. Nobody's impressed by using it over a modern language. It really is like a fixie bicycle.

Re: I write games in C (yes, C) (2016)

#34

I totally resonate with the author of the post. My main requirement to enjoy a language deeply is often simplicity, so I love languages like, C, Golang, Odin and Zig. That said, I also acknowledge that often times I need to solve problems that can benefit from a language that embraces what I call necessary complexity, but do it in elegant ways. Whenever I need to prioritise code correctness, especially memory and con…

The language is called Go, golang is the website domain.

Re: I write games in C (yes, C) (2016)

#35

>Death of flash >The library support for games[in Go] is quite poor, and though you can wrap C libs without much trouble, doing so adds a lot of busy work. I can't see when this was written, but it has to be around 2015. So, about 10 years ago. I wonder what his opinion is today.

The first capture of the page on Internet Archive Wayback Machine is from January 9th, 2016. So it’s at least that old.

Also here is a snapshot of the main page of his website from that time, which has screenshots of his games and thereby provides context into what kind of games he had made and published when the blog post was written.

https://web.archive.org/web/20160110012902/http://jonathanwh...

This one looks like it’s 3d and has a pretty unique style:

https://web.archive.org/web/20160112060328/http://jonathanwh...

Re: I write games in C (yes, C) (2016)

#36
> I like Go a lot. In many ways it is C revisited, taking into account what has be learnt in the long years since it was released. I would like to use it, but there are big roadblocks that prevent me. The stop-the-world garbage collection is a big pain for games, stopping the world is something you can't really afford to do.

I'm no Go fan, to be clear, but GC isn't the problem with Go. It has a pretty decent GC with sub-millisecond pause times. People who complain about GC pauses while extolling the virtues of manual memory management are running on a set of prejudices from 1999 and are badly in need of a mental firmware update.

Re: I write games in C (yes, C) (2016)

#37
post #15

> when it comes to compilation I can't think of anything faster. What languages compile fastest?

Rust can be up there with C depending on the project.

Any language can be, depending on the project. Rust compile is slower than C, on more than average. That's it.

Re: I write games in C (yes, C) (2016)

#38

Yes, C. Like all id games up to... Doom 3, if I'm not mistaken? Only then they switched to C++. There's absolutely nothing impressive about this fact.

Nobody claimed it was impressive. It’s a little unusual to use C instead of C++, but that’s about it.

Re: I write games in C (yes, C) (2016)

#39
I always liked C. I enjoyed how brutal it is, except the preprocessor.

This is why zig is a godsend. It is actually simpler than C while being more precise than C!

For example zig can distinguish between a pointer to a single element vs a pointer to an array of unknown length. Where as in c abi, it is all T*

When importing a c lib, you can make it more ergonomic to use than c itself.

Being able to easily import c lib is especially important to game dev, as practically all so called c++ libs also export a c header as they know how important it is.

https://github.com/zig-gamedev has a lot of repos of ziggified c libs used in games.

As for the preprocessor, zig comptime is so much better. It’s just more zig that runs at compile time.

Re: I write games in C (yes, C) (2016)

#40
C has very low entry level, providing that you have some knowledge about memory management. When, as a Java developer, I had to quickly deliver some exchange connector using given .h and .so, I chose C, because C++ had too high entry level. If C is a sharp knife, C++ is a rotating pell post full of sharp knives. You can cut yourself even if you think you're safe.

But I find string management in C awful and would like to borrow it from C++. Only the string management

Post reply on HN