Using Zig | My Initial Thoughts on Ziglang
All of the learnings were done on twitch where i build a stack data structure (planning on doing more) and going through and building an interpreter. We are just finishing up the extended lexer grammar and then we are on to the parser (at the time of this comment)!
### Twitch
Everything is built live on twitch
Twitch : https://bit.ly/3xhFO3E
Discord: discord.gg/ThePrimeagen
Spotify DevHour: https://open.spotify.com/show/4MLaDrQcQ5mi3rsnvWkwPt
### Editor
All my videos are edited by Flip. Give him a follow! https://twitter.com/flipmediaprod
Join this channel to get access to perks:
https://www.youtube.com/channel/UC8ENHE5xdFSwx71u3fDH5Xw/join
### Links
Linode: https://linode.com/prime
https://discord.gg/ThePrimeagen
Twitch: https://twitch.tv/ThePrimeagen
Insta: https://instagram.com/ThePrimeagen
Twitter: https://twitter.com/ThePrimeagen
VimRC & i3: https://github.com/ThePrimeagen/.dotfiles
Keyboard 15% off https://bit.ly/Prime360 USE CODE PRIME360
#coding #neovim #typescript #programming #vim #softwareengineering #codinglife #webdesign #webdevelopment #webdev #javascript #rustlang #rust #twitch #twitchstreamer #programmerhumor #codinghumor #software #softwareengineer #softwaredeveloper #softwaredevelopment
by ThePrimeagen
linux smtp client
Real Talk, no idea how i accidentally uploaded with 720p. Deal with it. Sorry, not sorry, subscribe to make it 1080p
Seems to me like we have to keep an eye on this language. It can only get better. A couple of the ideas are very nice, maybe even Rust can learn a bit from it 😅
The problem with this refusal to allow exceptions is this cripples the language when there are real resources that could need cleaning up.
My runtime panics without releasing a global OS level named lock/mutex? Now I need to reboot my machine because this language has opinions about exceptions. Clearly not designed by people with ability to understand why we use C, and C++ and Pascal, and Python+Extensions instead of something else. Writing cleanup code for failures, or for cleaning up real resource handles in twenty places is the reason why Go is crap. If you can't write an operating system kernel, and a game, and a database engine in it, it's a bad language.
Zig Use Cases where I think it will take over:
# Embeded Systems – it has 1st class C interop and can reuse C code and compile it into the output. Writing in straight C sucks, zig is much better and you can use all your c headers etc. I.e. Arduino's, mico controllers, robotics, firmware, and on and on. You want to write a driver in C, or zig? Zig hands down and you can reuse all the c headers etc for your complex nvidia GPU driver code base or w/e in zig.
# File Format libraries, i.e PE File Format, Font formats etc, you can use c headers from windows, linux etc. So if you need to develop a new file type specification for something complex like AI model standardization (i.e. making safetensors not suck, standardizing file formats etc), a lot easier to build that kind of stuff in Zig and compile out to dll's, libs, etc and then link those in from Rust, Python, .Net, etc etc.
# Game Dev – Again, it's interop with C shines here, how many mountains of complex game code out there is written in c, c++ etc that can just easily be used in zig?
Honestly, it's interop with C etc is so good, pretty much anyone looking to get off c, c++ etc will go to zig before they learn rust. Assuming zig can get to 1.0 in time.
Such a cryptic language for reading.
I know my expectations is biased because i mostly work on python. But damn that is dificult to read
Did you see the video: How to Use Abstraction to Kill Your API – Jonathan Marler? Нe has a beard, so we can trust Zig! (Link: https://www.youtube.com/watch?v=aPWFLkHRIAQ)
Zig is good for gamedev – at least that's what I'm using it for. It's SO easy to make an app that's cross platform – and I don't mean Windows, Mac, Linux, I mean like Windows, Macos, Linux, Andriod, IOS, X86, ARM, RISCV, PowerPC, MIPS, 32 and 64 bit, with a single codebase and build system, and they can all be compiled on a single computer with a single command.
It's not going to replace C any time soon – it's still VERY early days. However, Its build system is already being used in projects like Raylib, since it's so much more cohesive and usable than CMake. Even though Raylib itself doesn't have a single actual line of Zig.
It still has a lot of problems – String handling is an absolute pain (like in C actually), the documentation for the build system is incomplete and in some cases completely missing, the standard library is missing some key data structures (notably Sets), and so on. But all of these are problems that can be fixed.
It's insanely easy to learn as well – I took 2 days to learn it, and a week in I'm already proficient in it. Contrast to Rust where I spent two weeks trying to wrap my head around it and eventually gave up.
Youre awesome for sharing this hosting insight! Ive used Bluehost and GoDaddy, but Cloudways with TST20 coupn is the real gem.
Can you or anybody in the comments recommend one or multiple good error handling patterns?
@1:52 – this vaguely reminds me of lua's pcall
gradle deez nutz I can feel it lmao
Uses 'fn' to as the function keyword, I love it already.
8:10 100% on java! god know's what all is there, I recently tried to make some chances for a friends codebase, ykw it's was a lot harder than anticipated.
This guy juat really wants to code in python
Yes, there’s room for Zig.
I started learning Rust a while back and find it hard to grasp.
Then tried Zig and felt right at home (referred from Bun’s Author).
I know Zig isn’t on par with Rust’s memory safety lbut it’s ok! That’s the trade off I’m willing to make.
I want something non-gc and am able to be productive in it.
8:04 i Completed Java in 3 Years 💀👀😂 not really completed but worked with major Frameworks, I'm still in learning stage 💀 Java has it's own universe 💀😂 Once you stuck into Java it is hard to get out 💀
Special error types seem really nice to use.
Prime, have you ever thought about posting your livestream series on YouTube, specially the programming ones, like the one you mentioned in this video? Because in your Twitch channel I cannot find the livestream videos of said streams.
The extremely high compilation time, the lack of certain modern features by default like async, the struggle of integrating with C/C++ code, and certain safety-imposed restrictions are driving me crazy while using Rust. As a fan of the good old C, I think I'll enjoy getting to learn Zig.
Are you DrDisRespect in your free time?
On the error return thing, that's just stupid. Basically they're making a more annoying and less optimized way of using a pointer as a return with the possibility that it's a NULL pointer. FFS, just return a damn pointer and check it, it's not difficult or going to lead to errors if actually run tests on your code. Oh boohoo, the C compiler doesn't hold your hand and suck you off if you make a mistake. Programs have existed for free, and that are open source, for decades to check your C code, for all kinds of errors. Yeah, even the errors that Rust and Zig don't check for in their compilers. If you're a new programmer, then fine, use a baby brain language and contribute to the downfall of civilization as humans get more and more stupid as time goes on. But if you already know C and are having all the errors that people keep whining about, then you are the problem, not the language, and you should get out of the industry before you make the world any worse of a place than it already is.
Why do you review Ada and show what a real alternative to C offers?
The features of Zig are nice, but the syntax kinda sucks.
Errors as values is a C-like thing to do, I love C!
if (item) |foo| { … } looks the same as if (item != null) { … } . What kind of next level bs is that?
There are too modern languages trying to dethrone C/C++…..Zig, D, rust, carbon , beef.. who else??
C will be always your father. Remember it
i think zig has a huge potential in the Wasm world.
for perspective, i write and design Rust/Wasm that is shared between mobile, browser, and desktop. Zig toolchain executing completely in Wasm (eg compile Zig to Wasm or link Wasm components together, all in Wasm) seems to introduce a new paradigm of portable development and execution.
we’re not using zig for anything prod ready yet, but i think Zigs foundation in Wasm might beat out Rust in the long term. i’m excited to see the package management system and compiler integrate with the Wasm pre-spec stuff (eg. Wasm component model).
Keep going zig!
It's fun to watch how this.. languages. How they slowly evolve into brainfuck.
Step 1: let's remove semicolon, oh even better – let's make it optional
Step 2: let's get rid of function keyword and shorten syntax in general
3: why stop here, let's add more special characters and their meaning will depend on context, like ? can be optoional and ? can be short equivalent of if, ! can be boolean not or it can get value of optional or it can be sign that the function (sooory, that fn) return an error, etc etc
4: []()->{} where [](){} are optional
5: Actually, let's use special symbol for everything like in APL
…
n: Brainfuck
Well…
Zig came up specifically to make the work with C/C++ codebases easier and less prone to human mistakes, which are precisely the two main positive points you found. I guess it shows it is doing just fine so far. It's not here to fight Rust, Go, Typescript nor Java anyways.
And I believe Carbon is intended to fight for territory against Zig in the future.
Did you know that the homepage for download safari says that it's BLAZINGLY FAST?
I see that you've seen V [which was my major curiosity] but I was also wondering what you thought about Nim?
lisp macros are cool. scheme macros are great. racket macros are better
Zig's purpose is to suck all the C programmer in.
Am I the only programmer in the world who doesn't have problems with throwing errors?
I see Rust as being a better C++, and Zig as being a better C
Like it's literally C except better, idk
We have a fellow Zigger hope you like the programming lan
Idk rust macros are easy to make
Why are you a programmer?!
I see Zig being perfect for targeting WASM (unless of course you're a Rust dev, which I'm not).
this quick overview was super helpful to me. thanks!
Replace Rust now that it has its problems.
Anybody else feel like Zig could be a good choice for gamedev? Fast, simpler than C/C++ but with great interop?
Google is developing Carbon, which is supposed to be the C++ killer, for real this time… right?
The use of parentheses around everything makes everything look like a function, there's no need, just define your grammar better. The use of quotes around names in imports, still breaks the feeling that there was a real module system, NO! IT'S JUST TEXT FILES!! Weird he took Ruby's unpacking syntax. I'm sure there are other reasons I won't like it.
Do you think people would swtich from python to Zig? I chose python over perl simply because I could be more productive in python more quickly than I could in Perl.
tranditionally try catch is actually leads to very good code, you can throw patternized error in arbitrary places of your application, and handles them in a uniformed way at the top level, and reuse this error handling function at any layer if you want detailed control, I see nothing about that TBH.