When Zig Outshines Rust – Memory Efficient Enum Arrays

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • zig

    General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.

  • >Zig gives buffer overflow safety and null pointer safety but not use after free, double free

    It can provide the latter two through the use of the `GeneralPurposeAllocator`, which tracks UAF and double free.

    Stack pointer escape safety is being actively researched (there are a few tracking issues, see https://github.com/ziglang/zig/issues/2646). I'm personally interested in this, I've written a decent-ish amount of Zig for toy/personal projects, and anecdotally stack pointer escape is the only type of memory error that has bitten me more than once (though to be fair, one of these cases was calling into a C API, so even Rust wouldn't have helped).

  • Ryujinx

    Experimental Nintendo Switch Emulator written in C#

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • gameroy

    A Game Boy emulator, disassembler and debugger, written in Rust

  • I recently found https://github.com/Rodrigodd/gameroy to be a very complete implementation

  • excalidraw

    Virtual whiteboard for sketching hand-drawn like diagrams

  • hashbrown

    Rust port of Google's SwissTable hash map

  • Thanks, great point indeed. I am looking into this https://github.com/rust-lang/hashbrown

    The way I think about it -- rather naively, I suppose -- is that I care more about the references cells make to each other than the actual grid of cells displayed on a table. The latter feels more like a "view" of the data than an actual data structure?

    This also seems to align with the relative priority of (sorted from highest to lowest): figuring out the order of evaluation, calculating those evaluations, and finally displaying the results of the evaluation

  • rosettaboy

    A gameboy emulator in several different languages

  • As somebody who has written the same gameboy emulator in C++, Rust, and Zig (as well as C, Go, Nim, PHP, and Python) - I have yet to find a place where language affected emulation correctness.

    Gameboy audio is kind of a pain in the ass (at least compared to CPU, which is fairly easy, and GPU, which is easy to get "good enough” if you don’t care about things like palette colours being swapped mid-scanline) - and some languages take more or less code to do the same thing (eg languages which allow one block of memory to be interpreted in several different ways concurrently will make the “interpret audio RAM as a bunch of registers” code much shorter with less copying) - but in my case at least, each one of my implementations actually has the same audio distortions, presumably because I’m misreading some part of the hardware spec :P

    https://github.com/shish/rosettaboy/

    (Also yes, the zig version is currently failing because every time I look at it the build system has had breaking changes...)

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts