Zig - A 12-Minute Overview! Everything You Need to Get Started!

Поділитися
Вставка
  • Опубліковано 25 лис 2024

КОМЕНТАРІ • 3

  • @flatmapper
    @flatmapper 2 місяці тому

    Why to use Zig if we have already hyping Rust expansion

    • @CodingWithTom-tn7nl
      @CodingWithTom-tn7nl  2 місяці тому +5

      -Zig is easier to learn
      -Zig offers full memory management, so you can choose when to heap allocate or not. In Rust heap allocations are done for you.
      -Zig is slightly faster, depending on the program
      -Zig can easily call and compile C and C++ code
      -Zig can compile for any platform without needing to actually compile on that system

    • @ozzy-fr7vj
      @ozzy-fr7vj 2 місяці тому

      Memory allocation patterns
      Try rust non linear data structures like binary tree
      To make the this work in rust you have to wrap it refcell to push mutable check to runtime
      And wrap refcell in rc to allow multiple owner then wrap in option
      Hence option is the final type
      Now try implementing a little bit complex algo like morris traversal
      The code will be an absolute mess with this, all of this just to avoid error prone malloc and free, instead try a arena allocation now this extremely simplifies the code and lifetime are also known just one allocation and free are needed the tangled mess of malloc and tree along with raii is also gone
      Till rust support this feature in stable version, right now it’s in nightly and there seems to be no push allow different allocations pattern in rust
      Language like zig and c will still remain superior to rust