Zig Master: Tagged Union Use Cases
13:19
Zig Master: union
14:15
2 ай бұрын
Zig Master: enum
7:11
2 ай бұрын
Zig Master: Packed Struct
19:16
2 ай бұрын
Zig Master: Extern Struct
7:51
2 ай бұрын
Zig Master: Struct Layout
12:54
2 ай бұрын
Zig Master: Structs
22:57
2 ай бұрын
Zig Master: Alignment in Zig
15:23
Zig Master: Memory Alignment
10:00
Zig Master: Slices
25:25
3 ай бұрын
Zig Master: Many Item Pointer
15:34
Zig Master: Pointer to Array
14:35
Zig Master: Single Item Pointer
18:02
Zig Master: Memory in Practice
20:45
Zig Master: Data in Memory
11:23
4 ай бұрын
Zig Master en Español: Arrays
14:00
Zig Master: Arrays
15:31
4 ай бұрын
Zig Master: var and const
29:08
4 ай бұрын
Zig Master: Zig and ZLS Versions
15:26
Пікірлер
@lolilollolilol7773
@lolilollolilol7773 20 сағат бұрын
woah, the 0.13 doc never mentions the destructuring syntax ! Although tbh, this syntax seems to be of very limited use if only arrays can be destructured. But that's one of the big issues with the language: the doc sucks big time (esp. the doc of the std lib which is a joke, the std lib itself seems to be an afterthought). I wish the doc was a wiki, so that people could at least contribute. Instead of that, it's a single, huge 15,000 lines of HTML page that noone wants to edit.
@lolilollolilol7773
@lolilollolilol7773 20 сағат бұрын
The problem with the philosophy "this is how we implement interfaces in Zig" vs actual interfaces is, people will never use these design patterns simply because they don't know them. The user manual never really mentions them (it talks about the Allocator interface once), and doesn't explain any of these patterns. You have to look at the code of the Allocator interface to see how it's implemented. About 1% of the developers will ever do that. And even if they manage to understand, most will think it's just too much hassle. Anyway, I'm glad I found your channel, because it treats in depth a lot of material that one can see nowhere else.
@maso553
@maso553 23 сағат бұрын
Hi i was wondering if you have a Go course in English?
@deadmarshal
@deadmarshal 4 күн бұрын
Hey. Please consider making a video on multi-dimensional arrays and slices and different methods of passing them to functions as I'm having difficulty understanding these. Thanks a lot!
@dudethebuilder
@dudethebuilder 3 күн бұрын
Great idea! I'll put it on schedule for upcoming videos.
@xx_Ashura_xx
@xx_Ashura_xx 4 күн бұрын
these videos are solid and helpful idk why theres hardly any views or no comments. but thank you for the content much loved!
@phat80
@phat80 4 күн бұрын
you so slooooow… 🤦‍♂️
@rezabani9904
@rezabani9904 5 күн бұрын
Thanks fr great content. I come from a little knowledge of C++ (I haven't write pure C that much) my daily job is in C++ but I think learning some other things like Rust or Zig is gonna be good for me and honestly I don't like the super complexity of C++ either. I hope zig would be my future development arena. By the way you have a great forum with so much cool stuff 👍
@omercelebi2012
@omercelebi2012 6 күн бұрын
Thank you!
@dawid0115
@dawid0115 6 күн бұрын
second example blew my mind 😱 im very interested in learning zig now!
7 күн бұрын
Peer if and peer add work only if "a" (integer) is comptime known, because the compiler can coerce it to float.
@dudethebuilder
@dudethebuilder 6 күн бұрын
True. Thanks for the clarification!
6 күн бұрын
@@dudethebuilder BTW love the series 👍 There were a few moments when I wasn't sure what was going on, so I used the manual and coded some experiments. This time, I felt it was worth mentioning what I found ;) I love Zig. Can't wait to get to some more advanced stuff!
@joaquimpedro4984
@joaquimpedro4984 9 күн бұрын
Truly extraordinary and detailed content! Congratulations.
@tito-xz8mh
@tito-xz8mh 13 күн бұрын
great content man - appreciate you making so many in depth videos on zig
@vuphuocthinh9241
@vuphuocthinh9241 13 күн бұрын
The real world example is execellent! I suggest doing a series of networking (UDP, TCP) in Zig. That would be amazing!
@thilina91
@thilina91 14 күн бұрын
thank you for the amazing explanation!!
@thilina91
@thilina91 15 күн бұрын
thanks for the video!! great stuff!
@thilina91
@thilina91 15 күн бұрын
thank you for the great video on memory layout in zig. cheers!
@omercelebi2012
@omercelebi2012 16 күн бұрын
I can achieve same output with this: const f_slice = array[start..]; so why [0..length]; necessary? Thanks for the series, your channel very valuable to community!
@dudethebuilder
@dudethebuilder 15 күн бұрын
That's true. You can slice to the end with array[0..]. Also, when you're slicing with a length and not a specific end index, the idiomatic way is array[start..][0..length] instead of array[start..start + length]
@grawlixes
@grawlixes 16 күн бұрын
this is EXACTLY the video I wanted for a conceptual overview of memory in Zig. thanks!
@vuphuocthinh9241
@vuphuocthinh9241 18 күн бұрын
Thanks for this amazing series! I got the example on RwLock to work in zig 0.14.0-dev.850+ddcb7b1c1 by using `.unlockShared` instead of `.unlock`.
@dudethebuilder
@dudethebuilder 18 күн бұрын
That's great! Thanks for sharing that tip.
@_rtdp_
@_rtdp_ 20 күн бұрын
Build script for Zig v0.13.0: const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding, }); const optimize = std.builtin.OptimizeMode.ReleaseSmall; const exe = b.addExecutable(.{ .name = "wasmstr", .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); exe.rdynamic = true; // use this // exe.root_module.export_symbol_names = &.{ "alloc", "free", "add", "sub", "zlog" }; // instead of this exe.entry = .disabled; b.installArtifact(exe); }
@dudethebuilder
@dudethebuilder 18 күн бұрын
Thanks for sharing this!
@Dystisis
@Dystisis 25 күн бұрын
When working with arrays of u16 or similar smaller types requiring frequent iterations, is it worth doing alignCast to 64 or something like that at initialization to get the initial pointer aligned up with a word? (Or will it automatically be, maybe?)
@dudethebuilder
@dudethebuilder 23 күн бұрын
When dealing with arrays and pointers to arrays you normally don't have to set the alignment as the array will automatically have the "natural" alignment of the element type. A pointer to an array will also have that alignment automatically. It's only when you are casting a different pointer type (i.e. *anyopaque) where the true alignment is unknown that you have to do an align cast.
@markdatton1348
@markdatton1348 26 күн бұрын
So when you use the || to create a new set, is that essentially equivalent to having just defined some error set ParseError that has equivalent entries to the ones in InputError and NumberError? Or is there still some indirection between ParseError and the sets that make it up?
@dudethebuilder
@dudethebuilder 23 күн бұрын
As I understand it, there's no indirection. The new set contains all the errors of the original sets.
@DistantLights
@DistantLights 27 күн бұрын
Doing a job search and such now so a bit busy, but I was planning on giving C an indepth look when I get settled, should I skip C and go straight to Zig?
@dudethebuilder
@dudethebuilder 27 күн бұрын
If you have the time, a knowledge of C will help you get a better understanding of why Zig works the way it does. Especially when it comes to memory management and pointers. But you could go straight to Zig if your low on time.
@DistantLights
@DistantLights 27 күн бұрын
@@dudethebuilder Well, if that's the case, I'll check C out since it'll be useful for other areas as well. Thanks
@randjey24
@randjey24 Ай бұрын
thanks for this amazing series, I have a question, can I make those "is a tuple" assertions in compile time ? I want to prevent my program to panic at runtime due to a bad input that is known at compile time that it would failed, in this scenario that we made. like the 42 and the struct with named fields.
@dudethebuilder
@dudethebuilder Ай бұрын
I used @panic in the example but I'm pretty sure you can replce that with @compileError and the error will occur at compile time given that all metaprogramming checks in Zig happend at compile time (i.e. the `if (!info.struct.is_tuple)` check).
@randjey24
@randjey24 Ай бұрын
@@dudethebuilder thanks, that's great to know.
@bobsprite6711
@bobsprite6711 Ай бұрын
Excellent!
@noahgsolomon
@noahgsolomon Ай бұрын
exe.addCSourceFile(.{ .file = b.path("src/math.c") }); exe.root_module.addIncludePath(b.path("src")); this is what I had to do to make it work on 0.14.0
@dudethebuilder
@dudethebuilder Ай бұрын
Correct! Thanks for sharing.
@BeOnlyChaos
@BeOnlyChaos Ай бұрын
Arguments to functions being immutable had me confused for a while. I wonder why Zig does not error if a function makes a modification to an argument that was not passed in as a pointer. At least that's what I saw when I was trying to modify a struct that I passed in (without using pointers).
@dudethebuilder
@dudethebuilder Ай бұрын
If the passed in struct has pointers within it, you can modify the values they point to in memory since they are accessible directly via the pointers no matter where they are (assuming the pointed-to value isn't const). If the passed in struct only has non-pointer types, you should get an error if you try to modify them within the function, because you would be trying to modify a const copy of that struct.
@eduardabramovich1216
@eduardabramovich1216 Ай бұрын
Nice stuff about zig, have you tried other langs like Odin and C3? What made you choose Zig?
@dudethebuilder
@dudethebuilder Ай бұрын
I've been through a pretty long list of languages over the years, but from the "newer" ones, I did some Go, Rust, Nim, and now Zig. They're all great languages and apply unique solutions to programming problems. But I found Zig to be the most radical re-thinking of low-level systems programming to truly interoperate seamlessly with C and replace C when needed. IMO Zig is even lower level than C since you can build programs that don't even depend on the C library and be free of any behind the scenes runtime that brings in a default allocator (malloc) if you want. I believe Zig is the only one that easily achieves that level of standalone independence from C.
@joebuydem
@joebuydem Ай бұрын
extremely helpful video thank you.
@rafaelsantizo1748
@rafaelsantizo1748 Ай бұрын
que excelente papa, gracias por estos videazos tanto de rust como estos. los de rust siempre los utilizo como referencia.
@devbites77
@devbites77 Ай бұрын
Great visualizations make it so easy to understand.
@omercelebi2012
@omercelebi2012 Ай бұрын
Thank you. Can you suggest how to study zig in effectively? I would like to know if reviewing repos help or make it worse? I don't have low level background, only Python, Typescript.
@dudethebuilder
@dudethebuilder Ай бұрын
I would recommend looking at the standard library source code in the Zig repo itself. Data structures like ArrayList, HashMap, and Bitset will give you a feel of how Zig code is written, tested, and how its peculiar allocation paradigm is used. Also, reading the Language Reference is very helpful in learning the language for the first time and as a reference later on.
@devbites77
@devbites77 Ай бұрын
useful info. cheers
@devbites77
@devbites77 Ай бұрын
Great content; learned a ton. I am warming up to kickstart after first rejecting it and doing manual config.
@AdityaSingh-uv8uf
@AdityaSingh-uv8uf Ай бұрын
I know a little bit of c++ should I invest my time in zig because I've come to know it is much safer compared to c and c++ in terms of memory leaks and thing ?
@dudethebuilder
@dudethebuilder Ай бұрын
Yes, I would recommend learning Zig if you know C or C++ because it will feel very familiar in the way you can control memory, with added safety checks and no null pointers.
@TekExplorer
@TekExplorer Ай бұрын
"stud fumt" seriously? you do know that's "standard" "format" right?
@dudethebuilder
@dudethebuilder Ай бұрын
I think you'll find very few people in programming languages communities that would say "standard format" versus the abbreviated "stud fumt". I actually first heard these abreviated terms when working with Go some years ago.
@lolilollolilol7773
@lolilollolilol7773 20 сағат бұрын
@@dudethebuilder they also use these ugly abbreviations in C++. I hate them.
@v0_mx297
@v0_mx297 Ай бұрын
Excelente contenido 👌🏻
@juanpablouriolbalbin887
@juanpablouriolbalbin887 Ай бұрын
I think you are allocating new memory even though you still have space for one more element. In your example, you double the capacity from 8 to 16 when you add the 7th element (index 6). Therefore, you still have space for an 8th element.
@dudethebuilder
@dudethebuilder Ай бұрын
Correct! I noticed that just as I finished recording the video and added a note to the description. The actual code on the repo has been fixed. Thanks for the heads-up.
@rodriidamn98
@rodriidamn98 Ай бұрын
Thanks for the content ❤
@tubeincompetence
@tubeincompetence Ай бұрын
Is ending every other sentense with "OK" something that will remain during the playlist? I guess I have to filter it out in my brain somehow :D
@dudethebuilder
@dudethebuilder Ай бұрын
I think that at some point along the series I cut down on the "OKs", but still leave some around for good measure. :D
@thilina91
@thilina91 Ай бұрын
I kinda wanted to try out nvim for some time and finally gonna give it a try now. Thanks for the video!
@EliasDorneles
@EliasDorneles Ай бұрын
This is great stuff, man! This example is exactly what I needed: it answers several questions I had and gives a great example of generic data structure! Thank you so much for this!
@pedrobotsaris2036
@pedrobotsaris2036 Ай бұрын
thanks for this!
@DanMackAlpha
@DanMackAlpha Ай бұрын
interesting, when I just compiled this code on a fresh zig build (version 14.0-dev.109), I get a compile error because it thinks that gopr should be a const instead of a var. thanks for the video on making and using hashmaps.
@dudethebuilder
@dudethebuilder Ай бұрын
Hmm, good to know. I haven't tried 0.14 yet. Tahnks for the heads-up!
@DanMackAlpha
@DanMackAlpha Ай бұрын
how would one print out the nodes in the trie? I can't seem to get the syntax quite right 😞
@dudethebuilder
@dudethebuilder Ай бұрын
If you implement the format method as per the std.fmt instructions to provide for formatting of Node and Trie, you can then print the trie using the normal print functions and the Trie's format method would traverse the tree (like in the lookup method) and call the Node's format method on its way down. I think I've implemented this format method for other structs in previous videos. If I have a chance, I'll update the Trie code to add this funtionality.
@telesphore4
@telesphore4 Ай бұрын
I really like these new videos that use Zig on small single episode projects instead of just explaining Zig syntax or the standard lib. Don't get me wrong, I like the explainers, but I want to know how to put the pieces together to make something useful. Live coding videos are fine, but they're typically very long. These are short, to the point videos that still get something done with Zig which is a niche that afaik is unique to this channel. Maybe you could also do videos on parts of larger projects, that are still discrete and self-contained, like how to process command-line arguments, or how to parse JSON. I dunno it's just a thought. Edit: I mean to do these things for real (In anger.) and not just using the libraries themselves... Maybe a simple CSV reader would be a better project, seeing that there is no std library for that.
@dudethebuilder
@dudethebuilder Ай бұрын
Those are some great suggestions and I will definitely take them into consideration for upcoming episodes. Thanks a lot for sharing your ideas.
@RagHelen
@RagHelen Ай бұрын
Everything is so much quicker and easier if you have Windows and a mouse :)
@dudethebuilder
@dudethebuilder Ай бұрын
lol. Haven't touched a Windows machine since XP. Once I went UNIX/Linux, I never turned back!
@raptorate2872
@raptorate2872 Ай бұрын
Hello Dude thanks for all your help, you are a lifesaver for those who want to learn zig. May i ask how to navigate through the 2 different playlists you have. It would seem like they have overlapping concepts.
@dudethebuilder
@dudethebuilder Ай бұрын
Thanks for the support. I would recommend watching the videos in Zig in Depth first, specifically those that pertain to the language and not the build system or project tools. Then you can catch up with recent changes with the videos in Zig Master.
@alexanderzikal7244
@alexanderzikal7244 Ай бұрын
Thank You! I did not understand the last step "generic", because the change to @FloatFromInt(i) will then only work with floats. What happen if You use again this function in main with int?
@dudethebuilder
@dudethebuilder Ай бұрын
Making Stack generic means you can then make Stacks with different item types. If you want to handle integers, you make a Stack with an integer type. To use floats, you make a Stack with a float type. But once you make a Stack with one item type, you can't use it for another item type, so that's why the float from int cast is necessary if working with a Stack of floats.
@alexanderzikal7244
@alexanderzikal7244 Ай бұрын
@@dudethebuilder Thank You!
@severgun
@severgun Ай бұрын
What is the difference const vs var in terms of array? Is it const reference as in most languages or const values?
@dudethebuilder
@dudethebuilder Ай бұрын
Arrays in Zig are values so a const array is immutable. Pointers and slices can be const themselves (as values) in addition to the values they point to, which can be const or not.