Live data from Hacker News

Why I Write Games in C

jonathanwhiting.com

151–160 of 303 posts

Re: Why I Write Games in C

#151
C++ compile and link time. I once worked on a PS3 game that had a 50 minute turnaround time (change code -> compile -> link -> load). No scripting either. The horror. It was because the company had home brewed a bunch of "optimizations" into the build process.

On the up side it will force you to learn to live edit the game with the debugger to tweak and adjust.

If its C++ and the programmers know the engineering KISS adage it can be ok. I have seen so much horrible needlessly complex C++. So bad you are pleasantly surprised it runs at all. C++ so bad and unpleasant to work on it makes you question why you are a programmer at all.

sigh

Then you write some python, C, ruby or lisp (or scheme, or clojure) and your like: "oh, now I remember why i do this again, this is so much fun!"

I like the simplicity of C too. You can have a good mental model right down the CPU of what is going on. But these days given how fast CPUs are and how much more productive you can be in a high level language (python is 10x more productive than C++, apparently) I think a garbage collected high level language is the way to go.

If I accept their offer, my next job will be using Golang.

Re: Why I Write Games in C

#152
post #151

C++ compile and link time. I once worked on a PS3 game that had a 50 minute turnaround time (change code -> compile -> link -> load). No scripting either. The horror. It was because the company had home brewed a bunch of "optimizations" into the build process. On the up side it will force you to learn to live edit the game with the debugger to tweak and adjust. If its C++ and the programmers know the engineering KISS…

Don't mix language features with engineering mistakes.

Re: Why I Write Games in C

#153
post #137

Earlier quoted context omitted.

if you don't want to watch the video, here is a basic overview tldw; of the technique: on every run of the game loop(usually every frame), reload a dynamically linked module (dll for windows, .so for linux), which contains the actual code you want to run every frame. The function you then invoke from the module must be passed the entire block of memory allocated for the game state. You then just recompile the dll/so…

I assume you'd be using techniques discussed here? http://stackoverflow.com/questions/384121/creating-a-module-...

yes - but different OS have different ways to load dynamically linked modules, and the casey video only showed the windows method. But it's basically the same, just library calls differently named.

Re: Why I Write Games in C

#154
post #147
post #105

>Even more than that I care about the speed of the compiler. I am not a zen master of focus, and waiting 10+ seconds is wasteful, yes, but more importantly it breaks my flow. I flick over to Twitter and suddenly 5+ minutes are gone. Quick suggestion, has really helped me: take that 10 or 20 seconds waiting for compilation, and stare out a window. This gives your eyes much needed break from focusing on a computer moni…

As good advice as this is, waiting 10 or 20 for compilation is just sad.

Have you never had a project larger than 10 files?

Re: Why I Write Games in C

#155
post #149
post #138

Earlier quoted context omitted.

- OOP you only get if you use it. - RAII you only get if you use it. - exceptions you only get if you enable them. - references. no overhead. - vtables. you only get them if you need them. - templates. no overhead runtime. - C++ standard library. you only get it if you need it. - what's wrong with vector ? hash map ?

Yeah, and what's left is not much of C++. See my post about runtime recompiling for arguments to use C compiler instead of a very limited subset of C++. (References make the type system more complex for little benefit. Templates create massive amounts of complexity and slow down my iteration loop. Already explained what's wrong with std::vector and std::unordered_map.)

- Compile times with templates are on my system under 10 seconds.

- I missed your vector and unordered_map discussion.

- "more complex" is not a useful metric to compare the language systems. Similar, I can easily say, that C pointer arithmetic is creates more complex situations when verifying that code is safe to use.

Re: Why I Write Games in C

#156
post #105

>Even more than that I care about the speed of the compiler. I am not a zen master of focus, and waiting 10+ seconds is wasteful, yes, but more importantly it breaks my flow. I flick over to Twitter and suddenly 5+ minutes are gone. Quick suggestion, has really helped me: take that 10 or 20 seconds waiting for compilation, and stare out a window. This gives your eyes much needed break from focusing on a computer moni…

>Quick suggestion, has really helped me: take that 10 or 20 seconds waiting for compilation, and stare out a window. Wow, that sounds pretty nice. I wish I had a window to look out of.

Or you know, just look away from the monitor, in the physical space of your office/whatever instead of a flat surface, which would have similar benefits.

Re: Why I Write Games in C

#158

Earlier quoted context omitted.

>Quick suggestion, has really helped me: take that 10 or 20 seconds waiting for compilation, and stare out a window. Wow, that sounds pretty nice. I wish I had a window to look out of.

Or you know, just look away from the monitor, in the physical space of your office/whatever instead of a flat surface, which would have similar benefits.

So many office spaces are rectilinear and planar. I find the fractal real world to be so much more restful to look at. It refreshes my mind in a way unlike any manufactured surface.

Re: Why I Write Games in C

#159

Earlier quoted context omitted.

Or you know, just look away from the monitor, in the physical space of your office/whatever instead of a flat surface, which would have similar benefits.

So many office spaces are rectilinear and planar. I find the fractal real world to be so much more restful to look at. It refreshes my mind in a way unlike any manufactured surface.

What the parent advised was not about what one finds "restful" or "refreshing the mind". It's about needed eye gymnastics -- re-focusing at different depths, etc.

Re: Why I Write Games in C

#160
post #152
post #151

C++ compile and link time. I once worked on a PS3 game that had a 50 minute turnaround time (change code -> compile -> link -> load). No scripting either. The horror. It was because the company had home brewed a bunch of "optimizations" into the build process. On the up side it will force you to learn to live edit the game with the debugger to tweak and adjust. If its C++ and the programmers know the engineering KISS…

Don't mix language features with engineering mistakes.

Oh, I agree. Its not the language's fault. You can write a good or bad program in any language. No language can save you on its own. But, as the expression goes: some programming languages give you enough rope to shoot yourself in the foot, other, enough rope to blow off the whole leg. I have done C++ for 14 years. It can be great and fast if you are careful.
Post reply on HN