News for hackers. Stuff that matters.
Re:The gold standard of optimization: A look under the hood ... by mort96 on Sunday March 22, 2026 @06:08PM (#47482737)
I think Minecraft's lighting system is a good example: there are 16 different brightness levels, from 0 to 15. This allows the game to store light levels in 4 bytes per block.

Similarly, redstone has 16 power levels: 0 to 15. This allows it to store the power level using 4 bits. In fact, quite a lot of attributes in Minecraft blocks are squeezed into 4 bits. I think the system has grown to be more flexible these days, but I'm pretty sure the chunk data structure used to set aside 4 bits for every block for various metadata.

And of course, the world height used to be at 255 blocks. Every block's Y position could be expressed as an 8-bit integer.

A voxel game like that is a good example of where this kind of efficiency really matters since there's just so much data. A single 1616256 chunk is 65.5k blocks. If a game designer says they want to add a new light source with brightness level 20, or a new kind of redstone which can go 25 blocks, it might very well be the right choice to say no.

Re:The gold standard of optimization: A look under the hood ... by tosti on Sunday March 22, 2026 @07:54PM (#47483670)
I don't think Minecraft would be considered a cornerstone of optimal programming.
Re:The gold standard of optimization: A look under the hood ... by kulahan on Sunday March 22, 2026 @08:20PM (#47483874)
The entire program doesn't need to be a cornerstone of optimal programming for this one example to hold true.
Re:The gold standard of optimization: A look under the hood ... by helterskelter on Sunday March 22, 2026 @08:20PM (#47483883)
The 4 bit stuff is a hangover from Mojang having to squeeze every bit of perf from their Java based engine that they could. Their original sound engine was so sketchy that C418's (music composer) minimalist sound is partly because it really couldn't handle much more than what got released.

MS has been loosening up on the 4 bits limit and have created a CPP variant of Minecraft which performs better, but they've also introduced their unified login garbage that has almost made me give up Minecraft completely.

Re:The gold standard of optimization: A look under the hood ... by Pannoniae on Sunday March 22, 2026 @08:40PM (#47484024)
Hey, this isn't entirely accurate!

The 4-bit stuff is a hangover from Notch doing this (I'd maybe even say a similar-calibre programmer to Chris Sawyer...). The sound has nothing to do with technical limits, that's a post-facto rationalisation.

The game never played midi samples, it was always playing "real" audio. The style was an artistic choice, many similar retro-looking games were using chiptune and the sorts. It's a deliberate juxtaposition...

The CPP variant doesn't really perform better anymore either.

Re:The gold standard of optimization: A look under the hood ... by helterskelter on Sunday March 22, 2026 @09:35PM (#47484444)
Fair enough, I mostly meant to point out some of those design decisions predate MS, as much as I love to hate on them. The music was just an interesting bit of trivia I read the other day.
Re:The gold standard of optimization: A look under the hood ... by Pannoniae on Sunday March 22, 2026 @10:17PM (#47484769)
Yeah, 100% :) Ironically, the design constraints are one of the big things which made it work so much! If it was designed in a "traditional" way, it would have been much less ambitious.
Re:The gold standard of optimization: A look under the hood ... by imtringued on Monday March 23, 2026 @05:51AM (#47487250)
Bedrock Edition has a smaller simulation distance, which is kind of the opposite you'd expect from the more "optimized" version.
Re:The gold standard of optimization: A look under the hood ... by mort96 on Sunday March 22, 2026 @09:35PM (#47484448)
Minecraft is, and always has been, handling vast amounts of data at pretty good performance. It's not an impossibly difficult task, many other people have made voxel game engines which are better, but it's something you can't do without paying attention to these things. Every voxel engine with remotely reasonable performance needs to carefully count bits used per block.
Re:The gold standard of optimization: A look under the hood ... by nitwit005 on Monday March 23, 2026 @03:36PM (#47494111)
You can find other people discussing implementing similar games on YouTube, and the need to cram the representation of blocks into as small a size as possible always comes up.

Information about blocks is the overwhelmingly dominant thing being stored in memory for those games, so naturally reducing the size of that data becomes important.