I rewrote my Rust keyboard firmware in Zig: consistency, mastery, and fun

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

SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  1. zig

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

    Here's another example of the coolness of Zig's comptime code execution:

    https://github.com/ziglang/zig/commit/0808d98e10c5fea27cebf9...

    That's a generic container class (similar to vector in C++ or List in C#). But! With a twist!

    It stores structs in "column major" order in memory (e.g., if a struct had two fields A and B, then in-memory layout would be A...AB...B), and you can idiomatically and efficiently get a a slice of the values of each column.

    I.e., it's a datastructure that automatically applies the struct-of-arrays optimization:

    https://en.m.wikipedia.org/wiki/AoS_and_SoA#Structure_of_Arr...

    And the code to do it is straightforward, normal Zig.

    Pretty awesome stuff!

  2. SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  3. TinyGo

    Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.

    TinyGo is a Go toolchain for microcontrollers that uses LLVM, and it produces binaries that are extremely small. A few kB is not uncommon, from what I've heard, although I don't have much personal experience with it.

    The standard Go toolchain cannot compile for microcontrollers, so the size of binaries that it produces is irrelevant.

    Just like there are many compilers for C, there are multiple compilers for Go with different priorities.

    https://tinygo.org

  4. nrf-hal

    A Rust HAL for the nRF family of devices

    The embedded HAL crates do this with extensive use of macros, for example: https://github.com/nrf-rs/nrf-hal/blob/aae17943efc24baffe30b...

    This solution makes sense given the constraints of Rust, but there's quite a cost in terms of compiler time and cognitive overhead to understand what is going on.

    (Aside: I didn't use the HAL in my Rust firmware, that's a higher layer of abstraction; I only used the PAC crates.)

  5. drogue-device

    A distribution of tools and examples for building embedded IoT applications in Rust

  6. ziglings

    Learn the Zig programming language by fixing tiny broken programs.

  7. dstep

    A tool for converting C and Objective-C headers to D modules

    Not quite as seamless as Zig, but dstep is an external program that leverages libclang to do the same thing (and generates a D module for you), as well as e.g., smartly convert #define macros to inlineable templates functions :)

    https://github.com/jacob-carlborg/dstep

  8. zephyr

    Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.

    I'm going to sound old and very uncool but ...

    Use C! I'm in the process of doing my first "serious" project in 'straight' C (I'm a C++ guy from long ago) and it's taken me a while to get into it properly, but I'm starting to get its philosophy and it's becoming easy.

    But also, in the embedded space, it clearly has all the support you could ever want. I'm also gradually falling for Zephyr (https://www.zephyrproject.org) that has all the support for (eg) callbacks, all sorts of low level stuff.

    And one more ... the way you'd solve this in Zephyr is to use the scary simple API (https://docs.zephyrproject.org/latest/reference/peripherals/...).

    https://github.com/zephyrproject-rtos/zephyr/blob/master/sam...

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

  • Any good examples of using embedded Rust with an existing embedded C codebase?

    1 project | /r/rust | 12 Oct 2022
  • Release RP2350 and ESP32-C6 support, RISC-V native emitter, common TinyUSB code

    1 project | news.ycombinator.com | 3 Nov 2024
  • A review after using Rust on embedded in production for over a year

    7 projects | news.ycombinator.com | 14 Oct 2024
  • What is micropython?

    1 project | dev.to | 29 Jul 2024
  • Talking to the Pico over USB

    1 project | dev.to | 16 Jul 2024

Did you know that Zig is
the 22nd most popular programming language
based on number of references?