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.
@lolilollolilol777320 сағат бұрын
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.
@maso55323 сағат бұрын
Hi i was wondering if you have a Go course in English?
@deadmarshal4 күн бұрын
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!
@dudethebuilder3 күн бұрын
Great idea! I'll put it on schedule for upcoming videos.
@xx_Ashura_xx4 күн бұрын
these videos are solid and helpful idk why theres hardly any views or no comments. but thank you for the content much loved!
@phat804 күн бұрын
you so slooooow… 🤦♂️
@rezabani99045 күн бұрын
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 👍
@omercelebi20126 күн бұрын
Thank you!
@dawid01156 күн бұрын
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.
@dudethebuilder6 күн бұрын
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!
@joaquimpedro49849 күн бұрын
Truly extraordinary and detailed content! Congratulations.
@tito-xz8mh13 күн бұрын
great content man - appreciate you making so many in depth videos on zig
@vuphuocthinh924113 күн бұрын
The real world example is execellent! I suggest doing a series of networking (UDP, TCP) in Zig. That would be amazing!
@thilina9114 күн бұрын
thank you for the amazing explanation!!
@thilina9115 күн бұрын
thanks for the video!! great stuff!
@thilina9115 күн бұрын
thank you for the great video on memory layout in zig. cheers!
@omercelebi201216 күн бұрын
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!
@dudethebuilder15 күн бұрын
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]
@grawlixes16 күн бұрын
this is EXACTLY the video I wanted for a conceptual overview of memory in Zig. thanks!
@vuphuocthinh924118 күн бұрын
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`.
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?)
@dudethebuilder23 күн бұрын
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.
@markdatton134826 күн бұрын
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?
@dudethebuilder23 күн бұрын
As I understand it, there's no indirection. The new set contains all the errors of the original sets.
@DistantLights27 күн бұрын
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?
@dudethebuilder27 күн бұрын
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.
@DistantLights27 күн бұрын
@@dudethebuilder Well, if that's the case, I'll check C out since it'll be useful for other areas as well. Thanks
@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Ай бұрын
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Ай бұрын
@@dudethebuilder thanks, that's great to know.
@bobsprite6711Ай бұрын
Excellent!
@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Ай бұрын
Correct! Thanks for sharing.
@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Ай бұрын
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Ай бұрын
Nice stuff about zig, have you tried other langs like Odin and C3? What made you choose Zig?
@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Ай бұрын
extremely helpful video thank you.
@rafaelsantizo1748Ай бұрын
que excelente papa, gracias por estos videazos tanto de rust como estos. los de rust siempre los utilizo como referencia.
@devbites77Ай бұрын
Great visualizations make it so easy to understand.
@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Ай бұрын
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Ай бұрын
useful info. cheers
@devbites77Ай бұрын
Great content; learned a ton. I am warming up to kickstart after first rejecting it and doing manual config.
@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Ай бұрын
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Ай бұрын
"stud fumt" seriously? you do know that's "standard" "format" right?
@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.
@lolilollolilol777320 сағат бұрын
@@dudethebuilder they also use these ugly abbreviations in C++. I hate them.
@v0_mx297Ай бұрын
Excelente contenido 👌🏻
@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Ай бұрын
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Ай бұрын
Thanks for the content ❤
@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Ай бұрын
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Ай бұрын
I kinda wanted to try out nvim for some time and finally gonna give it a try now. Thanks for the video!
@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Ай бұрын
thanks for this!
@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Ай бұрын
Hmm, good to know. I haven't tried 0.14 yet. Tahnks for the heads-up!
@DanMackAlphaАй бұрын
how would one print out the nodes in the trie? I can't seem to get the syntax quite right 😞
@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Ай бұрын
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Ай бұрын
Those are some great suggestions and I will definitely take them into consideration for upcoming episodes. Thanks a lot for sharing your ideas.
@RagHelenАй бұрын
Everything is so much quicker and easier if you have Windows and a mouse :)
@dudethebuilderАй бұрын
lol. Haven't touched a Windows machine since XP. Once I went UNIX/Linux, I never turned back!
@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Ай бұрын
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Ай бұрын
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Ай бұрын
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Ай бұрын
@@dudethebuilder Thank You!
@severgunАй бұрын
What is the difference const vs var in terms of array? Is it const reference as in most languages or const values?
@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.