Zig for Impatient Devs

Поделиться
HTML-код
  • Опубликовано: 28 май 2024
  • Discord (!!!): discordapp.com/invite/bWrctJ7
    C is a great language. It's fast, simple, and oh so dangerous. But what if you want the speed, but not the danger? Introducing Zig, the hottest new C alternative on the block!
    But can you learn it in 10 minutes?
    Resources:
    Zig: ziglang.org
    ziglearn.org: ziglearn.org
    ZLS: github.com/zigtools/zls
    __________________________________________
    Check out my other socials!
    🎮 Discord ▶ discordapp.com/invite/bWrctJ7
    🐦 Twitter ▶ / isaacharrisholt
    🖥️ Portfolio ▶ ihh.dev
    📝 Blog ▶ isaacharrisholt.com
    __________________________________________
    Timestamps:
    00:00 - Introduction and explanation
    00:27 - Installation and setup
    00:48 - Variables and data types
    01:34 - Operators
    02:13 - Errors
    02:49 - Control flow
    03:38 - Functions
    04:04 - Pointers and references
    04:42 - Arrays, slices and structs
    06:28 - Enums, unions and tagged unions
    07:25 - Comptime
    08:18 - Memory management
    08:51 - Standard library datatypes
    09:22 - What's left?
    #zig #softwareengineer
  • НаукаНаука

Комментарии • 253

  • @IsaacHarrisHolt
    @IsaacHarrisHolt  5 месяцев назад +42

    ERRATA:
    0:33 - I mentioned that Zig doesn't have nice stack traces. This isn't true! They're very good, and quite detailed. It also does have a package manager. See @mlugg5499's comment for more information :) (or see the package manager release notes: ziglang.org/download/0.11.0/release-notes.html#Package-Management)
    1:18 - []const u8 is a SLICE of const bytes, not an array! Also, strings will COERCE to this type, but as @rexicon2269 correctly pointed out, Zig string literals are technically constant single item pointers to null terminated byte arrays (*const [N:0]u8), however, I left this out of the video as we didn't cover sentinel termination :)
    1:30 - @as is not a cast! It's effectively an inline type assertion. It'll only work if the type can be safely (upwardly) cast (thanks again @rexicon2269)
    3:02 - The output would be 1, 4, 16, 64, not 4, 16, 64, 256 (thanks @someoneunknown6894!)
    4:15 - There are some `const`s missing from types (thanks @unperrier5998!)
    4:27 - The first line should be `const x` (thanks @GhislainGt!)
    4:43 - Same as 1:18
    4:58 - Missing `u8` between `[_]` and `{0}` (thanks @unperrier5998!)
    5:39 - Struct fields are assigned with `=` not `:` (thanks @unperrier5998!)
    8:18 - The inline loop should print `false` twice at the end (thanks @jcsahnwaldt!)

    • @raffimolero64
      @raffimolero64 5 месяцев назад +4

      Nice work. Good middle-ground between Fireship's " in 100 Seconds" and other more in-depth tutorial vids.
      7:10 Rust's actual Option type declares `None` before `Some`, affecting the order of comparisons.
      This means the discriminant (tag) for None is 0, None < Some(0), and this behavior will be optimized out for Option.
      9:16 As a newbie, I hadn't seen this syntax before. Looks like the while loop is taking an expression, which should only return true or false as per if/else, but the expression manages to return a value which is captured in the block. It looks more like some sort of Optional value matching, which wasn't explained earlier.
      I did a little bit of research and it looks like you can run an expression like
      if (?T) |t| {
      doSomething(t);
      } else {
      doSomethingElse();
      }
      which appears to be special-cased for optional types and error unions.
      Maybe this errata comment could also be used with a "NOT COVERED:" section to dump a bunch of keywords that may be important to search, starting with the words you said at the end of the video. One thing you haven't mentioned, I think, is tests. Just put those words in there and go. The video is long enough, writing out whole examples in a comment would just be extra work that could go into making a part 2.

    • @tatterdemalion898
      @tatterdemalion898 5 месяцев назад

      well this sounds like C with a little more error handling XD

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +5

      Sounds like a good thing to me 👀

    • @master74200
      @master74200 5 месяцев назад

      At 0:39 the PATH specified is also incorrect. It should be a path to where the binary resides, not a path to the binary itself. In fact, /usr/bin very well should already be in the PATH variable.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +1

      In this case, zig is a directory, as that's what comes from the download :)

  • @felixjohnson3874
    @felixjohnson3874 5 месяцев назад +152

    As someone who is so used to 2x speed for everything it is unexplainably refreshing to have a video that *_actually_* needs to be slowed

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +27

      I watch most stuff at 2.7-3x speed, so I understand your plight 😅 it's one of the reasons I like making content like this!

    • @user-fe8hp6jv9f
      @user-fe8hp6jv9f 5 месяцев назад +5

      God dam so true

    • @bpo217
      @bpo217 5 месяцев назад +6

      100% agree

    • @Yash9278
      @Yash9278 4 месяца назад +1

      ​@@IsaacHarrisHoltBamboozled 😂😂😂

    • @krellin
      @krellin Месяц назад

      oh crap i forgot i had this on faster speed

  • @oerickmuller
    @oerickmuller 5 месяцев назад +40

    This video is like a movie trailer, but for a language, and in a good manner: you watch the video, see how things happen in Zig, and if you think that it's for you, you go deeper. This kind of content is extremely helpful.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +2

      I'm glad you found it useful! Let me know what else you'd like to see

  • @matteac_rs
    @matteac_rs 5 месяцев назад +26

    zig is awesome, quite difficult to understand the memory model coming from a gc lang, but it is extremely powerful. I love the fact that zig aims to be simple, like c, instead of being complex (but more powerful out of the box) like rust. I also love rust, but at some point it becomes overcomplicated
    I really liked the video, a lot of info in 10 minutes, loved it!

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +5

      Yeah, going to a low level lang from a GC Lang is difficult, but eventually you'll wrap your head around it and it'll all just click :)
      Glad you enjoyed the video!

    • @offroaders123
      @offroaders123 4 месяца назад +2

      Great comment, and heck yeah King Crimson!

  • @not_herobrine3752
    @not_herobrine3752 5 месяцев назад +68

    Zig sounds like chrismas for C users

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +14

      Why do you think I released the video at this time of year 😉

    • @not_herobrine3752
      @not_herobrine3752 5 месяцев назад +12

      @@IsaacHarrisHolt how long were you waiting for someone to comment this

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +10

      So long

    • @Kraboobee
      @Kraboobee 5 месяцев назад +10

      Merry zig to all C users

    • @Maagiicc
      @Maagiicc 5 месяцев назад +3

      All of this looks pretty good, but I think I'll stick with C

  • @alexon2010
    @alexon2010 Месяц назад +2

    I'm a complete beginner in Zig, I've been developing for the web - front-end, Javascript with React for about 10 years, I love the productivity of Reat, but I also want to learn a compiled language because I really like embedded electronics for machines... I liked it a lot about Zig... even though I don't know English, your video was the best so far for learning Zig... congratulations

  • @vojtastruhar8950
    @vojtastruhar8950 5 месяцев назад +1

    Awesome video. I hope your channel grows! Great work

  • @someoneunknown6894
    @someoneunknown6894 5 месяцев назад +6

    Just got recommended to me, great video! Really enjoyed it and subscribed :D
    A small note, on 3:02 the loop with the continue expression would print 1, 4, 16, 64 instead of 4, 16, 64, 256
    Idk what's your style but I personally like No Boilerplate's errata comment where he mentions small mistakes like this
    Again though, the video is awesome, thanks for making it! :D

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +1

      Done! It's something I've done before too. Thanks for pulling me up on it :)

  • @pierreollivier1
    @pierreollivier1 5 месяцев назад +15

    Zig is really my favorite language, as a C developer it really is everything I wish C was and more :
    - No more Macro cancer.
    - No more make/cmake/ninja cancer.
    - No more implicit integer promotion foot guns.
    - No more namespace conflict.
    - No more quirks.
    - No more checking for null everywhere.
    - No more void* and macros for generic.
    - Actually useful and usable standard library.
    - Seamless interop with C.
    - Lower level control than C with native support for SIMD primitive.
    - Errors as value.
    - Stricter type system.
    - Allocators are first class citizens
    - Very readable and explicit code, there is next to no hidden control flow everything you read is everything you get.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +3

      This is exactly what Zig is trying to solve! It's still not my cup of tea personally - I like slightly higher level languages - but I'm not solving low level problems, so I don't need as much control as Zig provides.
      That said, I definitely want to experiment more with working on low level systems and such, and I think Zig is definitely a fun way to try and accomplish that.

    • @pierreollivier1
      @pierreollivier1 5 месяцев назад +3

      @@IsaacHarrisHolt That's understandable. If you wish to get the broader perspective on why Zig is so awesome, a quick experiment that I would recommend, would be to re implement something relatively trivial like hex dump. Try to do it in C, try do to it in your favorite language, then try to do it in Zig. This shouldn't take too long, (around 500 loc for a bare bone implementation). If you try hard to write good C code redoing everything in Zig will really give you valuable insights on why Zig is so great.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад

      Ooh thanks! I'll take a look into it. Honestly I've never actually written any C outside of RaspPi/Arduino programming, so it might take me ages to get through it all

  • @samdavepollard
    @samdavepollard Месяц назад +2

    so impressive, how much you manage to pack into 10 minutes
    great work - many thanks for sharing your knowledge
    subbed

  • @chefaku
    @chefaku 21 день назад +2

    8:00 I have never seen a macro so simple to understand

  • @aveydotdev
    @aveydotdev 4 месяца назад +5

    Everything I need is in C, Zig, and Go!

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 месяца назад +2

      Well good job I have overviews of 2/3 of those on the channel 😉

  • @AK-vx4dy
    @AK-vx4dy 2 месяца назад +1

    Zig big feature is seamless integration with C, not only using libraries in both directions with lon the fly bindings generation but zig even can compile C code or be used as build system (programmed in Zig !)....
    Zig author(s) should take some prize for it!!!
    Oh i forgot, Zig can compile itself and c *cross-platform*... you can compile to Windows binary (exe) on mac or linux or vice-versa....🤯

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  2 месяца назад

      Yeah, Zig is great! And this is very compelling. I know Vercel used `zig cc` as the build tool for their Go/Rust project

  • @koool56
    @koool56 5 месяцев назад +8

    Using Zig have been awesome, exactly what I needed after envying Rust/Go features I wished C had!

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +1

      Cool! What would you say is your favourite Zig feature?

    • @koool56
      @koool56 5 месяцев назад +6

      ⁠​⁠​⁠@@IsaacHarrisHoltWell, it’s three things I missed in C, hard to pick one.
      * optional value as 1st class language citizen (not unwieldy C++ implementation, null pointer or magic value)
      * being able to add methods to structures (C void pointer way loses type safety and syntax is nuts)
      * Errors as values, checking for null on top of checking some global error variable is hacky in both C and C++

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +1

      Very valid reasons! Let me know how you get on with Zig

  • @fleaspoon
    @fleaspoon 5 месяцев назад +10

    thank you for the video but I had to slow it down to have some time to think

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +6

      That's the point! It's meant to be a speedrun of the language. You can always watch it a couple of times 😉

    • @reed6514
      @reed6514 5 месяцев назад +5

      Alternatively, drink 6 pots of coffee, and you'll have to slow down so the universe can think.
      (Don't drink 6 pots of coffee! Care for your heart! ☕❤💥)

  • @DanFromIran
    @DanFromIran 19 дней назад +1

    I love C and I think I will love Zig even more. thank you for this video.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  19 дней назад

      You're so welcome! I'm glad you found it useful

  • @henrispriet9812
    @henrispriet9812 5 месяцев назад +7

    This feels like C trying to Rust 🤔

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +7

      Is that such a bad thing? 👀

    • @holthuizenoemoet591
      @holthuizenoemoet591 5 месяцев назад +1

      To me it feels like C trying to Python, which is not bad

  • @jp46614
    @jp46614 5 месяцев назад +10

    This looks a lot like rust in some cases, I also see a lot of rust developers alternating between rust and zig, it looks promising. As for things like panicking on integer overflow, how about dynamic integers? Does it have runtime checks for overflows? That sounds like a poor trade off between performance and safety.

    • @mgord9518
      @mgord9518 5 месяцев назад +12

      It has runtime checks in Debug and ReleaseSafe mode. For ReleaseSmall and ReleaseFast, integer overflows are UD

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +2

      Good to know, thanks!

    • @dealloc
      @dealloc 5 месяцев назад +4

      i think the analogy most people make is Rust is "the new C++" and Zig is "the new C". Of course doesn't mean they're going to replace the languages; just that Rust is more implicit like C++ and Zig is more explicit like C. Of course it's not apples to apples, since C++ is (somewhat) extended C, not the same history with Zig and Rust. Interop between the two is a whole other rabbit hole :P

  • @mlugg5499
    @mlugg5499 4 месяца назад +4

    At 0:33, you mention some missing features. Firstly, Zig does have a package manager - it's a quite recent creation and so somewhat immature, but it does exist, and is being used in the wild (the best example is probably the Mach project). Secondly, I'm not sure what you meant by "reasonable stack traces". I haven't heard of any major issues we currently have with stack traces - in general, stack traces are printed by the panic handler on any crash, and they're detailed & prettified. If you've encountered any specific issue with incomplete/incorrect stack traces, that's a bug, and possibly one we're not aware of, so please report it!

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 месяца назад +2

      Apologies for that! I couldn't find any information on the Zig package manager (I assume you mean Zon?) on the ziglang.org site, so I assumed it was potentially third-party, like nektro/zigmod. If you could just make sure I've got the right one, and provide some documentation, I'll include a link in the pinned ERRATA comment.
      I'll do the same re the stack traces. I don't know why, and I can't reproduce them, but I didn't have a great experience when I was researching for this video. Thanks for calling me out, though!

    • @mlugg5499
      @mlugg5499 4 месяца назад +1

      (I just wrote a detailed reply here and RUclips in its infinite wisdom deleted it when I tried to fix a typo. I'll rewrite it later on :p)

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 месяца назад

      Looking forward to it :)

    • @mlugg5499
      @mlugg5499 3 месяца назад +4

      @@IsaacHarrisHolt Sorry it took me so long to get around to this, I've been quite busy. Okay, so!
      ZON is not the name of the package manager, but rather a file format. It stands for Zig Object Notation - like JSON, we've basically taken Zig's construction syntax and turned it into a file format. ZON is used by the package manager, but it's a general-purpose file format.
      The package manager itself does not have a name - it's just a system integrated into the compiler. The way it works is that you create a file named `build.zig.zon`, which declares the name of this package, and all of its dependencies and their URLs (the package system is decentralized, unlike e.g. npm). These dependencies can then be referenced from your `build.zig`. The schema for this ZON file is detailed at github.com/ziglang/zig/blob/master/doc/build.zig.zon.md. Unfortunately documentation for the package manager itself is a little lacking at the minute - the best resource is probably the release notes for 0.11.0 (ziglang.org/download/0.11.0/release-notes.html#Package-Management), but keep in mind that might be a little outdated.
      You can see an example package at github.com/andrewrk/SDL, and an example usage of said package at github.com/andrewrk/sdl-zig-demo.
      I hope this helps!

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  3 месяца назад +1

      Very helpful, thank you! I'll add a link to this comment in the errata :)

  • @ilonachan
    @ilonachan 4 месяца назад +1

    I really like Zig in concept, as a replacement for C it's definitely a stellar option with just straight upgrades everywhere! I've never really worked that low-level though, I don't deal well with the whole "manual memory management" thing, which is why I'll probably stick with Rust instead.
    What's really sad to me is how awesome the whole comptime and emergent type meta stuff is, and how that whole system is probably fundamentally incompatible with Rust's type system. If the Rust team ever finds a way to integrate all this comptime magic into their code naturally, it's really gonna pop off for me! (and yes I know macros exist, but they only operate on tokens and not actual types and structures. Again because Zig's model of building the types at comptime seems pretty much incompatible with Rust's type checker.)

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 месяца назад

      I like this take! Yeah, comptime is pretty much my favourite feature of Zig. Like you, I prefer Rust's memory management and I find the type system more robust.
      You can still accomplish most of what comptime offers through generic types, but not everything, sadly.
      And don't get me started on lifetimes...

  • @Somali-iv9pu
    @Somali-iv9pu 3 месяца назад +1

    It really seems to be a beautiful language i think ill try learning it i wanna invest time in it but i dont know if it will ever be in demand

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  3 месяца назад +2

      There are some really big projects using it! Bun is probably the most famous example at the moment

  • @reed6514
    @reed6514 5 месяцев назад +4

    It looks nice. This is the first time I've looked a new (to me) language and actually wanted to use it.
    Like I've watched Rust videos & C & python & I've played with C#, but meh idc whatever I'll stick with my PHP. Zig actually looks like a thing i wanna try. But i have 30+ FOSS php projects, so i won't be switching languages any time soon.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +4

      It's always worth experimenting, even if you don't do anything major with it. Give it a go for the advent of code or whatever :)

  • @justafreak15able
    @justafreak15able 5 месяцев назад +1

    Bro what tool do you use to generate these voice tracks for your videos? 😮

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +2

      A Blue Yeti, Reaper FM and Adobe Podcast :)

  • @VivekYadav-ds8oz
    @VivekYadav-ds8oz 3 месяца назад +3

    Nice to see more videos in the NoBoilerplate style.

  • @ottergauze
    @ottergauze 28 дней назад +1

    Take a shot every time he says "type", I dare you.

  • @iaconst4.0
    @iaconst4.0 14 дней назад

    good video , many persons say that zig is the fastest language program, is that true?

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  14 дней назад +1

      I mean, Zig is a manually memory managed, low level language, so it's gonna be fast. As for the fastest, who knows? It'll vary benchmark by benchmark, but generally the fastest is probably gonna be assembly

  • @lattehour
    @lattehour 4 месяца назад +3

    the day i will write .* to dereference a pointer will happen only in end times

  • @abcdefg-nu4xj
    @abcdefg-nu4xj 5 месяцев назад +2

    you are so underrated

  • @rexicon2269
    @rexicon2269 5 месяцев назад +3

    at 1:18 this is not a array of "const u8" :)
    it's actually a slice of "const u8". the difference being "[]const u8" and "[N]const u8", where N is a comptime known value.
    "this is a string" is of type "*const [N:0]u8" aka a pointer to a const 0 terminated array of u8. this then coerces into a []const u8 through the explicit type you give "const string: []const u8".
    same thing at 4:43
    minor error, but they are distinctly different things.
    error 2:
    at 1:30
    the @as is not a cast. it's a inline way of writing `const flt: f80". the actual cast here happens implicitly. the same thing would have worked if you had written "const flt: f80 = 5000.1". of course this can only happen if it's a safe cast such as casting upwards i.e u32 => u64. casting downwards would not work, and be an error, and would require i.e @intCast

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад

      Have added to the pinned errata comment! Thanks for calling me out :)

    • @rexicon2269
      @rexicon2269 5 месяцев назад

      always happy to help :)
      just saying:
      @as is not a cast! It's effectively an online type assertion.
      i think you meant to say "inline type assertion"

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад

      I do! Thanks 😅

  • @blouse_man
    @blouse_man 5 месяцев назад +7

    Zig feels like a mix, can u tell what the special reason for which zig is in the talks for sometime now??

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +7

      A lot of it is down to how low level you can get with it. It's as low level as C, but ultimately safer. Comptime is also very useful once you start getting into advanced stuff with it - much nicer than headers and macros.

    • @pierreollivier1
      @pierreollivier1 5 месяцев назад +9

      Zig is meant to replace C, If you know C well you can clearly see (no pun intended) that Zig was built off the frustrations of C. The problem with C is that it lacks type safety, and carries a lot of terrible decisions, namely, macros, preprocessor, nullability implicit conversion rules, forward declaration etc. You might think that alternatives already exist, like C++ or Rust, the problem with those languages is that they aren't "real" C replacement, Why ? Because they don't follow the same set of principles. Zig on the other hand really focus on simplicity and ease of use, especially if you are a C programmer all of the very "unsafe" things and all of the error prone stuff is replaced with more explicit or safe constructs and idioms. In Zig you can't cast variables as freely as you used to do in C, instead you have to use specific builtins to do so. You don't need to use macro magic or void* to get generics, instead you can use a safe alternative called comptime. You don't need to worry about the build system and portability and linking error, instead you can use Zig to build Zig. You don't have to migrate to a new testing framework, instead you can just rely on the Zig builtin testing framework, You don't need to use more macro magic from another language to generate bindings to interops with your old C you can just compile it with the Zig compiler, You also avoid namespace conflict out of the box, and so much more that I can't really name everything, the point is that I'm a C developer, and Zig literally is everything I wished C was.

    • @salty_cucumber
      @salty_cucumber 3 месяца назад +1

      ​@@pierreollivier1 excellent answer

  • @ikirachen
    @ikirachen Месяц назад

    AOP reinvented ... nice to see this aproach :)

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  Месяц назад

      Ooh interesting take! What makes you say that?

  • @runnow2655
    @runnow2655 5 месяцев назад

    trying to follow along and add zig to my VScode but I don't know which file is the zig executable 😭

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +1

      When you download Zig, the compressed file contains the executable and the standard library :)

  • @ekaansh
    @ekaansh 5 месяцев назад +1

    so well presented, a treat to watch

  • @modolief
    @modolief 5 месяцев назад +1

    Thanks!!

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +1

      You're welcome! Let me know what you'd like to see next 😉

    • @modolief
      @modolief 4 месяца назад

      @@IsaacHarrisHolt Ok well ... this is kind of a big ask, but I haven't seen a good overview video for the general software dev audience on the topic of TLA+, the formal specification language that can be used to prove the correctness of programs. Yes, I know, it's a really out there topic, but it has been on my radar for years.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 месяца назад

      @@modolief interesting! I'll look into it, but it seems quite far from my usual content, so I can't make any promises 😅

  • @colto2312
    @colto2312 Месяц назад +1

    ngl i'm sold. if i'mma compile to binary; this is probably my choice. mostly a scripter personally however

  • @AWriterWandering
    @AWriterWandering 20 дней назад +1

    I was too impatient. Watched at 1.5.

  • @gp5381
    @gp5381 4 месяца назад +1

    would you make one episode on F# and fsx scripts? :) lovely channel

  • @yongkangchia1993
    @yongkangchia1993 2 месяца назад

    how did you make this video? PowerPoint?

  • @yadukrishnan8577
    @yadukrishnan8577 3 месяца назад +2

    Please do a part 2.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  3 месяца назад +1

      Interesting request! What would you like it to cover?

    • @yadukrishnan8577
      @yadukrishnan8577 3 месяца назад +1

      @@IsaacHarrisHolt I've heard that Zig does async differently when compared to other languages. I'd love to know if that is true. And maybe c-interop as well.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  3 месяца назад +1

      It's true! I'd recommend looking at ziglearn.org

  • @user-ng8rl3jb1i
    @user-ng8rl3jb1i 2 месяца назад +1

    Maan zig came out of nowhere

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  2 месяца назад

      What do you think of it?

    • @user-ng8rl3jb1i
      @user-ng8rl3jb1i 2 месяца назад +1

      @@IsaacHarrisHolt Seems pretty fast and nice. I saw a video of zig being the first in speed in some task. Faster than c and rust. That is amazing ! I hope it replaces c or at least be used as much as c. It feels like a new breath or smthing. I like c / c++ but i would totally love to use zig for a project in my university. The only drawback i see atm is that i feel i cant use it for something solid or long term (since i guess there would be some changes in the languages ). Mostly for some demo projects i guess. I hope it goes well

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  2 месяца назад +1

      There are some pretty big production projects happening in Zig right now - you can definitely use it long term! There's nothing saying you'll be forced to update versions.

  • @phenanrithe
    @phenanrithe 3 месяца назад +1

    Why the rush?

  • @venir_dev
    @venir_dev 5 месяцев назад +1

    Next, you'll do Elixir... right? 😍

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +3

      Oooh interesting! I hadn't thought of doing Elixir. Maybe I'll start running polls and suggestion stuff on Discord

  • @KieranHolroyd
    @KieranHolroyd 5 месяцев назад +1

    No Boilerplate is spreading across languages now

  • @guilherme5094
    @guilherme5094 4 месяца назад +1

    👍👍!

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 месяца назад

      Thanks! Let me know what you'd like to see next :)

  • @LageAfonso
    @LageAfonso 5 месяцев назад +13

    I don't feel like Zig syntax is well structured enough, seems like a bunch of syntax sugar that someone just added to make things work.
    Maybe I'm just used to Rust typesystem.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +4

      I do love the Rust typesystem. Zig is still technically pre-1.0 though, and I think there's a lot of room for it to grow and improve

    • @shrin210
      @shrin210 5 месяцев назад

      ​@@IsaacHarrisHolt There is no room to grow and improve syntax i guess

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад

      Major versions could introduce breaking changes :)

    • @pierreollivier1
      @pierreollivier1 5 месяцев назад +3

      From the perspective of a rust developers maybe, but if you've been programming in C extensively, you might be able to see that basically all of the "syntactic sugar" is really just very common C idioms (who are very error prone, or unreadable) expressed in a shorter and or safer way. Because the target audience for zig is really just C developers who want to migrate/maintain their old code base with a more modern and safer language, with more control/freedom than what Rust offers (at the expense of memory safety), and without the ugliness of C++. Which makes a lot of sense, I also believe that they've said that the syntax might evolve once everything is ready for the 1.0 as they don't think syntax should be their primary concern.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +2

      I disagree with the developers here somewhat. People these days are generally flocking to languages that feel good to write, and syntax is a big part of that. Zig is currently lauded because it's a vast improvement on C, but lots of things are a vast improvement on C, tbh. As soon as a 'Zig with nice syntax' comes along, Zig could be in trouble.

  • @unperrier5998
    @unperrier5998 3 месяца назад

    **ERRATUM**
    The return values at 3:01 (loop with continue expr) are wrong, it should be: 1, 4, 16, 64
    At 4:15 you're missing a bunch of 'const' to specify the pointer is pointing to constant value (two consts in the pointer definition, just like in C)
    At 4:24 the code you display works because you forgot to make the variable constant.
    At 4:58 you're missing the type: [_]{0} requires a type. It should be [_]u8{0}
    At 5:39 the code doesn't even compile

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  3 месяца назад

      Thanks! I think a couple of these are already in the pinned "ERRATA" comment, but I'll add the missing ones

    • @unperrier5998
      @unperrier5998 3 месяца назад

      @@IsaacHarrisHolt I was going along with your examples, playing with them, that's how I noticed them. They're helpful because even though they're slightly wrong at times, the audio commentary tells what matters. On that note I had to reduce the audio speed and pause to actually digest the teaching.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  3 месяца назад

      @@unperrier5998 totally fair! I know it's a lot to get through in a short space of time - that's how it's designed - and I definitely expect people to pause and rewatch parts. I'm glad you found it helpful though :)

  • @mrk131324
    @mrk131324 5 месяцев назад

    Sounds like Rust without the weirdness.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад

      Interesting! What do you find weird about Rust?

    • @mrk131324
      @mrk131324 5 месяцев назад +1

      @@IsaacHarrisHolt A lot of small things. Like not using a ; for return lines. The naming of the crates.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад

      Fair enough! It's not for everyone

    • @RiwenX
      @RiwenX 4 месяца назад +1

      @@mrk131324 You call them weirdness, I call them coolness.

  • @krellin
    @krellin Месяц назад

    i know zig
    -Neo

  • @CodingResoures
    @CodingResoures Месяц назад

    zig vs rust

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  Месяц назад

      Personally I think they solve different problems. Zig gives you more control and will ultimately allow for slightly better performance, but Rust is safer and makes it more difficult to shoot yourself in the foot.

  • @KimberlyWilliamsch
    @KimberlyWilliamsch 4 месяца назад +1

    So it's literally modern c

  • @vincent06
    @vincent06 3 месяца назад +1

    I have mixed feelings about Zig after watching this... I like the errors handling, var VS const, defer keyword and many other things but operators look horrific... I don't want my code to looks like hieroglyphes ** +%= ++ .*

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  3 месяца назад

      Totally valid points! Zig isn't for everyone, but I'd also argue that syntax isn't everything. You'd get used to it after a while.

  • @EduardKaresli
    @EduardKaresli 5 месяцев назад +2

    OK, we have C, C++ and Rust, why would one prefer Zig instead? What is Zig's best use-case scenario?

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +3

      Zig is supposed to be a replacement for C. It's not finished yet, so it doesn't cover quite as wide a surface area, but I can see Zig being used anywhere C might.
      A good example is Bun, the new JS runtime built as an alternative to Node.

  • @alexon2010
    @alexon2010 Месяц назад

    This pointer thing and I don't understand anything

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  Месяц назад

      Yeah, pointers take some time to get used to!

  • @friedrichmyers
    @friedrichmyers 5 месяцев назад

    My biased ass towards C would never make it comparable but it seems promising enough to try.
    Comparing to other languages, If it makes a good package system then I might ditch Go for backend development and use this instead.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +1

      Ooh interesting take! I think I still prefer Go - development speed is much higher - but I can see Zig working if you're doing high throughput computing

  • @deathlife2414
    @deathlife2414 5 месяцев назад

    Tried it the cache for zig init-exe was to large for simple project. Wait for it for another 2 more years for it to reach 1.0

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад

      Interesting! I didn't experiment with init-exe that much for this

    • @reed6514
      @reed6514 5 месяцев назад

      What's init-exe?

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +1

      It's how you initialise a new Zig project. It's technically not needed, but it gives a nice structure etc. It's kinda like Cargo init, but more optional

  • @necauqua
    @necauqua 2 месяца назад +1

    don't understand the comments complaining about pacing, it's literally perfect
    good video, keep it up 👍👍

  • @TheSaintsVEVO
    @TheSaintsVEVO 5 месяцев назад +1

    Why do you people edit videos like this with zero pauses

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +2

      So I can stick "in 10 minutes" in the thumbnail 😉

    • @user-he4ef9br7z
      @user-he4ef9br7z 4 месяца назад

      Good. Most tutorials are too slow paced and boring.

  • @xE92vD
    @xE92vD 2 месяца назад +1

    Is it comparable to Rust? And why would anyone use Zig over Rust?

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  2 месяца назад +1

      I would say Zig is lower level than Rust. Rust allows you to write high-performance code, but other than the borrow checker, it mostly feels like a high level language.
      Zig gives you a lot more control over your memory, and you can therefore probably write more efficient code in Zig.

    • @xE92vD
      @xE92vD 2 месяца назад

      @@IsaacHarrisHolt So it's basically a new C++?

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  2 месяца назад +1

      It's closer to a C alternative than a C++ alternative, I think. It's like C with more constructs to help with safety

  • @user-he4ef9br7z
    @user-he4ef9br7z 4 месяца назад +2

    Really not a replacement for C though. The whole advantage of C is that it maps very well to assembly and how memory is represented. Zig seems to have too many abstractions, making it more high level.
    Anyways, looking forward to learning and implementing it.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 месяца назад

      Fair take! I think Zig is supposed to give you as much low level control (which I think it does) while being safer than C. Glad you enjoyed the video though!

  • @holthuizenoemoet591
    @holthuizenoemoet591 5 месяцев назад

    noob question, but why not use C?

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +1

      Zig provides more safety in things like optionals and error unions, as well as safer patterns for memory allocation :)

  • @igornowicki29
    @igornowicki29 4 месяца назад +1

    Some music in background would be nice.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 месяца назад

      Noted, thanks!

    • @stoomkracht
      @stoomkracht 3 месяца назад +1

      Noooo it is already way too fast to process and music is just an annoyance and distraction in focussed information sharing.

  • @lmnts556
    @lmnts556 3 месяца назад +3

    Very well done, just not a fan of the zig syntax. I honestly prefer the c syntax over zig. Zig reminds me of java and I really hate java.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  3 месяца назад

      I understand the Java pain. My programming journey started with Minecraft mods and plugins 😅
      But I would be careful of dismissing a language for its syntax!

  • @xarcaz
    @xarcaz 5 месяцев назад

    Zig has a lot of cool stuff, but IMHO there's sadly not much point in using it until it gets something equivalent to RAII.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +1

      That's a fair take. If you use the larger data structures, and then immediately defer the deinit call, it's not THAT dissimilar to RAII patterns

  • @lockbert99
    @lockbert99 4 месяца назад

    I would say the majority of "modern languages" allow exceptions for errors. And they all have a string type. But with "try" and "catch" in the language it looks an awful lot like exception handling.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 месяца назад +1

      I disagree. With exceptions it's difficult to predict where errors are going to come from. Error unions tell you in advance that a function could throw an error via their return type.
      Take JavaScript for example. `JSON.parse('not JSON')`, will error, but there's no warning in advance.
      Also, by returning the error rather than throwing it, you know the code won't stop unless you explicitly tell it to stop.

    • @lockbert99
      @lockbert99 4 месяца назад +1

      @@IsaacHarrisHolt I think input data is ideally verified with a predicate function. If it is too much to do both (verify and process) there should be an indication that a function returns an invalid input error. I wouldn't do that with an exception in C++/Java etc. since it is a known possibility that the data is malformed and the function should return success/failure. If the Zig code is forcing error handling on a function with a known error possibility that's a good feature since programmers can code like, for example, fopen will never return NULL.
      I would save exceptions for errors that cannot be anticipated and which don't have a path forward other than program termination and find out what went wrong.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 месяца назад +2

      Fair take! This is what languages like Go and Rust do. Errors are values, so you're forced to handle them when they arise, but you can also panic to halt termination

  • @ayoubelmhamdi7920
    @ayoubelmhamdi7920 5 месяцев назад +7

    utrafast video, i can't continue watching, if i make it slow the voice will be weird

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +4

      It's meant to be fast! It's a reference video, and you can always pause it 😉

    • @andrewbuzz7308
      @andrewbuzz7308 2 месяца назад +2

      Watching on a tablet it's an uncomfortable experience however you go about it. References are better as text probably

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  2 месяца назад

      Fair take. I appreciate this style isn't for everyone

  • @regeleionescu935
    @regeleionescu935 5 месяцев назад +1

    It looks like Java with pub, fn etc. Very verbose, too many words to do something

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +1

      I disagree, to some extent. Having more reserved words typically makes a language LESS verbose, as you only need a single word to achieve something that takes a lot in other languages (e.g. the `go` keyword in Go).
      I'm curious which language you're comparing to to form this opinion, though

  • @Evan490BC
    @Evan490BC 4 месяца назад +4

    Is this your normal way of talking? You don't _have_ to cram all this content in a 10 minutes talk, you know... A 15 minutes video with you speaking at a slower pace would have been much better.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 месяца назад +4

      I make content like this for the folks like myself who watch stuff at 2x speed and still find it too slow 😅

  • @kveonlichman2917
    @kveonlichman2917 5 месяцев назад +2

    no boilerplate knockoff ⁉⁉

  • @m4rt_
    @m4rt_ 5 месяцев назад

    Jai is better, though it's still in beta.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +4

      Isn't Jai aimed at game programming specifically though?

    • @ErikOnNoobTube
      @ErikOnNoobTube 5 месяцев назад +2

      How is metaprogramming in jai compared to comptime in zig?

    • @Tezla0
      @Tezla0 5 месяцев назад +4

      It probably is, but it will never be released

  • @Little-bird-told-me
    @Little-bird-told-me Месяц назад

    Why bother to learn a new language, where there are no string only arrays defined as [u8], string manipulation function are verbose and clunky, and memory allocators are different paradym. Sure there error handling "try syntax" is good. The complier is your enemy. When we already have Rust why bother with zig ? A simple language with manual memory management and no head files

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  Месяц назад

      All your points are very valid! Zig does have some advantages over Rust - it's a bit lower level, and you have more fine grained control over your memory management without having to resort to "unsafe" blocks and so on.
      Also, comptime is awesome

  • @user-jj5mi1yl6p
    @user-jj5mi1yl6p 4 месяца назад

    Python teaches Zig nothing. Async/await approach can't compete with Golang. Huge mistake.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  4 месяца назад

      Agreed! Go's concurrency is absolutely next level

  • @drygordspellweaver8761
    @drygordspellweaver8761 3 месяца назад

    Just too verbose, and aside from the compile time metaprogramming I don't really see much benefit over vanilla C.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  3 месяца назад

      There are a lot of benefits, I think. Allocators, error unions, tagged unions, unified tooling, better package management...

  • @VioletGiraffe
    @VioletGiraffe 5 месяцев назад

    I see, Zig is just a worse C++. Well that was a waste of time.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +2

      Interesting! I'm curious what your reason is here. Zig is meant as a replacement for C, not C++ - that would typically be Rust

    • @koool56
      @koool56 5 месяцев назад +7

      C++ is a worse C

    • @VioletGiraffe
      @VioletGiraffe 5 месяцев назад +1

      ​@@IsaacHarrisHolt, hi! Don't take my comment too seriously, I have not done an in-depth comparative analysis of the two languages, and your video is all I know about Zig. But a lot of features really do feel like C++ reinvented. The only thing I noticed that C++ doesn't do (yet) is reflection. As a professional C++ developer, I don't see any reason whatsoever to switch to (or even be interested in) either Zig or Rust.

    • @VioletGiraffe
      @VioletGiraffe 5 месяцев назад +1

      ​@@koool56, C is the worst procedural language in active use today. Unless your goal is writing buggy, verbose and hard to maintain code, then it is perfect.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +1

      Understood! It's not for everyone, and if you're happy with C++, then that's okay!

  • @eli1882
    @eli1882 5 месяцев назад +5

    Zig is so nice

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +6

      I quite enjoyed learning it. I don't like the casing conventions, but otherwise it's a fascinating language

    • @eli1882
      @eli1882 5 месяцев назад +3

      @IsaacHarrisHolt I dislike it too, but I felt the same when I started using Rust and have since got over that

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +4

      What's wrong with Rust's casing convention? I feel like snake_case for variables and PascalCase for types is pretty standard. What I don't like about Zig is the fact they also use camelCase for functions on top of that. It's a really weird mix

    • @eli1882
      @eli1882 5 месяцев назад +4

      @IsaacHarrisHolt Zig is definitely the strangest of the two. I came from C, and I always used snake case for everything other than constants. But in Rust, "String," "Option," and "Result" and the like just felt odd at first. It does make sense.

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  5 месяцев назад +2

      Ah, interesting! My background is Python, so I'm very used to snake case for everything except classes

  • @01MeuCanal
    @01MeuCanal 2 месяца назад

    Y'all have some idea of Zig 1.0 ETA? Another question: Why Zig code in Compiler Explorer generate so much assembly lines?

    • @IsaacHarrisHolt
      @IsaacHarrisHolt  2 месяца назад +1

      Sadly I have no idea when Zig will hit 1.0. You'd probably be better off asking one of the core team members.
      Same goes for the second question :)