WLOG - blog something different

tags: ai arduino bass games godot i2c linux plan9 random rv web werc zig
Learning all the wrong lessons
link | random, zig | Wed Now 01 23:08:29 CET 2023 No.26

The time when some thought should be given to something other than just random projects is approaching. For whom does the sysbell rings?

So why not sharpen the brain with a simple exercise? A “cold open” so to speak. A quick “hello” run through the current popular (and STRONGLY recommended) system programming languages. See what we remember and how easy the easiest example is, and then do the easiest example the “hard” way (communing with the system directly).

Throw together some code, and to avoid making the grave mistake of having an opinion on programming languages on the net, print out some metrics:

File size, data size, and memory size of c, clang, zig, rust, go and odin on x84_64

In the context of my bias toward embedded and/or system development, an interesting pattern emerges. Zig and Odin produce the least amount of code.

This is not an exhaustive or balanced test by any means. But let’s explore this further. How about a popular microcontroller (it can’t get more popular than Arduino on avr, right)?

File size, data size, and memory size of c, zig and rust on avr

In the case of toggling a value in a register (and thus blinking the Arduino Nano onboard LED), Zig and C are neck and neck. Using the avr-gcc version of the compiler and included libraries or manually writing the needed parts from scratch in Zig took about the same effort (as in no time at all). Interestingly, by using Zig one could also compile C code directly (though linking and packing are still better done with avr-gcc for now).

Some more exploring needs to be done on this.