Views : 156,611
Genre: Science & Technology
Date of upload: Apr 30, 2024 ^^
Rating : 4.953 (85/7,185 LTDR)
RYD date created : 2024-05-22T15:19:29.156905Z
See in json
Top Comments of this video!! :3
If I didn't have Rust, I'd definitely be using Zig. For me, the philosophy behind Rust and Zig is what matters: we can make the compiler do more work for you, so why don't we? While I appreciate certain problems are so much easier to solve in Zig than in Rust, the stuff I write works really well in Rust, and it just clicks for me mentally.
238 |
Zig is definitely an amazing language, but there is so much you should have mentioned, maybe in another video, because as a C developer, Zig is really everything I wish C was.
1 - It's simple and easy to use.
2 - I'ts the most refactorable language (meaning you don't have to jump in 30 files fixing headers and function prototypes.
3 - Comptime is capturing 90% of the power of C++ templates/Macros, while still being very readable and type safe.
4 - The build system is insanely good, I replaced make/cmake with Zig, and with Zig itself it's really amazing.
5 - Zig found the right balance of freedom, meaning you can do exactly what you are doing in C (aka crazy casting and weird stuff unlike Rust) but at the same time the language design makes it very inconvenient and verbose to do so. Which makes it actually easier to just to the right thing and not take any shortcuts. So for once the Type system is actually one that doesn't deceive you because of how loose it is like C or how tight it is like Rust.
6 - Allocators are first class citizen. Even the Std is build around that which is amazing. I really don't get how a manual memory managed language like C didn't come with some form of interface for allocators.
7 - The interops with C is the most natural, intuitive, and straightforward that I've ever seen. You literally just add an @cImport("header.h"); and a exe.addCsourceFile("") in your build.zig and you are good to go.
8 - Zig also has integrated unit testing, which makes it so easier and cheaper to test code. In C I would literally spend 30 minutes writing some code and one hour testing it properly. In Zig you write a function write 2/3 tests forget about it and just do a quick zig build test and you are good to go. Which is also why it's so easy to refactor Zig btw.
9 - No hidden memory allocation, no hidden control flow, everything you read is everything you get, you don't have to guess whether this functions aborts, returns -1 or 0, or whether it sets ernno.
10 - The error handling and all the builting safety features makes it so much easier to write fast and correct code.
I could go on an on but TLDR if you are a C developer you should definitely try Zig as I'm sure it's going to be the real C replacement. In System level programming.
127 |
technically, defer runs at the end of the current scope, not function scope. so if you have something like this:
fn main() {
{
defer print("b");
print("a");
}
print("c");
}
you get this:
a
b
c
if it was at the end if the function it would be this:
a
c
b
if it ran at the end of the function scope rather than watever nested scope it's in, it would try to free a pointer that is out of scope, which doesn't work.
12 |
as a beginner to programming, zig is my favourite out of all the languages i tried, i feel like i can read the standard library code and have an understanding of what its doing, unlike other low level languages where i cant comprehend anything others wrote , but the thing is , it feels like zig is dependant on C , you cant really do anything without importing a C library atleast from my prospective, also it feels like the community around it assumes everyone is coming from using C
24 |
@LowLevelLearning
3 weeks ago
come learn about C and other languages at lowlevel.academy/
57 |