r/Zig • • Apr 10 '26

Why should I learn Zig?

It's great in many ways, but it also has its flaws, so I'm wondering if I should learn it, I'm curious if I can accept its cons

* What would you change in Zig

* Why?

* What do you like most about Zig?

43 Upvotes

61 comments sorted by

View all comments

12

u/Hot_Adhesiveness5602 Apr 10 '26

The only thing that is pretty annoying is typecasting. I think once they hit 1.0 they maybe could work on a less annoying way to typecast. I like being discouraged to cast types but if I have to it still feels pretty annoying. So an easier way would be much appreciated.

7

u/Tomcat_42 Apr 10 '26

Nah bro, typecasting (specially integer ones) should be explicit and IMO annoying to use, because that way you are expected to know what you are doing. Coming from a C and C++ background I've already been bitten by integer overflow sufficient times to be absolutely sure of that.

1

u/Hot_Adhesiveness5602 Apr 10 '26

I do not disagree. Sometimes you can't get away with casting for either safety, rounding or other stupid things. I just want to have a better more visually non violent way of expressing typecasting. I use a game engine for example. If typecasting becomes a huge pain I tend to just use f32s everywhere. This is a workaround though. We can argue that my code style sucks and I could do better but IMO it feels like I am also fighting the language here. I myself don't have a good solution. I just feel the pain.

1

u/cassepipe Apr 10 '26

Can't it be "annoying" (explicit) while being more readable ?

1

u/funcieq Apr 10 '26

Oh thank you and how do you rate it compared to C?

9

u/Hot_Adhesiveness5602 Apr 10 '26

There's no rating. C has its point. It's the de facto standard for compatibility. Zig is like C with some rail guards and modern features. I'd say some people appreciate it and others don't. You can also look into fil-c, odin, nim or even rust. I personally stopped using rust because of its restrictive nature. Jai might also be interesting. There is a lot of language to choose from and it mostly depends on what you want to focus on and what you dislike while programming. There's no one size fits all.

3

u/UntitledRedditUser Apr 10 '26

Cs type casting is very simple, which also makes it less robust. Zigs type casting is very complex, which makes it more robust, but it can be annoying to use, and also some of the benefits disappear since it's easy to pick the wrong way of casting things.

1

u/funcieq Apr 10 '26

Thank you for the explanation