Skip to content

Instantly share code, notes, and snippets.

@ryuukk

ryuukk/zig.md Secret

Created October 25, 2020 19:03
Show Gist options
  • Save ryuukk/f9cf9cd7e5e913dca5fe3d6b8d029681 to your computer and use it in GitHub Desktop.
Save ryuukk/f9cf9cd7e5e913dca5fe3d6b8d029681 to your computer and use it in GitHub Desktop.

Hello, i'm not good at typing so i'll keep this short as possible


Preface: I am porting my engine to multiple languages in hope to find the language that i'll pick to write my game

What i tried so far:

  • C++
  • D
  • Rust
  • C#
  • Swift

My experience with zig, it's been almost 1 week and it's not even half done (took me 1 week with D for comparison)

The bad:

  • iterators are a pain to implement, do have to suffer from the same pain for every types that needs an iterator?

    • Answer: yes Solution: nothing
    • Side effect: i have to write duplicate code, that means N times more maintenance, and N times more bugs
  • composition, interface concept with @parentPtr thing is a pain to implement, do i have to suffer from the same pain for every types that need to implement

    • Answer: yes Solution: nothing, if you don't like the concept of composition, then remove @parentPtr and be explicit about it
    • Side effect: hard to write reusable code, you bloat everything
  • i can't do struct { stuff = Stuff{}}

    • Solution: i have to do struct { stuff: Stuff = Stuff{}} ... and if it has fields you have to implement everything since there is no concept of "default"
    • Side effect: i don't want to use structs and instead use simple primitive types
  • std.info.log("my message"), i can't, i have to add .{} at the end, why? i don't know but i hate it, it makes me type more, 3 characters, that are all annoying to type and all different

    • Solution, create a 2nd function that does no formating, and call it std.info.logf("my message") "f" :trollface:
    • Side effect: i don't want to log anything, it is a pain to type
  • self *Self, why do i have to type this everytime? your struct name is long? enjoy the visual noise, you forgot to put *, enjoy the bugs, you forgot to call self inside that function? enjoy the time wasted, want to make a static function? enjoy the confusion inside your struct

    • Solution: nothing
    • Side effect: i don't want create functions and instead put everything on a single one, with bloat and clutter everything
  • cast to stuff? enjoy the confusion, visual noise and mess it'll create

    • Solution: nothing
    • Side Effect: unreadable
  • want to return an i32, but you typed return -1; then enjoy time wasted

    • Solution: you have to return @as(i32, -1); Really?
  • operator overloading for Matrix, Shapes, Vectors?

    • Answer: nope Solution: bloat your code with methods

Will add more things here as i go, i'm not giving up on the language yet


Conclusion:

Language "seems" good, at first, but unfortunately, as you write zig code, you realize you are just writing more words that does nothing to help you solve your problems, instead they add clutter to your code, that becomes an absolute mess to read and to reason about

You end up not wanting to touch again your old code because it is a LOT of noise to rearrange whenever you refactor something

There is absolutely nothing to help you reduce the clutter, there is nothing that help you reduce maintenance when you want to share code, because you just can't, there is no facilities to help you solve your most "common" problems

I want to like the language, but i fight every step of the port, which only creates frustrations and regrets

If new language doesn't help solve old problems, and "usability" issues, then it is not a good thing and should go back to design board before releasing to the mass

It is C with sane build system and unneeded complexities

It is a better Rust, that's it


So far the only language that feels like has the potential to replace C and C++ is Swift, if you don't need explicit manual memory management

Otherwise i'll just stick with C++, unfortunately

Suggestion:

You should play with more languages, so you can guess what to focus on and what to improve, it feels like you haven't checked the alternatives much before engaging with strong design choices, because so far, i experience them as things that holds back the language from being a "general purpose language", it is a "system language that doesn't care about helping you write user applications"

Implement language features that helps reduce code maintenance, and that helps us avoid creating duplicate code

Simple != Minimalistic, wich is what Zig strive for, you mislead people by saying it's a "simple" language

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment