My thoughts on moving my CLI from Deno to Zig

  Рет қаралды 8,547

Code With Cypert

Code With Cypert

Күн бұрын

Пікірлер: 64
@abdushakoor0099
@abdushakoor0099 16 күн бұрын
I wanna learn zig, go or rust. Currently leaning towards go
@CodeWithCypert
@CodeWithCypert 16 күн бұрын
I know Go quite well and Zig and Rust at a beginner proficiency. Go is an extremely good choice to learn in my opinion, but the others are quote interesting choices too!
@ulrich-tonmoy
@ulrich-tonmoy 17 күн бұрын
im seeing more zig development prime moving from rust and kind of like zig zig is like c with modern flavor
@CodeWithCypert
@CodeWithCypert 17 күн бұрын
I’m a big Prime fan and was shocked to see his video yesterday of stopping Rust and looking into Zig but honestly, he said a lot of what I’ve been feeling regarding Rust and Zig so I can totally relate!
@HammytheSammy-ds2em
@HammytheSammy-ds2em 16 күн бұрын
I do C for embedded at work and I started learning Zig for personal projects after I really despised the rigidity of Rust. If I have it my way I’ll never write another line of Rust in my life. Rust is so rigid and the tooling feels like I’m being put into a prison full of micromanagers as correction officers. I understand why developers are trying to build performant stuff on Zig despite it not being mature. It’s simply a pleasant experience and the inconveniences are patched up with huge support of C projects that pick up any failures it currently has.
@CodeWithCypert
@CodeWithCypert 16 күн бұрын
@ while I don’t know if I’ve been as frustrated with Rust as it sounds like you are, I definitely share that sentiment. Zig has been a happy and powerful solution for me so far!
@bionic_batman
@bionic_batman 15 күн бұрын
Yeah, embedding files into the binary via comptime functions in Zig is kinda nice. Go (another excellent choice for this sort of applications) also has this feature out of the box btw.
@CodeWithCypert
@CodeWithCypert 15 күн бұрын
It does! I’ve used it for Go in the past and was pleased to find it in Zig as well!
@knolljo
@knolljo 17 күн бұрын
How was the learning experience of zig?
@CodeWithCypert
@CodeWithCypert 17 күн бұрын
I’m still learning it (idioms, best practices, etc), but learning it was similar to my experience trying to learn Rust. I struggled at first, gave up learning it, got excited about it and went back to learning it and it just sorta clicked the second time. That’s not to say I don’t struggle with parts of Zig still - I ran into a problem with this that I wasn’t 100% sure I’m solving correctly and could be leaking memory, but I’ve recently learned how to use the GPA to help detect that, too… so… I guess overall it’s going well :)
@that_rendle
@that_rendle 6 күн бұрын
Great content but it would be better if you zoomed the browser so viewers can read the text. I use a smaller monitor when recording screencasts, so I am seeing what people on iPad would see full screen, or people on 27” monitors would see in default KZbin.
@CodeWithCypert
@CodeWithCypert 6 күн бұрын
Thank you for the feedback! I’ll try to incorporate that into future videos
@pietraderdetective8953
@pietraderdetective8953 16 күн бұрын
is this normal in most Typescript project? I don't want to bash TS projects, but I do try to avoid them apps (e.g: VScode --> electron)...other than filesize, the memory it's using is also huge comparatively. When I'm hunting for apps, usually I search for C/C++ then Rust/Zig and lastly Python. Python apps are usually just C wrappers so they're highly efficient. anyway I wonder how's the filesize if you use ReleaseSmall to optimize for size?
@CodeWithCypert
@CodeWithCypert 15 күн бұрын
Are you asking specifically about the file size? If so, yes when compiling executables. You have to ship a runtime as well and that’s where most of the filesize comes from. Memory can be better managed in a lot of cases, but TypeScript or JavaScript doesn’t provide you with tools to make many impactful decisions regarding memory management. The trade off is that you usually don’t have to think about it, but when it becomes a problem, it becomes a hard to solve one. That’s a good question. I’ll try a ReleaseSmall build too and see how that turns out!
@bobby9568
@bobby9568 4 күн бұрын
Just found this channel, will you make videos coding from scratch?
@CodeWithCypert
@CodeWithCypert 4 күн бұрын
I have quite a few videos like that, though most are Svelte and Flutter, but I plan to start doing more of those with Zig in the near future
@robertvandrovec
@robertvandrovec 11 күн бұрын
Btw. did you strip info from the executeables? It should make them even smaller 😅
@CodeWithCypert
@CodeWithCypert 11 күн бұрын
I did not. Can you share any more info on that?
@robertvandrovec
@robertvandrovec 11 күн бұрын
@@CodeWithCypert Of course, when compiling via build-exe you can use: -fstrip When using build.zig script just add: exe.root_module.strip = true; For me it reduced binary files approximately 5x, but i don't have any embed files, so it might not be as radical for you. Just keep in mind its meant for final executables, don't use it in development builds, would make debugging much more complex. Would love to know how it worked for you 😁
@robertvandrovec
@robertvandrovec 11 күн бұрын
@@CodeWithCypert Of course, when using build-exe just add flag: -fstrip When using build.zig just add: exe.root_module.strip = true; For me it reduced executable size 5x. You have embed some files so it wont be as radical. Just keep in mind its meant for release binaries, when used on your reguar development/debug build it will make debugging really hard. Would be glad to hear how it worked out for you, btw. youtube is deleting my comments for some reason, or my client is just bugged 😐
@CodeWithCypert
@CodeWithCypert 11 күн бұрын
Thank you for sharing that! I thought you were referring to the original deno implementation as I didn’t expect the zig executables to be able to get much smaller! I’ll have to try that out. I check KZbin to see if any of your comments were being held, but I didn’t see any held comments so I’m not quite sure what the issue is there. I hope it resolves itself though - you have too good of information to not share 😁
@robertvandrovec
@robertvandrovec 11 күн бұрын
@@CodeWithCypert Oh sorry for not stating clearly i was talking about Zig. If you care for your executable size so much, you can also create some optimalizations for the embeded files. From what i saw on your public repo, the files you are embeding are not that large, but if they get larger, you might consider doing some optimalizations on them before embeding (be aware this should be done in build script, loading the files, doing transformations, saving data to new files and embeding those new files in your code), like removing comments, unnecessary white spaces etc. Zig embeds the files as they ARE. Even if you wont implement this, i would be interested to hear how the executable size changed after stripping. 😊
@mystic_monk55
@mystic_monk55 8 күн бұрын
Why not golang?
@CodeWithCypert
@CodeWithCypert 8 күн бұрын
Wanted to use Zig to try it out and I’ve built several CLIs in Go (and still consider it an excellent choice). Do you use Go for your CLIs?
@joshuadonahue5871
@joshuadonahue5871 6 күн бұрын
Why not ride a bicycle?
@CodeWithCypert
@CodeWithCypert 6 күн бұрын
@ 😂 as an aside, cycling is one of my favorite hobbies!
@10e999
@10e999 5 күн бұрын
Using a interpreted language of a CLI is crazy IMO. Welcome to the system programming world !
@CodeWithCypert
@CodeWithCypert 5 күн бұрын
Eh, I had high hopes for Deno and it allowed me to prototype quickly (I had a solution in less than an hour for the original implementation). I do agree that a better long term plan would be using something smaller like Zig though :)
@billvog
@billvog 17 күн бұрын
Great video! Would you still have the same problem with Bun? Did you consider it?
@CodeWithCypert
@CodeWithCypert 17 күн бұрын
You know - I had originally given up Node for Bun (there’s even a video of me mentioning that), but Deno version 2 won me back over. I’m truthfully not 100% sure how big the bun version would be, but I believe it would be comparable to my Deno version as bun would still need to ship a runtime with the executable
@runescapes
@runescapes 16 күн бұрын
the size difference is very cool, but I'm too lazy think about memory allocations and stuff frfr
@CodeWithCypert
@CodeWithCypert 16 күн бұрын
Explicitly allocating is definitely a trade-off and its not always the right trade-off to make! Thanks for watching the video and sharing your thoughts, @runescapes! I appreciate it!
@nikelborm
@nikelborm 15 күн бұрын
look at outdent NPM package for string literals
@CodeWithCypert
@CodeWithCypert 15 күн бұрын
That’s a neat idea, but I’m not sure that I view indentation as a big enough problem to take on an external dependency to solve that issue. Thank you for sharing that though, it’s neat seeing new ways to handle things!
@nikelborm
@nikelborm 15 күн бұрын
@@CodeWithCypert Yeah, I totally understand you
@Richetechguy
@Richetechguy 11 күн бұрын
Nice vid been building a zig cli as well its a fun language to write in
@CodeWithCypert
@CodeWithCypert 11 күн бұрын
I’m glad to hear that you’re enjoying Zig for your CLI! I’ve had a lot of fun with it too. What’s your CLI do?
@Richetechguy
@Richetechguy 10 күн бұрын
@CodeWithCypert it calls my api for reading/writing content into my headless cms
@CodeWithCypert
@CodeWithCypert 9 күн бұрын
Nice! That sounds like an interesting use case. Why’d you choose zig?
@Richetechguy
@Richetechguy 9 күн бұрын
@CodeWithCypert honestly I normally use Rust for production but it's not fun to code all the time wanted to try something new and Zig came up as something interesting and its been a blast
@CodeWithCypert
@CodeWithCypert 9 күн бұрын
@Richetechguy 😱! Just kidding. I get it. Rust is not something that I enjoy writing either. Wish it was, but alas it is not and I’m exploring Zig as an alternative
@abdushakoor0099
@abdushakoor0099 16 күн бұрын
EmbedFile look really awesome
@CodeWithCypert
@CodeWithCypert 16 күн бұрын
It really is! Plus, you mentioned learning Go in another comment -- it's something that you can do in Go, too!
@abdushakoor0099
@abdushakoor0099 16 күн бұрын
@CodeWithCypert i used Go to extend pocketbase for a project and it really is awesome.
@androth1502
@androth1502 15 күн бұрын
zig is to explicit. prefer odin or c3.
@CodeWithCypert
@CodeWithCypert 15 күн бұрын
I am going to have to check out Odin!
@androth1502
@androth1502 15 күн бұрын
@@CodeWithCypert while c3 is closer to my jam, i love odin's straightforward logical design.
@StingSting844
@StingSting844 16 күн бұрын
Nice video. Please fix your audio. The words starting S give a screetch sound and it's hard to focus
@CodeWithCypert
@CodeWithCypert 16 күн бұрын
I appreciate you pointing that out - I’ll make sure to investigate that and get it fixed ASAP!
@justafreak15able
@justafreak15able 14 күн бұрын
That's an issue faced by all content creators from the beginning. It's called Sibilance. I think there are a lot of deEsser software you can use to mitigate this.
@CodeWithCypert
@CodeWithCypert 14 күн бұрын
@justafreak15able I’ll be sure to check that out for future videos! I recently changed microphones so I probably need to revisit my entire audio pipeline
@that_rendle
@that_rendle 6 күн бұрын
@@CodeWithCypertI recommend Izotope RX Elements, it has an AI audio cleanup feature that analyzes an hour of audio in about 15 minutes, then automagically fixes hissing, clicks, hums, pops, background noise, etc. worth every cent
@CodeWithCypert
@CodeWithCypert 6 күн бұрын
Thank you! Ive been applying the De-esser plugin in final cut but havent noticed a ton of difference. Ill definitely check that out!
@mikkurogue
@mikkurogue 15 күн бұрын
Neat stuff, im also learning zig on the side. Mostly due to frustration with dealing with nodejs, and the entire ecosystem around it being essentially one big meme. Ive been enjoying my time in zig, especially given i come from more of a web background and i want to learn more of the lower-level or systems type of stuff to expand my already relatively wide skill set, but into a different branch of the industry. Zig has a few quirks im not the biggest fan of (like auto formatting being wonky, and i cant seem to configure it to my liking but thats maybe a skill issue) and the documentation being somewhat vague for a few things, but overall i really love the experience
@CodeWithCypert
@CodeWithCypert 15 күн бұрын
The documentation is a miss right now, in my opinion. I’ve had to dig into Zig source code to figure out how certain things actually work (many times too). I don’t believe you’re expected to be able to configure the formatter. I think the idea is a standard format that not everyone agrees on is better than 500+ different formats but each one makes its owner individually happy. I could be wrong on that though. I agree with Node and its ecosystem. My background is predominantly frontend web, with some backend and mobile, and I’m just tired of Node and its ecosystem, which is what originally prompted me to look at Deno - which is better than Node for sure, and I still plan to use Deno for a few projects, too!
@mikkurogue
@mikkurogue 15 күн бұрын
@@CodeWithCypert Yeah for sure, some of the docs are a bit weird, some bits are documented perfectly well but others have literally just the source code and no tests and im just "wut" facing the entire time lol. I have been thinking of deno, but I also want to give Bun a try because its written in Zig too. My experience is "full stack" but only out of necessity, i just like doing whatever I want and what is cool and best for the job. I also do believe a TON of people are moving over to Zig now too because of all the praise its getting from bigger creators and other businesses migrating over slowly, which is great because zig will mature faster with more adopters and contributors
@CodeWithCypert
@CodeWithCypert 15 күн бұрын
@ I think you’re right. I was shocked to hear @ThePrimeagen mention that he was considering Zig for 2025. Here’s hoping that’s good for the community!
Get Good at Zig with these resources for learning the language
14:24
Code With Cypert
Рет қаралды 3,5 М.
I hated Zig's build system when I first started learning Zig
8:03
Code With Cypert
Рет қаралды 3,9 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
Why Ghostty is written in Zig (not Rust or Go)
3:42
Changelog
Рет қаралды 47 М.
I can't use a Mac without this app.
13:43
Theo - t3․gg
Рет қаралды 116 М.
5 AMAZING terminal applications you didn't know you needed
8:40
Nick Skriabin
Рет қаралды 16 М.
Zig for Impatient Devs
9:48
Isaac Harris-Holt
Рет қаралды 124 М.
When Zig Outshines Rust | Prime Reacts
23:31
ThePrimeTime
Рет қаралды 147 М.
zig will change programming forever
9:34
Low Level
Рет қаралды 404 М.
"BEST C++ CODE ever written" // Code Review
27:38
The Cherno
Рет қаралды 119 М.
P99 CONF - Zig vs Rust
55:01
ThePrimeTime
Рет қаралды 86 М.
C++ Game Programmer Tries ZIG for the first time.
5:28
Low Level Game Dev
Рет қаралды 76 М.
Why learn Zig?
6:44
Kodaps Academy
Рет қаралды 20 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН