Peter Munch-Ellingsen: Why I wrote my own keyboard firmware in Nim (NimConf 2021)
Nim Programming Language1 HN recommenders · 2021–2024
3K views · talk · dated · Uploaded 2021-06-26
Peter Munch-Ellingsen explains at NimConf 2021 why he wrote his own keyboard firmware in Nim instead of using QMK or Arduino. He shows that the resulting firmware is very small.
Pointed to as a real-world example of Nim in embedded work, mostly by the author himself.
6:538-bit computer update
Ben Eater
1:12:27CppCon 2015: Andrei Alexandrescu “std::allocator...”
CppCon
22:21Reverse emulating the NES to give it SUPER POWERS!
suckerpinch
51:18Lexical Scanning in Go - Rob Pike
GoogleFOSSSydney
27:25“Hello, world” from scratch on a 6502 — Part 1
Ben Eater
59:34CppCon 2017: Matt Kulukundis “Designing a Fast, Efficient, Cache-friendly Hash Table, Step by Step”
CppCon
42:30RustConf 2018 - Closing Keynote - Using Rust For Game Development by Catherine West
Rust Programming Language
1:19:52CppCon 2016: Jason Turner “Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17”
CppCon
4 comments from Hacker News
Oh it definitely can run on those devices! I wrote my own keyboard firmware from scratch in Nim, and the firmware sizes are vanishingly small compared to even simple "hello world" level stuff in Arduino. I did a talk on it for NimConf2021: [VIDEO]
Nim works super well for embedded. The thing is that you can turn off the garbage collector and do manual memory allocation if you want to. Or simply use ARC which works a treat on embedded. I wrote my own keyboard firmware in Nim (and did a presentation of it during NimConf 2021: [VIDEO] ). It runs super fast and the code size is smaller than some simple "Hello world" level programs using the Arduino system. As for gamedev the ability to tune the GC by turning off automatic collection and then running it with a time-limit is perfect for preventing lag-spikes when a lot of stuff is going on (looking at you Java..). Nim actually performs very well, and the garbage collector does a great job of just getting out of the way and letting your programs fly. Your point about shell-scripting is kind of valid, it is indeed a weakly typed world. But with how fast Nim compiles the edit-test cycle feels as fast as Python, and you save a lot of time from having a silly typo that you only encounter after having run your script for a little while. The reason why Nim is good for pretty much anything is that the speed of the compiler and the garbage collection will rarely if ever stand in your way, and the flexibility of the syntax that stems from meta-programming allows it to be molded perfectly to the use-case.
Well, you give yourself a whole lot of extra work by attempting to create a Python to C transpiler, basically creating an even less mature and less popular language ecosystem than Nim has, when you could use Nim and get most of the benefits (statically typed, compiled to C) out of the box and enjoy their growing ecosystem. It seems that Prometeo is currently more limited than Nim. Maybe I'm not understanding your use case well enough and maybe your approach is actually a locally optimal solution, and I honestly greatly respect your effort and want to see your project succeed, cuz I love Python too. I even wanted to make a faster python myself at some point. Just, the more I learn about Nim, the more I appreciate its design decisions and think to myself: this is the faster version of python I'm looking for. Now, we just need the large package ecosystem that python has, but I'm willing to both wait and participate in making it come about. This presentation about writing keyboard firmware in Nim may be helpful, if you're willing to give Nim some more consideration: [VIDEO] There is also another talk about embedded programming in Nim from the same conference, here: [LINK]
I don't have any first-hand experience with embedded myself, but I've seen positive comments on different forums about using Nim in production for embedded devices. For example, see a couple pages of comments by girvo [1]. Also there's a video on writing keyboard driver in Nim [2]. [1] - [LINK] [2] - [VIDEO]