Comments by "" (@pierreollivier1) on "zig will change programming forever" video.
-
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.
262
-
@jorge42343 The difference is that It's less verbose than Rust, and the compiler won't fight you for it, but at the same time if the compiler see something that it knows to be wrong it won't let you shoot you in the foot like C would. To give you a better representation, Rust is like that overly protective mother that will not let you do anything because it's "unsafe", While C is the father who doesn't see anything wrong with letting you base jump at the age of 8 from a bridge and expect you to just be ok. Zig is the reasonable aunt, that will warn you but still be ok if what you want to do is reasonable. Also when I say that Zig is more verbose when you do some unsafe thing, It doesn't mean that it's painful or unbearable, you just have to use explicit builtins which are obviously more verbose than no builtins at all, but at the same time they improve the code readability and in the language design the intent of the Zig creator was to make the "easy" path also the correct one, so while you can still take shortcuts, those shortcuts are more verbose, and they gently push you to a more "correct" approach.
15
-
7
-
4
-
2
-
@mgord9518 Yes that's for me one of my favorite features of the language, is just how much readable it is, at doing what you would do in C. One example that I love is logging. I'm a sucker for logging things to a file as a mean to debug, in C it's cumbersome, and you can't really use printf unless you also use fflush and all that jazz, you have to change the %_ to do anything, or you have to write your own implementation of printf, and even that is tricky and annoying, in Zig, you just implement a format functions, and you can call that type format function it's very easy and, with comptime you can automate that process, and basically recursively check the type of the field at comptime, to see whether it has a member called idk print, or if it's a simple type just use {any} with it it's really amazing..
1
-
1
-
1
-
Because C++ sucks, it's not ergonomic, it's not fun, it's very bloated and hard to read. Zig achieves 90% of the power of C++ while remaining very readable, understandable, and that's why it's worth talking about. I love C++, but this language, is just not a good language compared to what exist today, it's hard to collaborate with people, it's hard to use some else's code because you have to audit it all to make sure it works like you want it to work. It's hard to debug with templates, the error messages aren't good, the compiler is quite slow, but the real problem is the amount of features available in the language, and how you can basically do everything with everything. I know people don't like to hear about it, but at the end of the day a programming language is just a tool, not a church to go on a crusade for, everyone with an ounce of objectivity can see that C++ is just not a good language this days, when things like Rust, Zig, Odin, Jai, exist.
1