Zig in 100 Seconds - Fireship

ruffsl@programming.dev to Programming@programming.dev – 29 points –
Zig in 100 Seconds
youtube.com
7

I'm surprised there isn't a community on this intense for this language already.
I'd suggest those who interested to make a post over on !community_request@programming.dev .

I hate videos that try to talk about programming concepts. Also it would be better if we had a real comparison between Nim and Zig as it seems that they try to fill the same void in programming languages.

Well, one major difference between nim and zig is that nim has codegen features built in, and the ergonomics are so simple around them you'll wind up using them without knowing.

Nim, if you just start calling functions in your code, will evaluate them at compile time. This means you can use loops and other constructs to generate bits of code. This is similar to how it works in Ruby and Elixir (and python too IIRC).

So you can do this contrived example:

for i in [a, b, c]:
  proc i =
    echo "Generated proc"

That code probably wont work, but you can see the utility on being able to generate stuff inside your source code.

Zig explicitly has chosen to not have codegen features. The reasoning is that it keeps the language simpler, and is inline with Zigs efforts to stay away from macros and templates. The closest you can get is the comptime keyword, which evaluates it's right at compile, but it's very limited