upvote
Related, Apple has a safer C variant they use to build firmware:

https://saaramar.github.io/iBoot_firebloom/

reply
Zig hits on a lot of Zen of Python.

> Beautiful is better than ugly.

> Explicit is better than implicit.

> Simple is better than complex.

> Readability counts.

What really sets Zig apart from the usual suspects (C, C++, Rust) is that it has first class compile-time reflection capabilities built into the language (comptime, @field, @typeInfo, etc.) rather than bolted on as macros or templates.

reply
> Python

Funny you make that analogy. I remember back when the two contending C alternatives were Zig and Nim, with Nim being syntactically almost a Python clone.

It seems Nim has gone the way of Crystal (Ruby version of Nim) and is just kind of there but mostly forgotten and doomed to be abandoned unless it finds a niche.

> What sets Zig apart is compile-time

I see this claim a lot, but I'm not sure. I think it's the fact that Zig is more or less still C syntax and semantics, just... fixed. The way it does comptime does seem better than how other languages do it, but I haven't actually used it, much less for long enough to judge it properly.

reply
Comptime is a gateway to partial evaluation, precomputing tables, and data layout optimization using the same language zig that you're familiar with when you need it and just a convenient way to handle generics when you don't.

As an example from my unfinished project, I use it to select the encoding to use [1] when resolving pointers to components [2] to reduce code size [3] as much as possible while keeping a high-level interface [4] where you don't need to care about any of it, just "map" a system over every matching entry within the database and it computes the "best" traversal for a single-thread. This is something that's generally difficult to both keep simple enough to work with and for it to generate good enough code to be worth it while retaining type safety.

Comptime enables such without much cognitive overhead as you're working in the same language as before just with lazy evaluation [5] and slightly more lenient rules around memory management making it easier to focus on working towards the desired the data model.

[1]: https://codeberg.org/tauoverpi/game/src/commit/77ec827ec93bc...

[2]: https://codeberg.org/tauoverpi/game/src/commit/77ec827ec93bc...

[3]: https://codeberg.org/tauoverpi/game/src/commit/77ec827ec93bc...

[4]: https://codeberg.org/tauoverpi/game/src/commit/77ec827ec93bc...

[5]: https://godbolt.org/z/P64Ezcrb7

reply
I haven't used Nim but your comment made me remember that language, yeah it was forgotten but I am not sure if it's completely abandoned, it seems that their team has been launching new language releases on a nice cadence: https://nim-lang.org/blog.html
reply
Lately, a lot of work has shifted to nimomy: https://news.ycombinator.com/item?id=43894666
reply
I don't mind the language having substantially worse "something" as long as it can be a smaller alternative for Rust, for the lack of a better word. Of course, there always needs to be some compromise. I don't mind that. I just have two requirements, and am curious to see how people have tackled that problem.
reply
Sure, and I'm just as curious.

But at the same time, I'm pretty sure that smaller/simpler is going to mean less safe.

reply
I think the opposite is true. The Rust philosophy is the idea that a complicated type system should ensure safety. This may work to some degree, but the overall complexity will introduce new issues. I say this as someone who was really excited about type systems in the past, but Rust is ... meh.
reply
> The Rust philosophy is the idea that a complicated type system should ensure safety.

I don't think the "complicated" is part of the philosophy. Rather the idea is that a "strong" type system should ensure safety. The general consequence of this however is that the language becomes quite restricting and limiting. Hence the need for more more complex feature that allow for greater expressibility.

reply
I think the problem is that some of the more advanced things related to generics or traits are half-baked or maybe somewhat function only in unstable, leading to horribly written code, or code which takes far more complexity to run than it should.
reply