Live data from Hacker News

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

jonathanwhiting.com

151–160 of 288 posts

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

#151
post #41

Earlier quoted context omitted.

Yeah, you could argue that choosing C is just choosing a particular subset of C++. The main difference from choosing a different subset, e.g. “Google C++” (i.e. writing C++ according to the Google style guide), is that the compiler enforces that you stick to the subset.

C's string handling is so abominably terrible that sometimes all people really need is "C with std::string". Oh, and smart pointers too. And hash maps. Vectors too while we're at it. I think that's it.

Add concurrency and you more or less came up with same list C's own creator came up when he started working on a new language.

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

#152
post #20

I write mostly like I would in C, but use C++ features as needed. It ends up looking similar to Rust if you squint. All these "I write games in C" people complain about C++ features, and then end up reimplementing virtual interfaces manually with struct headers or massive switch statements, just to feel better about themselves. Writing games in C is not harder, you just have to implement modern language features by h…

C++ reimplements a lot of the things we do in C with function pointers, while hiding what's actually happening behind topheavy syntax that implies a 1990s object oriented paradigm that's dead now.

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

#153
post #20

I write mostly like I would in C, but use C++ features as needed. It ends up looking similar to Rust if you squint. All these "I write games in C" people complain about C++ features, and then end up reimplementing virtual interfaces manually with struct headers or massive switch statements, just to feel better about themselves. Writing games in C is not harder, you just have to implement modern language features by h…

C++ reimplements a lot of the things we do in C with function pointers, while hiding what's actually happening behind topheavy syntax that implies a 1990s object oriented paradigm that's dead now.

Contrary to popular belief C++ isn't really object–oriented. I mean, you can write object–oriented code, but the language doesn't make assumptions about what goes into a class. It's really just a struct with associated functions.

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

#154
post #20

I write mostly like I would in C, but use C++ features as needed. It ends up looking similar to Rust if you squint. All these "I write games in C" people complain about C++ features, and then end up reimplementing virtual interfaces manually with struct headers or massive switch statements, just to feel better about themselves. Writing games in C is not harder, you just have to implement modern language features by h…

I remember the creator of Kaiju engine stating something about C++ compilers producing slower code with C-style C++.

That's probably to do with exceptions — possibly the only thing that pervades C++ code even if you don't use it. The compiler has to write code so an exception at any point leaves the stack in a sensible way, etc. Try -fno-exceptions (and -fno-rtti might save some memory while you're at it)

Regrettably not every C++ feature is free if you don't use it. But there aren't many that aren't.

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

#155
post #49
post #20

I write mostly like I would in C, but use C++ features as needed. It ends up looking similar to Rust if you squint. All these "I write games in C" people complain about C++ features, and then end up reimplementing virtual interfaces manually with struct headers or massive switch statements, just to feel better about themselves. Writing games in C is not harder, you just have to implement modern language features by h…

> Complaining about a language having features you don't want is silly. It might be silly if you're working on your own. Software that delivers a lot of value is usually developed and evolved not only by team, but by a team with changing members and changing leadership over the project's lifetime. The features used will be the union of all features used over the years, and while it's easy for team leads to allow the…

> Also, you may be forced to use language features you don't

This is quite important and often overlooked. An annoying fallacy is that people think some features are optional, but once they get heavily used, they aren't anymore. Often they quickly become an requirement and if you don't follow suit, your code is legacy or you are an idiot. But well, I guess I create legacy code upfront and the cargo cultists create modern code that turns into legacy next day.

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

#156
post #3
post #2

In my core I'm the same. C is my language and served me well for decades. There's nothing inherently major wrong with it until you reach one of the two (or both). Working in a group of people on a C codebase tends to introduce pain on multiple levels unlike some other languages (yes, including C++). The other is that anything takes a long-ass time to do compared to modern alternatives, which might also be an issue if…

Why do you think working with a group of people on a C codebase introduces pain unlike other languages? Working with a group of people always causes pain, but I found the pain much less severe for C than for C++.

C relies on the programmer to understand the lifetime of every object in the program, which is global structure. When the programmer is multiple people, it's easy to get out of sync. unique_ptr from C++ solves 90% of this.

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

#157

Earlier quoted context omitted.

COM was designed to be compatible with C. Linux games are also often written in C++. The ones written in C are just old.

Sure, but in practice COM is almost never used from C programs unless there is some integration into a very legacy codebase. Games are newly developed, they’re not enterprise database platforms.

OpenGL is commonly used from C++ too, or Java, but you labeled it as C.

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

#158

Earlier quoted context omitted.

C++ reimplements a lot of the things we do in C with function pointers, while hiding what's actually happening behind topheavy syntax that implies a 1990s object oriented paradigm that's dead now.

Contrary to popular belief C++ isn't really object–oriented. I mean, you can write object–oriented code, but the language doesn't make assumptions about what goes into a class. It's really just a struct with associated functions.

That's an odd opinion about a language with a lot of class related features. I can only assume you have a very strong definition of OOP.

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

#159
post #149

Earlier quoted context omitted.

Do you get a dopamine hit out of this?

Nothing about a dopamine hit out of it, no. Something about _main being an undefined symbol. Are you familiar with that error message?

How did your equivalent assembly program without a definition of _main to?

You're doing that thing. I think it's called "trolling". It goes like "hurr durr, they said take one, but they wouldn't let me take one plate" or "hurr durr, I filled my gas tank with nitrogen, which is a gas, but my car doesn't go" or "hurr durr, they said C++ features are all optional, but I don't want to use letters, how can I write C++ without using letters?"

At least when that guy asked Stack Overflow how to make gcc compile his .png, it was actually funny.

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

#160

As a hardcore C programmer and zealot myself... How in the hell can you be productive like that? C is a systems programming language, not an application programming language, let alone relevant to the levels of abstraction you'd want in game development. That said, "I am dead" is a very real video game indeed... and his arguments are very sound. I also can't stand C++. I disagree with him on Java though. The core lan…

You have to try it. You can write anything you want in C. Or assembler. It's hardly going to be very productive but... productivity is greater than zero, and the more you try the better you get. Rollercoaster Tycoon was written by hand in assembly, as were all NES and SNES games including ones like Earthbound and A Link to the Past — and SNES assembly isn't nearly as nice as x64.
Post reply on HN