You are viewing a single thread.
View all comments
136 points

Your game will actually likely be more efficient if written in C. The gcc compiler has become ridiculously optimized and probably knows more tricks than you do.

permalink
report
reply
-4 points
Deleted by creator
permalink
report
parent
reply
21 points

Yep but not if you write sloppy C code. Gotta keep those nuts and bolts tight!

permalink
report
parent
reply
30 points

If you’re writing sloppy C code your assembly code probably won’t work either

permalink
report
parent
reply

Except everyone writing C is writing sloppy C. It’s like driving a car, there’s always a non-zero chance of an accident.

Even worse, in C the compiler is just waiting for you to trip up so it can do something weird. Think the risk of UB is overblown? I found this article from Raymond Chen enlightening: https://devblogs.microsoft.com/oldnewthing/20140627-00/?p=633

permalink
report
parent
reply
46 points

Especially these days. Current-gen x86 architecture has all kinds of insane optimizations and special instruction sets that the Pentium I never had (e.g. SSE). You really do need a higher-level compiler at your back to make the most of it these days. And even then, there are cases where you have to resort to inline ASM or processor-specific intrinsics to optimize to the level that Roller Coaster Tycoon is/was. (original system specs)

permalink
report
parent
reply
2 points

I might be wrong, but doesn’t SSE require you to explicitly use it in C/C++? Laying out your data as arrays and specifically calling the SIMD operations on them?

permalink
report
parent
reply
5 points

There’s absolutely nothing you can do in C that you can’t also do in assembly. Because assembly is just the bunch of bits that the compiler generates.

That said, you’d have to be insane to write a game featuring SIMD instructions these days in assembly.

permalink
report
parent
reply
1 point

Honestly, I’m not 100% sure. I would bet that a modern compiler would just “do the right thing” but I’ve never written code in such a high performance fashion before.

permalink
report
parent
reply

RetroGaming

!retrogaming@lemmy.world

Create post

Vintage gaming community.

Rules:

  1. Be kind.
  2. No spam or soliciting for money.
  3. No racism or other bigotry allowed.
  4. Obviously nothing illegal.

If you see these please report them.

Community stats

  • 3.4K

    Monthly active users

  • 1.1K

    Posts

  • 8.8K

    Comments