What's Today

Hacker News Front Page · Mihalis Tsoukalos ·

Why Zig Over C for Systems Programming

El autor elige Zig para escribir código nuevo de sistemas porque conserva la cercanía de C con la máquina y evita un runtime, mientras que sus slices, errores explícitos, `errdefer` y comprobaciones en modo seguro ayudan a detectar fallos que C puede dejar pasar. Muestra ejemplos de limpieza de recursos, límites de arreglos, desbordamientos y compilación cruzada, además de cómo Zig puede compilar proyectos C durante una migración gradual. Reconoce que Zig todavía cambia con frecuencia, tiene menos herramientas y no elimina todos los riesgos de memoria; para algunos microcontroladores, el compilador disponible también hace que C sea la única opción.

After I wrote Why Zig Over Rust for Systems Programming, the obvious next question was C. The Rust question was about safety and how much ceremony I was willing to accept for it. The C question is different, because Zig and C want the same things. Both are small languages without a Garbage Collector and both stay close to what the machine does. So this post is not about leaving C for something completely different. It is about the parts of C that cost me time and how Zig deals with them. All the code was compiled on a Mac with Zig 0.17 and clang.

Leer la nota completa en www.mtsoukalos.eu →