zig is the future of programming. here's why.

Ғылым және технология

For a long time, I really didn't understand where Zig fit in in the developer ecosystem. Now, I think I get it.
🏫 COURSES 🏫 Learn to code in C at lowlevel.academy
📰 NEWSLETTER 📰 Sign up for our newsletter at mailchi.mp/lowlevel/the-low-down
🛒 GREAT BOOKS FOR THE LOWEST LEVEL🛒
Blue Fox: Arm Assembly Internals and Reverse Engineering: amzn.to/4394t87
Practical Reverse Engineering: x86, x64, ARM, Windows Kernel, Reversing Tools, and Obfuscation : amzn.to/3C1z4sk
Practical Malware Analysis: The Hands-On Guide to Dissecting Malicious Software : amzn.to/3C1daFy
The Ghidra Book: The Definitive Guide: amzn.to/3WC2Vkg
🔥🔥🔥 SOCIALS 🔥🔥🔥
Low Level Merch!: lowlevel.store/
Follow me on Twitter: / lowleveltweets
Follow me on Twitch: / lowlevellearning
Join me on Discord!: / discord

Пікірлер: 868

  • @LowLevelLearning
    @LowLevelLearningАй бұрын

    come learn about C and other languages at lowlevel.academy

  • @VivekYadav-ds8oz

    @VivekYadav-ds8oz

    Ай бұрын

    can u pls give me ur course for free? i am in my pre-final year in uni and I have an intern in TI in a month, I need to get pro in C 🙏 im broke haalp

  • @nickbors-sterian

    @nickbors-sterian

    Ай бұрын

    hey, if you could price your course better it would be great for us students. Im struggling to pay accomodation and my car payment (i need it to get to campus) but a student plan would greatly help but currently i am unable to afford your courses so im stuck with your generously provided free youtube content. I want to support you, but i need to support myself first :(

  • @AWIRE_onpc

    @AWIRE_onpc

    Ай бұрын

    @@simpleprogrammingcodes3834 i dont know c

  • @dylmm

    @dylmm

    Ай бұрын

    Hey LowLevelLearning, you should probably include zig in the title of the first video about zig, I had the use youtube's channel search function to find it.

  • @kevinrineer5356

    @kevinrineer5356

    Ай бұрын

    Wow that's pretty cheap for a lifetime license! I hope you get into MPI someday.

  • @foobar3202
    @foobar3202Ай бұрын

    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.

  • @RFelizardo

    @RFelizardo

    Ай бұрын

    This is what I was excited about, but when I started looking at using it for a pet project I started noticed that most folks still ended up writing bindings for common libraries anyway to get around issues with C APIs not being descriptive enough in some cases. Kind of ruins the magic. :(

  • @Sevenhens

    @Sevenhens

    Ай бұрын

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

  • @matrix07012

    @matrix07012

    Ай бұрын

    @@Sevenhens You can't every library though

  • @_somerandomguyontheinternet__

    @_somerandomguyontheinternet__

    Ай бұрын

    @@matrix07012 You can because C++ is a superset of C, meaning any C code is valid C++ code.

  • @foxwhite25

    @foxwhite25

    Ай бұрын

    @@matrix07012 like you can use every library seamlessly in zig

  • @Elesario
    @ElesarioАй бұрын

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

  • @andrewdunbar828

    @andrewdunbar828

    Ай бұрын

    Several decades ago.

  • @mgord9518

    @mgord9518

    Ай бұрын

    Since their inception

  • @user-vj9hb3gy6d

    @user-vj9hb3gy6d

    25 күн бұрын

    Rust is king! Repent and learn Rust to experience heaven on Earth! Zig is for sinners.

  • @Rudxain

    @Rudxain

    18 күн бұрын

    If you've read "PHP: a fractal of bad design", you'll notice some obvious parallelisms between the PHP community and any cult/sect/religion. This also reminds me of the joke "Cult of Vim VS Church of Emacs"

  • @baxiry.

    @baxiry.

    13 күн бұрын

    Zaig community is more logical. Rast community is more religious

  • @TheDolphiner
    @TheDolphinerАй бұрын

    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.

  • @fr3ddyfr3sh

    @fr3ddyfr3sh

    Ай бұрын

    Honestly, that sounds like Go 8 years ago. Or every sane language during their early years. It’s a fundamental law that the older a language gets, the more docs and features it will have.

  • @TheDolphiner

    @TheDolphiner

    Ай бұрын

    @@fr3ddyfr3sh Sure, in practice some amount of that is inevitable - but to offer a reply to your example: Generics in Go needed to be a new feature added to the language. In Zig, the feature that was already there, comptime, is so powerful that it produces generics for free. Same for interfaces (as awkward as they currently can be). I don't want to get too hung up on this as a be-all end-all of how programming should be done, but it is my takeaway from the language in a comparable way to how I believe Rust popularized to many people what a modern typesystem could feel like.

  • @fr3ddyfr3sh

    @fr3ddyfr3sh

    Ай бұрын

    I’m a little hyped for zig too. I always thought an expression-style try-catch feature would be cool, and zig simply has it out of the box :)

  • @189Blake

    @189Blake

    Ай бұрын

    I heard that they want to follow C philosophy and keep the language as slim as possible.

  • @quinten01

    @quinten01

    Ай бұрын

    @@fr3ddyfr3sh wym? Go is still like that today.

  • @zactron1997
    @zactron1997Ай бұрын

    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.

  • @scheimong

    @scheimong

    Ай бұрын

    Agreed. I just wrote a microservice yesterday in Rust that takes a netcdf file and cuts out a subregion based on a geojson "selection". I've been writing rust for 4 years so I kind of knew what to expect, but I was still shocked when all the tests passed on the first try. I was so happy that I went bragging to my colleagues for the rest of the day 😅. And because it's rust, all possible errors have been handled gracefully and I don't have to worry about race conditions at all. Granted I used quite a bit of well-tested third-party libraries, but still there were about 1000 lines of my own code. I'm pretty confident when I say that had I written it in any other language (Go, Java, Cpp, or god forbid JS), debugging alone would have taken me at least 2 days.

  • @raylopez99

    @raylopez99

    Ай бұрын

    @@scheimong 33% of software bugs cannot be caught by the Rust compiler.

  • @catto-from-heaven

    @catto-from-heaven

    Ай бұрын

    @@raylopez99 33% is way better than 100%

  • @raylopez99

    @raylopez99

    Ай бұрын

    @@catto-from-heaven True, if you can fight the compiler. I played around with Rust for a few months then gave up. If more devs adopt it, and it's taught in uni, it might have a future; same with Zig. Otherwise not and with AI on the horizon it might be moot.

  • @mgord9518

    @mgord9518

    Ай бұрын

    ​@@raylopez99Except it's not moot. If AI becomes as good a programmer as everyone thinks it will be then we can just abandon all languages because the godly AI will program everything directly in fully-optimized machine code. At that point, maybe everything is moot. We can just abandon our jobs because the AI will do everything and give us UBI

  • @cubemaster1298
    @cubemaster1298Ай бұрын

    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.

  • @LowLevelLearning

    @LowLevelLearning

    Ай бұрын

    you dont like having version control for your build systems build system? \s

  • @Adiee5Priv

    @Adiee5Priv

    Ай бұрын

    Rust moment?

  • @ScibbieGames

    @ScibbieGames

    Ай бұрын

    C++ dependency management can non-controversially be declared utter fucking dogshit.

  • @vintagewander

    @vintagewander

    Ай бұрын

    We have cargo for rust tho

  • Ай бұрын

    ​@@LowLevelLearning escaped s is crazy

  • @sirbuttonhd
    @sirbuttonhdАй бұрын

    Zig makes low level development fun, accessible and productive

  • @iraniansuperhacker4382

    @iraniansuperhacker4382

    Ай бұрын

    it wasnt already fun?

  • @sirbuttonhd

    @sirbuttonhd

    Ай бұрын

    ​@@iraniansuperhacker4382 as a dev coming from the high level world, no :D. C is rather banal, C++ is universally hated for a million different reasons, CMake is hell, Rust priorities safety over developer productivity and happiness. Zig is the only contender I really believe in. (Other than Odin and perhaps Jai, which are even more esoteric than Zig)

  • @sirbuttonhd

    @sirbuttonhd

    Ай бұрын

    @@iraniansuperhacker4382 C = mundane, C++ = universally hated for a million different reasons, CMake = a pain in the ass, Rust = no respect for developer productivity, Zig = finally a worthy tool

  • @Luke.-cv9uv

    @Luke.-cv9uv

    23 күн бұрын

    @@iraniansuperhacker4382 CMake is not fun

  • @CoolestPossibleName
    @CoolestPossibleNameАй бұрын

    My takeaway: Learn everything!

  • @CyberDork34

    @CyberDork34

    Ай бұрын

    Except C++ apparently, despite being more relevant and more widely used than either Rust or Zig

  • @Darkyx94

    @Darkyx94

    Ай бұрын

    Rule 1 of low level programming, we don't talk about C++, Rule 2 of low level programming, if we're trying to find example, pretend everything was written in C

  • @mgord9518

    @mgord9518

    Ай бұрын

    ​@@CyberDork34Because learning C++ means becoming a C++ programmer

  • @189Blake

    @189Blake

    Ай бұрын

    ​@@CyberDork34learning c++ would take the same time than the other 3 combined 😅

  • @krtirtho
    @krtirthoАй бұрын

    Zig is the best C toolchain ever

  • @mgord9518

    @mgord9518

    Ай бұрын

    Which is pretty amazing considering that C is 50 years old and hasn't figured this shit out No reason I should have to install gigabytes of libraries for other architectures when I just want to link to them

  • @IamPyu-v

    @IamPyu-v

    19 күн бұрын

    Yea, it's amazing.

  • @matteo.veraldi

    @matteo.veraldi

    12 күн бұрын

    Is it? I am genuinely asking

  • @ZenoDovahkiin

    @ZenoDovahkiin

    10 күн бұрын

    @@matteo.veraldi You can use Zig as a replacement for make/cmake, etc, configured in Zig. Last I was aware, it was also getting a built-in package manager, so you basically get another dub/cargo/alire, but this one works not only for Zig, the language it's associated with, but also C. That's the idea at least.

  • @maxturgeon89
    @maxturgeon89Ай бұрын

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

  • @wiktorwektor123

    @wiktorwektor123

    24 күн бұрын

    Pretty much. Zig is not much different in that regard, but I still prefer to use Zig instead of C.

  • @nikkehtine

    @nikkehtine

    20 күн бұрын

    C: pros: it does exactly what you tell it to do cons: it does exactly what you tell it to do

  • @samdavepollard
    @samdavepollard16 күн бұрын

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

  • @mouradchelik4375
    @mouradchelik4375Ай бұрын

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

  • @negaopiroca2766

    @negaopiroca2766

    9 күн бұрын

    Word

  • @udderhippo

    @udderhippo

    9 күн бұрын

    A pleasant one

  • @ImmiXIncredible
    @ImmiXIncredibleАй бұрын

    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

  • @TheSulross

    @TheSulross

    28 күн бұрын

    still not ready to embrace Zig myself - going to sit tight and wait for it's successor language Zag

  • @immige9216

    @immige9216

    28 күн бұрын

    @TheSulross better wait for zog then, it fixes all the stuff zag got wrong

  • @TheSulross

    @TheSulross

    28 күн бұрын

    @@immige9216 I confess that my real fantasy for Zag is to be a subset language of Zig that can be a Turbo Pascal like programming IDE that can run directly on 8bit and 16bit retro computers - or modern retro themed computers like the Agon Lite or the Commander X16. To do retro games development, of course. But where would be the fun in that if it didn't run directly on the target computer. 🙂

  • @JoseColonTV

    @JoseColonTV

    26 күн бұрын

    He said "defer macro". He has C Stockholm Syndrome. lol

  • @exnihilonihilfit6316

    @exnihilonihilfit6316

    12 күн бұрын

    I see the kids are here... goddamn time wasters

  • @jameslay6505
    @jameslay65054 күн бұрын

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

  • @pierreollivier1
    @pierreollivier1Ай бұрын

    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.

  • @mgord9518

    @mgord9518

    Ай бұрын

    I've been re-making a C project in Zig, started with a dumb 1:1 port and have slowly been implementing safety features and metaprogramming. It's pretty amazing how much more readable code becomes when you don't have to rely on 30 helper functions to extract data from packed structs like you do in C or Go

  • @pierreollivier1

    @pierreollivier1

    Ай бұрын

    @@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..

  • @pierreollivier1

    @pierreollivier1

    Ай бұрын

    @@mgord9518 I even forgot to mention how good and complete and portable the std is compared to C.

  • @jaivarsanb9194

    @jaivarsanb9194

    Ай бұрын

    hello thanks for this review of zig and how it helps you. I'm curious to know how much does the zig compiler help prevent data race related bugs due to concurrency & also identifying or prevention of memory leaks. If possible please help it by comparison with rust/golang thanks.

  • @fluffy_tail4365

    @fluffy_tail4365

    29 күн бұрын

    also defer is so good, the video doesn´t go into detail but also it is made to substitute the goto: error pattern you would sue in C when you need deinit/deallocs. It is just C but improved for me

  • @AkitooMusic
    @AkitooMusicАй бұрын

    Zig is nice.

  • @Caesim9
    @Caesim98 күн бұрын

    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.

  • @itr00ow93
    @itr00ow93Ай бұрын

    Zig is for puppygirls, rust for catboys

  • @zokalyx

    @zokalyx

    Ай бұрын

    weird take but ok

  • @vinylSummer

    @vinylSummer

    Ай бұрын

    Greatest take of the century

  • @itr00ow93

    @itr00ow93

    Ай бұрын

    @@zokalyx arf arf

  • @howisshegameing

    @howisshegameing

    Ай бұрын

    based take actually

  • @InternetExplorer687

    @InternetExplorer687

    Ай бұрын

    most reasonable take i have heard this month

  • @hacking4arabs
    @hacking4arabsАй бұрын

    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

  • @FlanPoirot

    @FlanPoirot

    Ай бұрын

    I enjoy Zig, Rust and Odin. they're give u different opinions and perspectives on the low level coding niche :) I like them for different reasons and I personally wish all 3 get popular and embraced by the broader community

  • @echoptic775

    @echoptic775

    Ай бұрын

    What did you accomplish that you couldn't do with other languages?

  • @xaxfixho

    @xaxfixho

    Ай бұрын

    You should try frenti 😉

  • @andrewdunbar828

    @andrewdunbar828

    Ай бұрын

    @@FlanPoirot With you on this!

  • @Adiee5Priv

    @Adiee5Priv

    Ай бұрын

    Endeavour os?

  • @user-fi6qx8bw6k
    @user-fi6qx8bw6kАй бұрын

    as a beginner to programming, zig is my favourite out of all the languages i tried, i feel like i can read the standard library code and have an understanding of what its doing, unlike other low level languages where i cant comprehend anything others wrote , but the thing is , it feels like zig is dependant on C , you cant really do anything without importing a C library atleast from my prospective, also it feels like the community around it assumes everyone is coming from using C

  • @shangsty

    @shangsty

    Ай бұрын

    it seems c and c++ are what everybody learns on i’m in prog foundations and it’s c++ at my community college

  • @mgord9518

    @mgord9518

    Ай бұрын

    Depends on what you're doing. On a language-level, Zig is absolutely NOT dependent on C. However, Zig is a young language, it lacks libraries. So you have to either roll stuff yourself or rely on existing C libraries if you want to do stuff not available in std

  • @PouriyaJamshidi
    @PouriyaJamshidiАй бұрын

    Nim is also a system's programming language with optional GC

  • @nathanfranck5822
    @nathanfranck5822Ай бұрын

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

  • @Leonhart_93

    @Leonhart_93

    Ай бұрын

    Yes, for that you need something with real control, instead of giving you bits and pieces always wrapped in some insanely complicated proprietary memory management system like Rust.

  • @andrewdunbar828

    @andrewdunbar828

    Ай бұрын

    Have a look at Odin. I like Zig and Odin but Odin might be even more game friendly.

  • @nathanfranck5822

    @nathanfranck5822

    Ай бұрын

    @@andrewdunbar828 Yeah, the builtin Quat, Vector and Matrix types in Odin definitely helps with ergonomics. Also the context object to pack allocators and debugging tools into. I'm sticking with zig for now, and having a good time with the killer zig features so far, though the ergonomics aren't as good as Odin

  • @heavymetalmixer91

    @heavymetalmixer91

    Ай бұрын

    Does Zig have OOP?

  • @nathanfranck5822

    @nathanfranck5822

    Ай бұрын

    @@heavymetalmixer91 You can pack data into structs and give them methods --- the best parts of OOP :) If you want interfaces and inheritance, it's not a first-class feature, you'd have to use anytypes and make some (arguably cool) comptime code to build up those concepts again, you'd get worse tooling and the community isn't generally impressed with it

  • @BrainySmurf77
    @BrainySmurf77Ай бұрын

    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.

  • @poggarzz

    @poggarzz

    Ай бұрын

    As a c/c++ enjoyer, zig is the only one I tried out of the "hot new" languages. so far, I am loving it.

  • @m4rt_
    @m4rt_Ай бұрын

    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.

  • @suvetar
    @suvetar10 күн бұрын

    I'm glad that you came back after a bit of reanalysis ... Zig is shaping up to be all sorts of nice and I really appreciate your walkthrough, definitely opened my eyes! Thanks!

  • @Lorne_at_work
    @Lorne_at_workАй бұрын

    Great video, I was just about to start my zig journey when I came across Odin. It's my first foray into low level/manual memory management and it's been really fun so far. I'd love to hear your thoughts on Odin as well.

  • @Leonhart_93
    @Leonhart_93Ай бұрын

    Zig's purpose is not a thing because "Rust is too hard", since it sounds like you are uplifting Rust to a new high. Rust is too restrictive and inherently doesn't trust the developer to write good code, which sounds more like the reason why Zig is an alternative. Zig's purpose is to be a modern C, that's it. Complete control over memory with more easily usable features like error handling and perfect inter-operability with C. And also, Zig's standard library is insanely clear and accessible. You get it out of the box in plain Zig code and it can be one hell of a tutorial in the advanced Zig features if you study the implementation of everything.

  • @nathanfranck5822

    @nathanfranck5822

    Ай бұрын

    Zig makes "memory soundness" another problem to solve eventually instead of a requirement for getting your code to run initially. Which is good if you are trying things out, and don't know exactly what you have set out to build. I can build a giant system that leaks like crazy and then solve the leak once I'm happy with the behaviour and design later.

  • @Leonhart_93

    @Leonhart_93

    Ай бұрын

    @@nathanfranck5822 Maybe you can make that argument for C, but Zig handles a lot of that with the "defer" statements, custom allocators and error handling. And even with that argument, hardcore engineers with still pick C over everything, because they like power and control, and are not afraid of using memory. But they may be somehow inclined towards Zig since it allows doing all of that.

  • @angeldude101

    @angeldude101

    Ай бұрын

    "Rust ... inherently doesn't trust the developer to write good code." Considering I don't trust myself to write good code, and barely trust others to write good code, Rust seems pretty perfect for me.

  • @arson5304

    @arson5304

    Ай бұрын

    why is it too restrictive, i've yet to be held back by chains from the language

  • @nathanfranck5822

    @nathanfranck5822

    Ай бұрын

    @@arson5304 Yeah Rust isn't bad if you just clone() everywhere, but then it runs significantly slower than JavaScript or Go for the same algorithm. Doing the easiest thing in Zig generally results in really fast single threaded code (talking small CLI apps with some hash maps, lists, iterations, from experience)

  • @minirop
    @miniropАй бұрын

    defer not only "places" the code at the end of the function, but at all exit points (if there is an early return for instance) like a destructor in C++. (and the futur defer statement in C hopefully)

  • @stighemmer
    @stighemmer13 күн бұрын

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

  • @loganhodgsn
    @loganhodgsnАй бұрын

    Thanks for the left!right idea for errors. Really helped me be able to read Zig better!

  • @Vifnis
    @VifnisАй бұрын

    "you should learn all the things" You know I'm not gonna do that, Ed.... my brain isn't big enough yet

  • @shethtejas104
    @shethtejas104Ай бұрын

    Hello and greetings from a fellow low level programmer. How are you doing? I have spent close to a decade on assembly language programming of proprietary DSPs either directly or by way of analyzing cross-compiled disassembly. I really appreciate your efforts in educating the general public about low level coding. As we know it, it seems scary and may be it is to some extent, but its amazing with lots of scope for creativity.

  • @angeloceccato
    @angeloceccatoАй бұрын

    In May, there is "the software you can love" in Milan. They'll speak about zig and system programming! I already took the ticket!

  • @ChipKeefer

    @ChipKeefer

    7 күн бұрын

    I went. It was terrific!

  • @angeloceccato

    @angeloceccato

    7 күн бұрын

    @ChipKeefer Argue please

  • @giannirosato4341
    @giannirosato4341Ай бұрын

    Another important thing to remember about Zig is that there are a lot of applications where completely memory-safe code simply isn't as important, and other concerns come first. An example I'm very familiar with is software video encoders; nearly all are written in C because the #1 concern is performance. Zig would make an ecosystem around developing one of these much more accessible, and give devs the tools they need to catch problems earlier & write code more quickly.

  • @Artoooooor
    @ArtoooooorАй бұрын

    My favourite feature is comptime. You can run piece of code at compile time, and with this you can generate more complicated arrays of data.

  • @DiThi
    @DiThiАй бұрын

    I hope you take a look at nim some day. Many of the zig features you've mentioned are also in nim, and it has many more that I would miss in zig. It's more high level than zig, but at the same time very low level when you need it to be.

  • @mitchelvalentino1569

    @mitchelvalentino1569

    Ай бұрын

    Nim’s flexibility is great. I enjoy it more than I ever expected.

  • @adriancruz2822

    @adriancruz2822

    Ай бұрын

    I did not enjoy Nim.

  • @andrewdunbar828

    @andrewdunbar828

    Ай бұрын

    I'd put Odin somewhere between Zig and Nim. Nim felt like it has less momentum and I didn't look at it as deeply as the others because of that.

  • @kickeddroid
    @kickeddroidАй бұрын

    Again with the fire videos!

  • @size_t
    @size_tАй бұрын

    I have to think about the video "Interview with Senior Rust Developer in 2023" from "Programmers are also human", where he said "They don't like 'unsafe' in my code, so just stuff it into macros"

  • @Burgo361
    @Burgo361Ай бұрын

    Zig is an interesting option I really need to try out at some point, I've seen some interviews with the creator they make some really good points.

  • @heitormbonfim
    @heitormbonfimАй бұрын

    I really love your cybersecurity stuff, it's the future, dude

  • @TheyCallMeHacked
    @TheyCallMeHackedАй бұрын

    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.

  • @wiktorwektor123

    @wiktorwektor123

    24 күн бұрын

    That true, "unsafe" Zig (which is whole language) is safer than unsafe Rust.

  • @demarcorr
    @demarcorrАй бұрын

    im dipping into zig after 15ish years of c# and java. its definitely a weird switch but im eager to expand my skillset into systems level prog, even if i dont do it professionally

  • @padmabharali1306

    @padmabharali1306

    27 күн бұрын

    Noob here , can you make computer app with zig ?

  • @demarcorr

    @demarcorr

    26 күн бұрын

    @@padmabharali1306 whats a zig?

  • @obkf-too
    @obkf-tooАй бұрын

    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.

  • @DefiantStorage1009
    @DefiantStorage1009Ай бұрын

    I think the most uniquely-zig thing is payload capture. There are also, of course, comptime/defer/undefined/slices, but the truly innovative payload-capture invention deserves the chef's kiss.

  • @andrewsharpe4764
    @andrewsharpe4764Ай бұрын

    Not a big comment guy, but I just want to say, your presentation has got so good, some of your early videos sounded fascinating but were a bit jargon heavy. Now, frankly, I watch pretty much every LLL video that comes up in my feed even if I’m never gonna use them or maybe even never gonna understand 👏 👏 👏

  • @ohdarlin692
    @ohdarlin692Ай бұрын

    As complete beginner in low level programming after high level on java and js it was really nice to program in zig, because its compiler says where I made a misstake, in C I just got error code and that's all. Also modern syntax feels refreshing and enjoyable.

  • @sieunpark2160
    @sieunpark2160Ай бұрын

    Regardless of what language is practical, they probably won't employ as much Zig programmers as C programmers for a long, long time.

  • @Alendrik
    @AlendrikАй бұрын

    quick mention to nim, optional gc, small binaries, and great interop with c code. great to look at, but struggles with a smaller community and worse documentation.

  • @priyanshu3331

    @priyanshu3331

    29 күн бұрын

    Well, there is also D language, it has a great interop with c and c++. Like Go, it's compiled. It also has an optional GC. The syntax is C like, has very good performance. Honestly I would say it's an extremely underrated language.

  • @mar.m.5236
    @mar.m.5236Ай бұрын

    Not doing dev anymore but coming from a VHDL, firmware, bootloader, kernel background and after just playing with the zigling "tutorial": this is the language I would have like to have during my low-level dev phase. It seems to make all the dangerous things quite visible and therefor controllable... I hope to see this language used more in the future (besides nim.... ;-) )

  • @keithl3789
    @keithl3789Ай бұрын

    Nice overview of zig. I never bothered to look into it before.

  • @guilherme5094
    @guilherme5094Ай бұрын

    I'm totally in love with Nim, but Zig looks great.

  • @phusicus_404
    @phusicus_404Ай бұрын

    C++ is the best

  • @Ellefsen97
    @Ellefsen9727 күн бұрын

    CompTime is also a pretty sick feature. You could have a function that creates an array with the 1 million first prime numbers and have it be computed at compile time instead of runtime

  • @jwr6796
    @jwr6796Ай бұрын

    I really like the idea of Zig, but coming from a JS and Rust background, I found it really hard to work with. Maybe it's because I'm running on Windows, but it seemed like a lot of the examples I found online required a lot of workarounds (or were simply out of date) and a lot of the docs were missing critical info to get over those roadbumps.

  • @aniketbisht2823
    @aniketbisht2823Ай бұрын

    As a C++ dev, Rust sucks but Zig comes close to what modern C++ offers you without any bullshit.

  • @heavymetalmixer91

    @heavymetalmixer91

    Ай бұрын

    In what way?

  • @dwight4k

    @dwight4k

    Ай бұрын

    @@heavymetalmixer91 I would like to know as well.

  • @Sevenhens

    @Sevenhens

    Ай бұрын

    Modern C++ is good...if you can close your eyes to the ugly ugly BS and drama and bikeshedding over implementations. FFS unordered_map and regex are still broken and will never be fixed. Runtime exceptions are the cause of a holy war that Google wages against the standards committee. 3rd party packaging and the CMake build system being a complete mess (second only to Python's mess). Tons of legacy footguns that the standards committee refuses to deprecate or atleast warn against using like vector. Networking...LOL. Despite all of that...modern C++ niceties like ranges and constexpr/consteval are genuinely cool to have in a programming language.

  • @aniketbisht2823

    @aniketbisht2823

    Ай бұрын

    @@heavymetalmixer91 C++ and Zig both have excellent compile-time computation capabilities : proc macros in Rust are a language of their own whereas in C++ you write almost the same code as you would for "runtime". C++ templates combined with constexpr make for a powerful metaprogramming system. The only thing that is lacking is a Reflection system (the proposal is on its way for standardization in C++26). Rust's macro system is tedious and an expert-only feature. For anything sophisticated, you have to reach out to them. For example: "println!" in Rust is a macro while in C++ std::print (which is more flexible) is just another function template. Rust also includes many runtime checks which you cannot get rid of in release builds, unlike the "NDEBUG" macro in C/C++. Rust is an awesome language for "application" developers who won't be writing any "low-level" code themselves and instead would use libraries for the same (which are most developers). But it is very tedious for library authors who might find the language limiting at times.

  • @aniketbisht2823

    @aniketbisht2823

    Ай бұрын

    @@heavymetalmixer91 C++ and Zig both have excellent compile-time computation capabilities : proc macros in Rust are a language of their own whereas in C++ you write almost the same code as you would for "runtime". C++ templates combined with constexpr make for a powerful metaprogramming system. The only thing that is lacking is a Reflection system (the proposal is on its way for standardization in C++26). Rust's macro system is tedious and an expert-only feature. For anything sophisticated, you have to reach out to them. For example: "println!" in Rust is a macro while in C++ std::print (which is more flexible) is just another function template. Rust also includes many runtime checks which you cannot get rid of in release builds, unlike the "NDEBUG" macro in C/C++. Rust is an awesome language for "application" developers who won't be writing any "low-level" code themselves and instead would use libraries for the same (which are most developers). But it is very tedious for library authors who might find the language tedious and limiting at times.

  • @manofacertainrage856
    @manofacertainrage856Ай бұрын

    Been doing this a while - the only thing I'd automatically start in C is not a project, but a class of actual computer science students - for two reasons: 1) to later appreciate every other language and what they bring to the table; and 2) to have the beginnings of an understanding of how the machine works and a basis to read kernel code.

  • @CaptainNinjaKid
    @CaptainNinjaKidАй бұрын

    I'd love to see more zig content, maybe a video comparing zig to cmake or premake for building large c(++) projects

  • @GearsDatapacks
    @GearsDatapacksАй бұрын

    I really like the concept of comptime in zig. It seems really powerful

  • @darkfllame
    @darkfllameАй бұрын

    it really depends on what domains you want to work on: embedded systems: zig games: zig webdev: zig os: zig c: zig networking: zig automation: zig

  • @mgord9518

    @mgord9518

    Ай бұрын

    Also: Build system: zig C++ compiler: zig JS runtime: zig Just use the right tool for the right job

  • @RiwenX

    @RiwenX

    Ай бұрын

    Embedded zig? I mean, have you been doing any embedded stuff? After years, Rust has finally reached the point where it's usable for embedded (well, for MCUs whose vendor supports it officially, ot there is good community support). I simply cannot see Zig being a productive language for embedded for years to come; that is, if vendors/community pick it up. Which is doubtful at best.

  • @perfumedeath6042

    @perfumedeath6042

    Ай бұрын

    Nice 😂

  • @adnanalshami3751

    @adnanalshami3751

    Ай бұрын

    @@mgord9518 the right zig for the right job 😁

  • @31redorange08

    @31redorange08

    Ай бұрын

    You put zig everywhere.

  • @MeriaDuck
    @MeriaDuckАй бұрын

    As a Java programmer I'm mot a fan of forced exception handling. I'd rather have the choice to not do it, or not do it right then and there. Java has evolved and the standard api is also moving away from checked exceptions in lots of cases. Having it in the signature of the function like zig has looks quite neat. Will surely look into it.

  • @jongeduard

    @jongeduard

    5 күн бұрын

    Java checked exceptions are indeed not liked by many, and in C# they copied a majority of things from Java, but checked exceptions where never implemented. But having error state represented by in functions in proper ways instead definitely is really powerful. The old try catch exception system is basically a difficult to overcome legacy burden. I believe no new languages are to be expected designed with it anymore. The actual important thing which I believe happened is functional programming becoming more main stream. Rust is obviously one of the best examples, but also more imperative languages like Go and Zig have been inspired by it. Older examples are OCaml and F#, of which the first one was a major influence on Rust. But I expect other functional languages also do it, especially pure functional languages.

  • @jvillasante
    @jvillasanteАй бұрын

    I mean, when talking about system languages saying that we are not going to talk about C++ in here is like saying "let's talk about GPUs, but not you NVIDIA" :)

  • @zackyezek3760

    @zackyezek3760

    Ай бұрын

    Yeah, let’s not talk about c++ when it’s BEEN the “higher level C replacement” for about 40 years now & is the only language anywhere close to C in terms of widespread usage for systems (or even just compiled) code. Zig seems to be an attempt to merely replace C rather than Rust, which is clearly going after C++ too. Being a new, de facto rewrite of C rather than trying to replace both wholesale probably is the better design & strategy. Especially because linker ABI compatibility with C lets you become a transparent drop in replacement, ironically the SAME THING K&R C did to FORTRAN by making it trivially simple to link Fortran libs into C programs.

  • @TheSulross

    @TheSulross

    28 күн бұрын

    yeah, the waves of weird anti C++ bias just tsunami rolled me

  • @uzoochogu

    @uzoochogu

    28 күн бұрын

    @@TheSulross Yes, it is almost like a trendy thing to just hate C++. Very cliche. Yet all their fancy tools are built with C++.

  • @dainess2919

    @dainess2919

    19 күн бұрын

    When C++ devs die they don't leave a corpse, it goes on a puff of black smoke straight to hell

  • @billyjoejimbob75
    @billyjoejimbob75Ай бұрын

    Zig? For great justice, obviously.

  • @Rtzoor
    @RtzoorКүн бұрын

    beyond the eloquent and coherent explanations, above all i most liked your comment that we should all be learning everything, becuase learning makes us not only better programmers, but also better people. i whole heartedly agree.

  • @KayleLang
    @KayleLangАй бұрын

    I like Zig a lot. While trying to understand computers at the low level, it's been more fun exploring it with Zig. Rust has too many abstractions, assembly has too little abstractions, C is close but has a lot of warts. Zig feels just right.

  • @seasong7655
    @seasong7655Ай бұрын

    He forgot to mention Nim as a language that uses no garbage collection.

  • @tenv
    @tenv29 күн бұрын

    It's one thing for Zig to improve and modernize C whilst still keeping the language small and lean, that would make it a great lang on its own. But then comptime... honestly its the best approach to generics I've seen, and it happened by accident! Best lang 10/10

  • @wmpowell8
    @wmpowell8Ай бұрын

    I haven't tried Zig before, but I have tried Rust and wrangling with the borrow checker is SO FRUSTRATING!!! Zig, which doesn't have a borrow checker, seems like it lowers the barrier to entry for a modern C alternative, making it easy to write fast but safe code.

  • @VeggieTanuki
    @VeggieTanukiАй бұрын

    The zig compiler is a god-send for generating statically-linked binaries and cross-compilation.

  • @juniordevmedia
    @juniordevmediaАй бұрын

    One of the few sublime text users that are left, Respect!

  • @abbatrombonelol
    @abbatrombonelolАй бұрын

    Not gonna mention holy C or C+ :p

  • @blarghblargh

    @blarghblargh

    Ай бұрын

    Why would he

  • @shangsty

    @shangsty

    Ай бұрын

    he must not be divine enough

  • @silloo2072

    @silloo2072

    Ай бұрын

    What is c+

  • @abbatrombonelol

    @abbatrombonelol

    Ай бұрын

    @silloo2072 It is a shell and compilted language used by temple OS, read the wiki its an insane story. Short version is "God spoke to him" and he made a Christian OS where each peocess comes off adam, C+ is called holy C as it looks like a cross, etc.

  • @silloo2072

    @silloo2072

    Ай бұрын

    @@abbatrombonelol thanks

  • @mrlithium69
    @mrlithium69Ай бұрын

    can you put zig in the title please ? not everyone can see the thumbnail

  • @kesslerdupont6023

    @kesslerdupont6023

    Ай бұрын

    also for searching "zig" on YT

  • @awesomedavid2012
    @awesomedavid2012Ай бұрын

    I hate to be one of these people, but you should check out Odin if you haven't. It seemingly fits in a similar place as Zig, but with a completely different mindset. I like that in Odin, you have access to allocators and calling conventions, but they aren't forced on you; you can just call new and use the default allocator.

  • @nyx211
    @nyx211Ай бұрын

    Is it just me or does it seem like Zig's syntax is weird for no reason? At 6:24 he mentions how you can think of running the openFile() function as going left or right. When you go left, the success result is put into f, but when you go right you catch the error value. So then why is the return type std.fs.File.OpenError!std.fs.File. Why is the right on the left and the left on the right?

  • @CallousCoder
    @CallousCoderАй бұрын

    I adore it and I see it as definite language for new “C” projects. And definitely great no awesome for embedded. And C developers will build so much faster in Zig than Rust.

  • @pseudoc
    @pseudocАй бұрын

    The best idea of zig for me is the build system, unlike CMake nor Meson you don't to learn a new 'language' for it, you can apply complex control flows in your 'build.zig'. To me, it feels like Terry David's HolyC, it's next-level design.

  • @MaxHaydenChiz
    @MaxHaydenChiz29 күн бұрын

    The way you talked about garbage collection vs malloc has the potential to be misunderstood or taken out of context. I think you mean that malloc/free are "deterministic" in the sense that you can point to a specific given line of code where the allocation and de-allocation take place. (Though, with smart pointers, deallocation can easily become non-deterministic, even this sense.) But usually people use "deterministic" in a more restrictive way. Normally, you'd say that malloc/free are non-deterministic in that they can take an unbounded amount of time. In a long-running application, you could end up with fragmented memory, and all kinds of other crazy things could happen when you call those functions. So they aren't real time safe and shouldn't be called from code that needs to make real-time guarantees. As a general rule, if you need deterministic memory usage, you have to allocate everything statically, or at least right at the start when the system turns on and then never again. In such systems, you don't use dynamic memory. With that and a few additional restrictions, you can calculate exactly how much stack space and other resources you need to handle the worst case scenario. However, there are a handful of situations where you do need to manage memory dynamically in a real-time system. As far as I am aware, the only known general purpose techniques for doing this wait-free involve garbage collection algorithms. (The same goes for lock-free approaches.) 5 years ago, I'd have said that these use cases were so obscure that they weren't worth mentioning, but so many consumer devices now have real-time components and mixed criticality workloads that this isn't a specialized topic anymore. We have cost effective multicore embedded SoCs, and even extremely cheap single core processors can get by with the "speed" of interpreted Python. Hardware features like transactional memory support are becoming more broadly available too. So, I think that we are going to start to see real-time garbage collection algorithms out in the wild before too long. Even if people aren't using specialized real-time algorithms that need them. If you need the real-time code on a camera or a drone to interface with a system to communicate with people's phones over bluetooth, that's going to force the issue, especially if devs want to use normal open source software libraries for the non-essential portions of their code even if those libraries weren't written with real-time systems in mind. I haven't found a "good" set of tools that supports this type of development, but maybe Zig will be the language to do it given how explicit it is about passing allocators around.

  • @GoWithAndy-cp8tz
    @GoWithAndy-cp8tzАй бұрын

    For Linux enthusiasts, C is often preferred over Rust due to its simplicity and speed. In C, one can directly use functions like dlopen() and dlsym() to dynamically import binary libraries and call existing functions without the need to recompile the code each time. In contrast, Rust requires compiling all libraries from source each time, which is necessary to satisfy its borrow checker requirements. This aspect can be frustrating for some users. Cheers! P.S> I pick Go despite I like Zig and Rust but I decided to learn them one by one.

  • @HaydenGray
    @HaydenGrayАй бұрын

    As much as I wanted to like Zig and use it as a C replacement I just couldn't. I found that it added "too much" to the language and had overly verbose syntax (I would rather just use Rust at that point). When I compared it to Odin, I found that Odin was just simpler overall while still giving the benefits that Zig has (no hidden allocations/manual allocators, range-based iteration, sized arrays, better error handling, etc). Zig definitely has a lot more momentum behind it now with the release of tools like Bun but I would really like the ecosystem with the better tooling (especially the LSP), MUCH simpler syntax, builtin linear algebra, and a style that feels like what C++ *should* have been to take off

  • @ovi1326

    @ovi1326

    Ай бұрын

    Actually there are some great podcast episodes between Andrew Kelley and G gingerBill where they both explain their rationales for doing things the way they do them. I like zig way more for comptime stuff, more explicitness in both the stdlib and the lang itself and most importantly @cImport

  • @stretch8390

    @stretch8390

    Ай бұрын

    Can you elaborate on the simpler syntax? I found it difficult because I am a beginner who never had to consider things like memory and static types before (lol), but I personally didn't find the syntax difficult.

  • @HaydenGray

    @HaydenGray

    Ай бұрын

    @@stretch8390 I wouldn't call it "difficult" but more just... odd (i.e. the "for" loop syntax). There wasn't a single thing that really killed it for me, it was more just death by a thousand paper cuts that made it kind of unpleasant to write (having to do error handling for writing to stdout without using the debug print for example). I'm sure things will change as the language evolves but having to do stuff like: ` try std.io.getStdErr().writer().print("Hello {s}! ", .{"foo"});` (which also requires the function to be marked with "!" which is quite a leaky abstraction) vs `fmt.eprintfln("Hello {}!", "foo")` to log to stderr without using the debug functions is just unpleasant to me. At that point, I think we cross the "simple language" barrier and I would rather just use Rust at that point

  • @bruno-brant
    @bruno-brant6 күн бұрын

    "I love that it makes me check every error type" says no one who ever knew Java and checked exceptions.

  • @filko3578
    @filko3578Ай бұрын

    Hey, I'm thinking about learning C to build my own data structures and algorithms, plus get into some networking (like TCP and chat apps), and maybe touch on graphics with OpenGL or something like that. I want to grasp some fundamental skills that you don't usually see in JavaScript or PHP projects. Also, I’m curious about how rendering works and want to get more into algorithms. Do you think Zig might be a better choice for diving into this stuff instead of C?

  • @atijohn8135

    @atijohn8135

    Ай бұрын

    General algorithms are more or less the same in any language. Outside of Zig's more readable memory deallocation, they'll be the same in C and Zig (although do note that C doesn't have any data structures in its library, so you need to write your stacks, queues, heaps, linked lists, trees and graphs all by yourself before writing an algorithm that requires them, while Zig has a bunch of standard containers for you to use. But since you're building your own data structures anyway, that shouldn't be an issue for you) Non-generic data structures are very simple to implement in C, but implementing generic data structures requires you to perform macro hacks or use the ugly and impossible to optimize void pointers. Zig is way better in that regard, since it has native support for generics. OpenGL programming is the same in any language. Zig might once again help you with memory deallocation, but in OpenGL you typically do not want to allocate memory while rendering, only at the start of your program, and then deallocate it at the end, at which point you don't even need to do that, since it'll get freed up automatically once your program exits. Networking itself is more or less the same in both languages; however C doesn't have anything network-related in its standard library, meaning that you'll also need to learn one of C's thousands of build systems, which can be troublesome; in contrast Zig not only has networking support in its standard library, but it also has a significantly better build system than any of the build systems available for C.

  • @the_original_dude
    @the_original_dude9 күн бұрын

    At first I really liked Zig, but later came to realize that I much more prefer C. C is so much more simple, which means less bugs in the compiler and easier to understand. You can hate headers, but it generally means less compilation, and you don't need to use a browser to look at the interface and documentation of a module. If only more people used C without libc.

  • @kenneth_romero
    @kenneth_romeroАй бұрын

    can you change code theme when presenting? that red text is hard to see on the background color. at least for me since i'm a bit colorblind

  • @BachenBenno99
    @BachenBenno99Ай бұрын

    Hold on, why are we not talking about C++? Did I miss something?

  • @31redorange08

    @31redorange08

    Ай бұрын

    Yes. Rule #1: We don't talk about C++.

  • @BachenBenno99

    @BachenBenno99

    Ай бұрын

    @@31redorange08 ok, but why?

  • @1zui

    @1zui

    9 күн бұрын

    Probably because with C++, there is no reason to use C at all.

  • @Sam-hu3xt
    @Sam-hu3xt22 сағат бұрын

    Everything claimed by newer languages can be achieved with C + good coding standard + static and dynamic analysis. It is just a matter of got experienced. Also people tend to forget about the tooling around the language. For example, C compilers are older that most of us, so they are tested in many scenarios and conditions. Nowadays, Zig, Rust, etc, are good languages to learn from them and even to use in some production environments far from the autopilot of your next plane to Honolulu. (Just an opinion)

  • @rzyr
    @rzyrАй бұрын

    I thought it was like this: zig is the new c, rust is the new c++, go is the new java. It's not a perfect 1:1 but it's a iseful simplification imo

  • @Zeocins
    @ZeocinsАй бұрын

    V Lang can also be run without garbage collection (and its autofree system is very interesting). So, not only C, Zig and Rust out there for that niche!

  • @klirmio21
    @klirmio21Ай бұрын

    I got subbed to you due to your youtube shorts, where you jebait as a cute girl video then say "i don't care, here is how you do that in C...." that was hella funny, I definitely think you should keep making them occasionally its off the topic, just wanted to give feedback that its working

  • @yihan4835
    @yihan4835Ай бұрын

    The C++ answer to all of the features mentioned here: Allocator: fully supported by all stl containers Defer: RAII (destructor) Error as value: C++ std::expect + setting compiler flag for checking switch case missing case Out of bounds check: use .at to access containers, or wrap raw buffer into span and then use .at

  • @presentfactory

    @presentfactory

    Ай бұрын

    Except C++ is a much more messy impossibly complex language with many more ways to mess all that up. Also sure containers have bounds checking, but raw pointers do not whereas Zig slices despite being primitives are bounds checked in all cases. Not to mention other debug checks done for primitive types like overflow checks which C/C++ do not do unless you run with something like UBSan which is more just tacked on to make up for the lack of these things in these languages. People have solutions to this stuff in C/C++ though, but tldr is it's just inelegant and often errorprone. Zig is a lesson in hindsight, taking inspiration from things C/C++ have struggled with and building it all into the language itself.

  • @yihan4835

    @yihan4835

    Ай бұрын

    @@presentfactory if C++ is really that impossible, you wouldn't see it being used at all. Yet, it's used in a lot of places.

  • @yihan4835

    @yihan4835

    Ай бұрын

    @@presentfactory Also, what if I don't want bounds checking? It's slower. In C++, you only pay for what you use. UB allows compiler to optimize the program in a much better way.

  • @presentfactory

    @presentfactory

    Ай бұрын

    @@yihan4835 It's used because it's old. C++ is like 30 years old and C is like 50, this has given them a lot of code built up in them over the years and tooling, libraries etc. This means they continue to be needed to maintain such codebases and work with such libraries. Newer projects though are slowing moving away from them. I still use C++ at my job because it's a C++ codebase and has been for the past 20 years, that is not changing anytime soon but all my personal projects are in Zig. Also you are confusing what Zig bounds checks are. Zig bounds checks are not always emitted, they are a debug check only present in "safe" builds like Debug or ReleaseSafe in other modes reading/writing out of bounds is UB. Zig is as fast if not faster than C/C++ because it has all the same philosophies in this regard around performance. If you actually needed to check if an element is in bounds at runtime you'd check the index against the slice's length or container's size manually, same as C++.

  • @owenwexler7214
    @owenwexler7214Ай бұрын

    Zig exists to write Bun, obv

  • @notuxnobux
    @notuxnobux25 күн бұрын

    5:17 the main thing about this isn't even just that, but also that it runs at every possible end of the scope/function. If you have multiple return statements (because you handle multiple possible errors from different functions) then the defer will return at every possible return so you will only have to write the cleanup in one place and it will always run, you wont miss it in some cases. The way to do this is in C is to write a goto to the end of the function that does the cleanup and checks that the values aren't NULL. This defer is basically that goto but cleaner and directly after the allocation as you say so you can immediately see if its done or not. It's basically like c++ RAII, except you dont have to write a class with a destructor to do it for every case (or write a hacky macro to do it). Zig also has errdefer to do it only when an error has happened for example if you want to cleanup everything that has been done when an error has occured but if it succeeds you want to return that data instead in its complete form.

  • @InvaderTakko
    @InvaderTakkoАй бұрын

    Would be cool if you checked out Odin as well. Its quite similar to Zig but in my opinion more ergonomic/readable and at least on the language side more mature. Doesnt have as much traction and a smaller community tho.

  • @andrewdunbar828

    @andrewdunbar828

    Ай бұрын

    Odin is a fair bit more C-like than Zig even though it is also fairly Pascal-like.

  • @eduardabramovich1216

    @eduardabramovich1216

    Ай бұрын

    @@andrewdunbar828 Yes sir, Zig is simple, but Odin is more simple.

  • @brainstormsurge154
    @brainstormsurge154Ай бұрын

    I think one person said it best that if you're tempted to do unsafe Rust code then that's where Zig should come in because it's built better for that stuff.

  • @aeiou3701
    @aeiou3701Ай бұрын

    seeing people say whatever about c++ most of the time makes me think whats wrong with my car cause i like it

  • @NeuwDk
    @NeuwDkАй бұрын

    I'm genuinely curiously, why won't you even get into C++? As someone who learned C then Rust and is now learning C++ - I don't understand all the hate. Subjectively, I don't think it is that bad. Sure you can shoot yourself in the foot, but that's not easier than in C. As I'm doing scientific computing, I find C++ is often more flexible and adaptable for my use cases. I don't have enough experience with Zig to have any opinion on it except it looks cool, but not ready for use yet.

  • @kutlokenosi3116
    @kutlokenosi3116Ай бұрын

    you can just say like "OPEN" *explosions and thunder in the background as the program crashes*

  • @skejeton
    @skejeton20 күн бұрын

    The main strength in Zig is the comptime, it's also it's main weakness - since any code can execute in a comptime function, this any code can take as much time to execute as it needs, for this reason, often times the LSP simply gives up, and essentially renders itself useless. Another is the thing with lazy error reporting, it's really, really annoying during development time. I want to see my errors the moment I make them, not only when I call the function.

  • @ErikBongers
    @ErikBongersАй бұрын

    If you're going to "try Zig, C and Rust", I think there's a good chance you'll stick with Zig, because C will constantly crash and Rust will be a constant fight with the borrow checker. Having said that, Rust is still compelling because of it's memory safety.

  • @holyknighthodrick5223
    @holyknighthodrick5223Ай бұрын

    I feel like you could just disable the GO garbage collector if you really needed, not sure why you would use zig instead of go

  • @gnorts_mr_alien
    @gnorts_mr_alienАй бұрын

    bun is written is zig and it looks like bun is here to stay so that is an anchor of zig in the ecosystem.

  • @n0xx295
    @n0xx295Ай бұрын

    You didn't even mention comptime. That feature by itself makes Zig almost as safe as Rust without having to deal the the cumbersome borrow checker.

Келесі