Show HN: NES Contra (1987) port (ASM –> C and then C –> WebAssembly)
A browser-based port of the 1987 NES game Contra converts its assembly code to C and then WebAssembly. It supports solo play and online two-player games. (epoyraz.github.io)
GCC can lower switch statements in several ways, rather than always building a comparison tree. For compact ranges of values, it uses a jump table, including when the cases share a constant offset from zero. Experiments suggest a rough density rule: a table is considered when its number of entries is less than about eight times the number of case labels. Thus five cases spanning values 0-34 can become a table, while five cases spread across 0-40 become a comparison tree. GCC can also isolate distant outliers: a dense run of cases may use a jump table while a faraway case is handled separately. However, it does not recognize every possible simplification, such as scaling evenly spaced inputs before dispatch.
The chosen strategy also depends on what the cases do. Multiple labels that lead to the same result can be combined into ranges and handled with a small set of comparisons, avoiding a large table. For suitable clusters of nearby values, GCC can instead use bit-test lowering: it encodes which values are valid in a bitset and tests the corresponding bit. The discussion traces these choices to GCC’s switch-lowering pass. It first groups labels by their destination and probability, then searches for bit-test clusters, jump-table clusters, and other groupings. This explains why switch compilation reflects not only how many values appear and how far apart they are, but also whether cases share destinations and whether subsets can be efficiently represented.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.
A browser-based port of the 1987 NES game Contra converts its assembly code to C and then WebAssembly. It supports solo play and online two-player games. (epoyraz.github.io)
PostgreSQL’s TOAST storage made the table much smaller, and counting or scanning rows was faster than with the larger uncompressed table. But reading a field inside every toasted value required far more buffer reads, showing that TOAST can trade space savings for slower access to large values. (pgedge.com)
Large GROUP BY hash tables cause frequent slow RAM accesses, leaving CPUs stalled even when monitoring shows 100% usage. Processing data in smaller chunks can improve cache use and speed up aggregation, even if it requires more CPU work. (pivotlake.io)
Enlightenment 0.28 adds initial NetBSD support, a NetworkManager module, and native PipeWire mixer support while retaining PulseAudio compatibility. The release also improves window management, display handling, and X11 and Wayland support, alongside numerous fixes and code cleanups. (phoronix.com)
Nonna is a TypeScript dependency-injection framework and ahead-of-time compiler that avoids reflection and runtime dependencies. It supports Node.js, Deno, Bun, edge runtimes, and major frontend frameworks, with request scoping and deterministic lifecycle hooks. (nonna.nodeboot.io)
Jepsen found 96 bugs in ParticleDB versions 1.1.4 through 1.1.18.11.rc-22, including crashes, data loss, and serious transaction anomalies. Most issues were fixed, but committed writes could still disappear and serializable transactions still had anomalies; Orkes says a later release resolves the remaining problems. (jepsen.io)
Today's best Hacker News stories, summarized and screenshotted, one email a day.