29
you are viewing a single comment's thread
view the rest of the comments
[-] Paradox@lemdro.id 6 points 1 year ago* (last edited 1 year ago)

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

this post was submitted on 03 Aug 2023
29 points (91.4% liked)

Programming

17225 readers
253 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS