zig will change programming forever

preview_player
Показать описание
For a long time, I really didn't understand where Zig fit in in the developer ecosystem. Now, I think I get it.

🛒 GREAT BOOKS FOR THE LOWEST LEVEL🛒

🔥🔥🔥 SOCIALS 🔥🔥🔥
Рекомендации по теме
Комментарии
Автор

Rust philosophy: make it hard to write bad code
Zig philosophy: make it easy to write good code

jameslay
Автор

You didn't even talk about one of the best features of Zig - seamless integration with C! It's really cool, you can straight import and start using C libs without writing any FFI.

foobar
Автор

Pros and cons of C: you can do what the hell you want

maxturgeon
Автор

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.

zactron
Автор

After reading some of the comments my thought is "since when did programming languages become religions?"

Elesario
Автор

One aspect of Zig I find so refreshing is how minimal it feels - you can comfortably go through the language documentation in a couple hours because there just isn't that much to learn. Zig comfortably gets so much done with comparably so few features.

TheDolphiner
Автор

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.

pierreollivier
Автор

Let's all agree on the fact that Zig has by far the best build system. It is literally built into the language itself. No more bullshit Makefiles, pkgconf or Ninja. Don't even get me started with CMake.

cubemaster
Автор

Zig is for puppygirls, rust for catboys

itrow
Автор

Finally you got zig-pilled :D One nitpick though: in zig defer operates on block scope, not function scope! Go's defer is function scope. Little, but important difference

ImmiXIncredible
Автор

that rare thing - a youtuber prepared to admit that they changed their mind
subbed

samdavepollard
Автор

I think Zig also fills another role : it's a better alternative to unsafe Rust. If I have a Rust function I'm about to mark as entirely unsafe, I think twice and rewrite it in Zig. I think unsafe Rust has more footguns than Zig does, and has a much clunkier syntax.

TheyCallMeHacked
Автор

Zig makes 1000% more sense for game dev IMO ... Dont want to be worrying about Arc<Box<T>> when I'm just trying to do stuff. Zig's "reflection" is also amazing for game dev stuff like network\io serialization, GUI etc

nathanfranck
Автор

When I get asked "What language should I learn?" I think the obvious answer should be C, because like you said the majority of systems is programmed in C and because Zig has still not reached 1.0

From my experience with Rust I can say that Rust FELT like a functional style programming language. It's focus on pattern matching, the immutability by default etc. It also has a lot of niceties of C++ (or some that C++ promised). But that means it also provides _some_ of the same footguns. Operator overloading, meaning that a line like a = b + c can be an unexpected heap allocation.

I feel that Rust is the best language for programmers wanting system programming or high performance that come from functional languages or want many high level features.

I feel Zig is closer to C than Rust is, like Zig has a "no hidden control flow" rule, it doesn't obfuscate how your data/ structs are on disk. I think it has a careful selection of features that make it nice to use for modern programmers. Especially:
1. An explicit error type, making it possible for a function to either return a value or an error, like you showed in the video.
2. A modern build system that doesn't depend on '#include's
3. Defer and what you didn't show errdefer. Making it easily possible to free resources on exit if an error ocurred. Formalizing the goto err pattern known from C. And being more powerful than Go's defer.
4. Very powerful tools to generate code and data structures at compile time. Even explicit loop unrolling with 'inline for'
5. Bounds checking and for loops over slices with a value and index

My favorite feature is that alloc operations explicitly are an operation which can fail. Sure in most cases it's a hassle and I just bubble the error up but being able to properly react in the 5% of cases where I want to react to Out Of Memory situations feels very empowering.

I think Zig has the possibility to become a very serious contender for the low latency, high performance and or system programming space, while I don't think it is taking many of Rusts users because of their different abstraction levels. But that depends on it becoming stable.

Caesim
Автор

At first, I was suspicious of Zig, thinking it was just another pointless endeavor. However, after giving it a try, I'm now addicted to it. I've been able to accomplish incredible things that I couldn't achieve with other languages

hackingarabs
Автор

I would also recommend Odin programming language, it is similar to zig yet feels different, people like using it for GUI applications, Game development, ...
The creator GingerBill is a friend of Andrew Kelly the zig creator, they influenced each other to make these languages what they are now.

obkf-too
Автор

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.

mrt_
Автор

Nice video! Some good pros for Zig, and you didn't even get to its build system, which is arguably even more impressive in concept than the language itself.

BrainySmurf
Автор

what alternate universe is this where C++ don't exist?

mouradchelik
Автор

The reason to learn C is not to use it (much), but because it makes you understand the computer better.

stighemmer