Live data from Hacker News

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

jonathanwhiting.com

241–250 of 288 posts

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

#241
post #96
post #15

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

Not every compiled language has a de facto standard compiler, but with SBCL Common Lisp compiles pretty quickly. The Pascals (and Delphi) also tend to have rather fast compile times. I believe Jai is supposed to compile quickly but I'm not in the beta so I don't know. C can be quite good if you know what you're doing and use a decent compiler.

I should really have specified fast compiling implementations.

It does make me wonder why Pascal never became more popular. Fast compiling is a big advantage.

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

#242

Earlier quoted context omitted.

Usually you start with just one feature, like std::map instead of OpenSSL's abomination of a hashmap library or rolling your own. Of course you should use std::unordered_map instead of std::map because the latter is actually a treemap, but you probably don't know that when you first learn it...

Nah, I prefer to just use C, because at least I can parse the quite sane and helpful error diagnostics when I omit a semicolon or something, instead of getting 15 pages of unreadable garbage dumped into my lap by the oh-so-wonderful C++ standard library. (Which quite frankly isn't much of a "standard" when there's about a dozen different real world interpretations of the code depending on which flavor of which compil…

LPT: scroll up to the top of the error message. Typically it's "could not match this function call" followed by "here's all the things that might match and why they don't match"

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

#243
post #192

Earlier quoted context omitted.

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.

Ah, the C++ guy who think you need all the features of C++ to be efficient... Many people of people are super productive in C. There is a cost, but this is usually just some initial overhead to identify / write some libraries. In a larger project this initial overhead is irrelevant.

If someone is using a C++ feature it's because they think the feature is better than not using it. std::string lets you treat strings as easily as ints — subject to a run–time cost. You can make libraries that make strings easier to use in C, but you can't make one that makes them as easy as ints.

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

#244

Earlier quoted context omitted.

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.

> It's really just a struct with associated functions. If that were actually true C++ would be a lot easier to accept as a 'C successor'. Instead you have the implicit this-pointer, complicated rules for which constructor or operator overload is actually called, a hidden vtable pointer (not to mention multiple inheritance), then you have public/private/protected, override vs final, const methods (which wouldn't be ne…

It has lots of optional features, none of which make it an object–oriented language. It's an everything–oriented language. It has lambda syntax for functors, but you're not calling it an impure–functional programming language. Virtual functions are one feature, which is useful in pseudo–object–oriented code.

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

#245
post #235
post #228

Earlier quoted context omitted.

There are other C++ compilers to benchmark against, using the same common C subset for comparison, though.

Is there still any non-LLVM C++ compiler left besides GCC? LLVM is not exactly known for its speed.

MSVC?

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

#246
post #221

Earlier quoted context omitted.

I can't find it with a more specific search on SO, maybe it was deleted. The question was like: I wrote "hello world" but I get some compile errors, followed by an image embed of a handwritten hello world program, followed by a compiler command where the input file had a .png extension and an error related to the compiler not being able to read PNG files, followed by quoting the part of the standard where it says the…

I'll take things that never happened for $500, Alex

I searched harder, just for you.

https://stackoverflow.com/questions/5508110/why-is-this-prog...

How would you like to send the $500? Monero is acceptable.

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

#247

Earlier quoted context omitted.

I think the productivity question hinges on what you count as the language versus the ecosystem. Very few nontrivial games are written in "just C". They are written in C plus a large pile of bespoke libraries, code generators, asset pipelines, and domain-specific conventions. At that point C is basically a portable assembly language with a decent macro system, and the abstraction lives outside the language. That can…

> I agree on C++ being the worst of both worlds for many people. You get abstraction, but also an enormous semantic surface area and footguns everywhere. Not only that, but who even knows C++? It keeps changing. Every few years "standard practice" is completely different. Such a waste of energy. > Java is interesting because the core language is indeed small and boring in a good way, much closer to C than people admi…

> no-unsigned-integers [...] still bothers me

I like the lack of unsigned integers in Java. It simplifies the language while only removing a tiny bit of functionality. You can emulate almost all unsigned math using signed operations, whether you use a wider bit width or even the same bit width. The only really tricky operations are unsigned division and unsigned parseInt()/toString(), which Java 8 added to smooth things over.

https://www.nayuki.io/page/unsigned-int-considered-harmful-f...

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

#248
post #219

Earlier quoted context omitted.

It doesn't link. Something about undefined symbol _main. Can you help?

It doesn't need to link. That is the complete program. Are you suggesting I need to pass a flag to the C++ compiler to disable the linker? How do I do that?

Oh, I see what you meant now. I don't think it works:

./test: line 1: hlt: command not found

./test: line 2: jmp: command not found

Do you get a dopamine hit out of this?

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

#249
post #218

Earlier quoted context omitted.

Automatic memory management is literally what makes them better

For many string operations such as appending, inserting, overwriting etc. the memory management can be made automatic as well in C, and I think this is the main advantage. Just automatic free at scope end does not work (without extensions).

You can make strings (or bignums or matrices) more convenient than the C default but you can never make them as convenient as ints, while in C++ you can.

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

#250

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…

> I would suggest him Odin as perhaps the best of both worlds between C and Golang.

It's interesting to me that you say this, because it's the exact way that I describe Zig to people. Especially with the new std.Io async / concurrency changes. Do you feel Odin fits the space between Go and C better than Zig? Or just differently, and they both share the same space?

Post reply on HN