Zig 0.11

253 points by tauoverpi 1 year ago | 185 comments
  • pid-1 1 year ago
    > Backed by the Zig Software Foundation, the project is financially sustainable. These core team members are paid for their time: (lists five people)

    That's quite impressive. For comparison, Python had 2 full time paid devs in 2019 (not sure about now).

    • samwillis 1 year ago
      I suspect some of this comes down to how larger donations are made. For Python they have often had people working at companies donating time on their employers books to the development of it.

      GVR for example works for Microsoft and has worked at Dropbox and other places, but spends much of his time on Python. So he isn't listed as an employee of the foundation, but at times is full time.

      If a company donates employee time they have more influence on the project than donating cash to pay for development.

      The fact that Zig had the cash donation to do it this way is brilliant, and probably a better model.

      • kristoff_it 1 year ago
        We're also pretty efficient, more than 90% of the donated money is used to pay developers (the rest goes to administrative costs, CI infrastructure, etc).
        • the_mitsuhiko 1 year ago
          More important than the number is that the foundation actually pays the core developers. Python suffers from having almost exclusively volunteer work and those volunteers often are not interested in solving the problems of the foundation or community (eg: packaging etc.).

          The most the PSF could do is “bolt on” a developer to solve packaging in yet another non embraced and supported way.

          • 1 year ago
          • captainhorst 1 year ago
            Their biggest release in terms of issues closed: https://github.com/ziglang/zig/milestones?state=closed 1012 in less than 8 months. What an amazing feat.
            • modernerd 1 year ago
              As a contributor to 0.11 it was very impressive how quickly my (small) PR was triaged, reviewed and merged.

              The Zig team are doing great work and they care about the contributor experience.

            • yla92 1 year ago
              The Async/Await didn't make it into this release[0] but hopefully by the next one!

              [0]: https://ziglang.org/news/0.11.0-postponed-again/

              • ngrilly 1 year ago
                Yes. Ideally, the release notes should have mentioned this in the roadmap section at the end :)
              • tarcio 1 year ago
                What are the use cases for zig? The website says general purpose and tool chain but people who have used it, what it excels at?
                • jedisct1 1 year ago
                  For WebAssembly, Zig really excels.

                  It's very memory efficient, everything compiles of the box to WebAssembly (freestanding or wasi), the resulting code is compact and fast, and it can take advantage of the latest WebAssembly extensions (threads, SIMD, ...) without any code changes. If you are using a webassembly-powered cloud service and not using Zig to write your functions, you are wasting money. Seriously.

                  Unsurprisingly, this is the most popular language to write games running on WebAssembly: https://wasm4.org/blog/jam-2-results/

                  Beyond the language, Zig is also a toolchain to compile C code to WebAssembly. When targeting WASI, it will seamlessly optimize the C library for size, performance or runtime features. I used it to port OpenSSL, BoringSSL and ffmpeg to WebAssembly. Works well.

                  Also, Zig can generate WebAssembly libraries that can then be included in other languages that support WebAssembly. Most of my Rust crates for WebAssembly are now actually written in Zig.

                  It's also supported by Extism, so can be used to easily write safe plugins for applications written in other languages.

                  • tempZigInterest 1 year ago
                    If you don't mind, since you have experience targetting WASM with both Rust & Zig, what advantages does Zig have over Rust in this particular use case?

                    Are the memory safety guarantees that Rust offers over Zig not as important or critical when targeting WASM?

                    I've been interested in checking out Zig for a while now.

                    • djur 1 year ago
                      Your link is really interesting, but it shows that Zig was the most popular language for writing games for a WebAssembly-based fantasy console with constrained resources, not that it's the most popular language for WebAssembly-based games overall.
                    • armchairhacker 1 year ago
                      My understanding is that Zig has all of the power and modernity of Rust, without the strictness and borrow checker. Unlike Rust, it also has powerful compile-time evaluation and custom allocators, and probably more improvements I'm not familiar with (in Rust you can effectively emulate custom allocators, but you have to rewrite every allocating structure to use them; or you can use nightly, but most third-party library and even some standard-library types don't support them).

                      I also heard someone say "Zig is to C what Rust is to C++". Which I interpret as, it's another maximum-performance modern language, but smaller than Rust; "smaller" meaning that it has less safety and also abstraction (no encapsulation [1]), but less requirements and complexity.

                      Particularly with games, many devs want to build a working prototype really fast and then iterate fast. They don't want to deal with the borrow checker especially if their code has a lot of complex lifetime rules (and the borrow checker is a real issue; it caused evanw to switch esbuild to Go [1]). In small scripts with niche uses, safety and architecture are a waste of effort, the script just has to be done and work (and the latter is only partly necessary, because the script may not even be fed enough inputs to cover edge cases). Plus, there are plenty of projects where custom allocation is especially important, and having every type support custom allocation is a big help vs. having to rewrite every type yourself or use `no_std` variants.

                      [1] https://github.com/ziglang/zig/issues/2974

                      [2] https://github.com/evanw/esbuild/issues/189#issuecomment-647...

                      • Arnavion 1 year ago
                        >My understanding is that Zig has all of the power and modernity of Rust, without the strictness and borrow checker.

                        This is an oxymoron :) The strictness and borrow checker are part of the power and modernity of Rust.

                        But even apart from that, Rust has automatic value-based destructors (destructor follows the value as it's moved across scopes and is only called in the final scope), whereas Zig only has scope-based destructors (defer) and you need to remember to write them and ensure they're called exactly once per value. Rust has properly composable Option/Result monads, whereas Zig has special-cased ! and ? which don't compose (no Option of Option or Result of Result) but do benefit from nice built-in syntax due to their special-cased-ness. Rust has typed errors whereas Zig only has integers, though again that allows Zig to have much simpler syntax for defining arbitary error sets which would require defining a combinatorial explosion of enums in Rust.

                        Of course from Zig's point-of-view these are features, not deficiences, which is completely understandable given what kind of language it wants to be. And the other advantages you listed like comptime (Rust's const-eval is very constrained and has been WIP for ages) and custom allocator support from day 1 (the way Rust is bolting it on will make most existing code unusable with custom allocators, including parts of Rust's own standard library) are indeed good advantages. Zig also has very nice syntax unification - generic types are type constructor functions fn(type) -> type, modules are structs, etc.

                        I hope that one day we'll have a language that combines the best of Rust's strictness and Zig's comptime and syntax.

                        • anonymoushn 1 year ago
                          > Rust has properly composable Option/Result monads, whereas Zig has special-cased ! and ? which don't compose (no Option of Option or Result of Result)

                          ?!!??u32 is a perfectly cromulent type in Zig.

                          • Ygg2 1 year ago
                            > Rust's const-eval is very constrained and has been WIP for ages

                            Having strong backwards compatibility does that to the language, alternative is arguably worse (see Python 2 vs 3).

                          • lenkite 1 year ago
                            Also none of the common knowledge around traditional data-structures and algorithms work with Rust anyways. One needs to dance like a ballerina with their hands and feet tied.
                            • pkulak 1 year ago
                              “Linked lists are hard” is not “none of the common knowledge around traditional data-structures and algorithms work”.
                            • binary132 1 year ago
                              I think Rust and Zig are very different in principals and shouldn’t really be compared. It’s almost like comparing C and Ada.
                            • Cloudef 1 year ago
                              As someone who used C as main language, I've switched to zig. It's the only language that tries to be "better C", and not another C++. Comptime being like Nim where it's not entirely own language is also plus. I'd say it excels at general purpose system programming, and especially if you need to work with memory in detailed way (rust makes this very annoying and hard).
                              • DeathArrow 1 year ago
                                What advantages does Zig have over C?
                                • lionkor 1 year ago
                                  - comptime, so writing compile time evaluating code, without introducing its own meta language like macros or templates.

                                  - very solid build system (the build config file(s) are written in zig so you dont have to learn another language for the build system (looking at you, makefile)) that has crosscompilation builtin (with one compiler flag)

                                  - language level errors, like, errors as first class citizens. forces you to handle errors, but without much mental or syntactic overhead (you can re-throw them with `try myfunction()`), also results in a unified interface

                                  - no implicit conversions

                                  - looks high-level (modern sytnax that is easy(ish) to parse) but as low level (or lower) than C, no abstractions that hide details you need to know about when programming (similar to C)

                                  - C interop, so you can just add zig source files to a C project and compile it all with the zig toolchain. Zig can also parse c headers and source files and convert them, so you can include c headers and just start calling functions from there. For example, using SDL is as simple as pointing the toolchain to the SDL headers and .so file, and the sdl headers will be translated to zig on the fly so you can start with SDL.SDL_CreateWindow right away.

                                  • GuestHNUser 1 year ago
                                    Just to name one: compile time code execution. It eliminates the need for a separate macro language and provides Zig zero cost generic types.

                                    Not to mention memory leak detection, crazy fast compilation times, slices and a built in C compiler so your code can seamlessly integrate with an existing C code base (seriously no wrapper needed).

                                    Zig is really really awesome. The only thing holding it back from mass adoption right now is that it's not finished yet, and that shows in the minimal documentation. That said, if you're comfortable tinkering, it's completely capable of production uses (and is already used in production in various companies).

                                    • packetlost 1 year ago
                                      Namespaces.

                                      Real enums, modules, etc.

                                      A compile-time execution system (effectively replaces the preprocessor/macro system).

                                      Syntax that is easier to `grep -r` for without complex regex.

                                      Tests are a first-class citizen.

                                      Safer type system.

                                      Really, just a bunch of things that should've been added to C 20 years ago.

                                      • kristoff_it 1 year ago
                                      • iraqmtpizza 1 year ago
                                        I thought Go tried to be better C
                                        • pjmlp 1 year ago
                                          It kind of is, for anyone without bias against languages that have a GC.

                                          However they could at least support some kind of enumerations, one of the things they definitly aren't a better C.

                                          • binary132 1 year ago
                                            Go is about as much like C as Java is.
                                            • flohofwoe 1 year ago
                                              Why should there only be one "better C"? Go has a very different philosophy than Zig, but both can be considered a "better C".
                                          • cztomsik 1 year ago
                                            1. It's typically at least as fast as C, unlike C++/Rust

                                            2. You can do type introspection (and switching) during compile-time, and it's not just some stupid TokenStream transformer, you really have type information available, you can do if/else on the presence of methods, etc.

                                            3. There are no generics, but your functions can accept anytype, which is still type-safe. See https://github.com/ziglang/zig/blob/9c05810be60756e07bd7fee0... and note the return type is "computed" from the type of the input.

                                            4. Types are first-class values (during comptime), so any function can take or return a new type, this is how you get generic types, without (syntax/checking) support for generics.

                                            5. You can easily call anything which does not allocate in these comptime blocks.

                                            6. There's @compileError which you can use for custom type assertions -> therefore, you have programmable type-system.

                                            7. It's super-easy to call C from Zig.

                                            8. This is subjective: You don't feel bad about using pointers. Linked data structures are fine.

                                            • pjmlp 1 year ago
                                              > 1. It's typically at least as fast as C, unlike C++/Rust

                                              The typical urban myth that never comes with profiler proofs.

                                              • flohofwoe 1 year ago
                                                TBF, Zig with the LLVM backend may be faster than C or C++ compiled with Clang out of the box just because Zig uses more fine-tuned default compilation options. That's true even for C or C++ code compiled with 'zig cc'.

                                                But apart from that the performance should be pretty much identical, after all it's LLVM that does the heavy lifting.

                                                • cztomsik 1 year ago
                                                  I don't need to prove you anything. Go and give it a try yourself.
                                              • pjmlp 1 year ago
                                                Being Modula-2 like (in safety), with a syntax that is more appealing to C minded folks, with nice compile time execution support.
                                                • ksec 1 year ago
                                                  I think this is one of the best short description of Zig.
                                                • skavi 1 year ago
                                                  A fancy new database is written in Zig: https://tigerbeetle.com/
                                                  • johnnypangs 1 year ago
                                                    Bun, a JavaScript runtime (uses WebKit as an engine I believe) is written in Zig. They seem to be doing alright:

                                                    https://bun.sh/

                                                    • BigJ1211 1 year ago
                                                      It uses JavaScriptCore, which was written for Safari. It's supposedly faster than V8, but harder to work with.
                                                    • tauoverpi 1 year ago
                                                      A game engine https://machengine.org is being written in zig, there's also https://microzig.tech as zig is well suited to embedded development.
                                                      • bsder 1 year ago
                                                        Zig has a decent chance of being an actual embedded device (ie. no operating system) programming language.

                                                        In my opinion, Zig seems likely to grow the necessary bits to be good at embedded while Rust is unlikely to figure out how to shrug off the clanky bits that make it a poor fit for embedded devices.

                                                        However, I'm a personal believer that the future is polyglot. We're just at the beginning of shrugging off the C ABI that has been preventing useful interoperability for decades.

                                                        Once that happens, I can use Rust for the parts that Rust is good for and Zig for the parts that Zig is good for.

                                                        • tialaramex 1 year ago
                                                          > clanky bits that make it a poor fit for embedded devices.

                                                          What do you see as "clanky bits that make it a poor fit" for such a broad range of stuff as "embedded devices" ?

                                                          Embedded goes at least as far as from "It's actually just a Linux box" which is obviously well suited to Rust, to devices too small to justify any "high level language" where even C doesn't really fit comfortably. Rust specifically has no ambitions for hardware too small to need 16-bit addresses, but much of that range seems very do-able to me.

                                                          • bsder 1 year ago
                                                            Example clanky bit: memory ownership rules.

                                                            There are lots of systems where memory changes hands. Game programming, for example. You allocate a big chunk of memory, you put some stuff in it, you hand it off to the graphics card, and some amount of time later the graphics card hands it back to you.

                                                            Rust gets VERY cranky about this. You wind up writing a lot of unsafe code that is very difficult to make jibe with the expectations of the Rust compiler. It's, in fact, MUCH harder than writing straight C.

                                                            Example clanky bit: slab allocation

                                                            You often don't really care about deallocation of objects in slabs in video games because everything gets wiped on every frame. You'd rather just keep pushing forward since you know the whole block gets wiped 16 milliseconds from now. Avoiding drop semantics takes (generaly unsafe) code and work.

                                                        • mattdesl 1 year ago
                                                          Fast and compact WASM builds are builtin to Zig's toolchain:

                                                          https://github.com/mattdesl/wasm-bench

                                                          • binary132 1 year ago
                                                            “Whatever you would use C for but better” roughly

                                                            I’m not really convinced because in Andrew’s livestreams he’s actively uncovered significant stdlib bugs that he is aware of and tables for later.

                                                            Hopefully those will all be gone by 1.0, but I doubt it. For now, I cannot consider it a viable alternative to anything for production software. I do hope it will be some day, because it’s a nice language, even if it has a few syntactic warts :)

                                                            that said... I feel safer choosing C89 or C99 for certain things due to its extremely wide availability and longevity.

                                                            It’s great for it to have competitors, but C and C++ are more like standards and less like one tool with a handful of people working on it.

                                                            • SpaghettiCthulu 1 year ago
                                                              I've been thoroughly enjoying implementing a compiler and bytecode interpreter in Zig for a little scripting language I've been designing.
                                                            • konsuko 1 year ago
                                                              The new multi-object for loop syntax is such an improvement. Hoping for many more small QoL features like this until Zig hits 1.0.
                                                              • ephaeton 1 year ago
                                                                Wow, those are really nice release notes.
                                                                • mlugg 1 year ago
                                                                  I wrote a good chunk of these notes and can tell you that these are probably the least detailed/useful we've ever done, because they were only about 40% completed when release day came, so we spent a few hours doing quick & sloppy improvements :P you can hopefully expect them to improve a bit over the next few days

                                                                  (although I think we still managed to write up all of the most important bits)

                                                                  • ephaeton 1 year ago
                                                                    interesting. Maybe those are the first I follow with interest and it's just the general quality of presentation / fitting level of detail / "tone". Maybe I'm just complimenting your template, but feel free to feel addressed!
                                                                • wodenokoto 1 year ago
                                                                  I enjoy seeing an update or discussion of things like D, Zig, Nim (and a few others I probably forgot) but I honestly can't keep track of where they are in relation to C/C++, C#/Objective-C, and Rust.

                                                                  Is there are chart or a "are we xxxx yet" page one can reference?

                                                                • msavara 1 year ago
                                                                  Anybody here who is using zig on daily basis?
                                                                  • captainhorst 1 year ago
                                                                    I use Zig for all my hobby projects:

                                                                    - A pixel art editor https://github.com/fabioarnold/MiniPixel

                                                                    - A Mega Man clone https://github.com/fabioarnold/zeroman

                                                                    - Zig Gorillas https://github.com/fabioarnold/zig-gorillas

                                                                    And most recently I had the opportunity to build a visualization for TigerBeetle's database simulator: https://sim.tigerbeetle.com

                                                                    Before I was using C++ and Zig has been an improvement in every way.

                                                                    • lylejantzi3rd 1 year ago
                                                                      That mega man clone is great. The movement feels exactly how I remember mega man 3 feeling. You absolutely nailed it. I also appreciate how you've set up the code, with the build script being written in zig. I checked the code out, compiled it, ran the web server and bam! It just worked. It doesn't seem like that should be a big deal, but competence is such an exotic bird in these woods that I appreciate it whenever I see it.
                                                                      • throwawaymaths 1 year ago
                                                                        How did you not name that zigorrilas?
                                                                      • trashburger 1 year ago
                                                                        I don't know about "daily" right now (I've had to take a break due to obligations), but I'm working on a modern implementation of the Self programming language with actor capabilities: https://github.com/sin-ack/zigself

                                                                        It's nowhere near usable yet, but Zig has been a joy to work with for over a year, and I can definitely see myself using it for a big piece of software.

                                                                        • whitehexagon 1 year ago
                                                                          Most days. Just switched to linux to access latest version and features, especially loving the new 'packed struct(u32)' for some low level SoC work (Register representation). I get compile errors if I miscount the bits, and I managed to get some type safety, and not a single 'shift', 'and' or 'or' sign in sight!

                                                                          Looks like I'll be porting to 0.11.1 as soon as the documentation is in place... I hope they slow down soon, already feels complete. The WASM support is amazing, much smaller outputs than the other options I tried (Java & Go). Great work team!

                                                                          • latch 1 year ago
                                                                            I took a year off, and one of the things I did was learn Zig. I've built a number of libraries, including one of the currently more popular HTTP server libraries (https://github.com/karlseguin/http.zig).

                                                                            A number of my libraries are used for https://www.aolium.com/ which I decided to write for myself.

                                                                            I try to write a bit every day with the benefit that I can "waste" time digging into things or exploring likely-to-fail paths.

                                                                            • rene_d 1 year ago
                                                                              I am building an on-premise annotation platform for medical image data (MVA.ai) where it is used for both backend and frontend (WASM). Really enjoy the language, with the key aspects being the low level control and performance, the build system and cross-compilation, comptime for generics, the easy integration of existing C libraries and the support for WASM. Manual memory management is sometimes a bit tedious, but you get used to it quite quickly. On the other hand, being able to use different allocators can even give you something like 'lifetimes'.
                                                                              • tauoverpi 1 year ago
                                                                                I'm slowly writing a game with it in my own time and previously worked on an in-memory cache for smart metering full-time. It's been nice to play with and my goto language for prototyping since arond 0.5.0.
                                                                                • eatonphil 1 year ago
                                                                                  Everyone where I work does. :)
                                                                                  • anonymoushn 1 year ago
                                                                                    We trade ten million dollars a day of shitcoin derivatives using zig. Should be more soon :). We're probably stuck on 0.10.1 until async makes it back in though.
                                                                                  • grumpyprole 1 year ago
                                                                                    Zig is not memory safe and therefore at risk, just like C/C++, of future government legislation that outlaws the use of memory unsafe languages for some or all projects. The risk of such legislation is not insignificant: https://www.itpro.com/development/programming-languages/3694...

                                                                                    Personally I do not see the point of building an entirely new language and ecosystem that does not fully address this issue.

                                                                                    • jmull 1 year ago
                                                                                      Well, technically, Rust is unsafe, unless they remove “unsafe”.

                                                                                      We’re really talking about safety on a continuum, not as a binary switch. Zig has some strong safety features, and some gaps. Well, one notable big gap, UAF. (Perhaps they’ll figure out a way to plug thisin the future? Perhaps by 1.0?)

                                                                                      Actually, safety has multiple axes as well.

                                                                                      > Personally I do not see the point of building an entirely new language and ecosystem that does not fully address this issue

                                                                                      The more safe languages make significant tradeoffs to achieve their level of safety. The promise of zig (I don’t know if it will ultimately achieve this, but it’s plausible, IMO), is “a better C”, including much more safety. For one thing, it has a great C interop/incremental adoption story, which increases the chance it will actually be used to improve existing codebases. The “RIIR” meme is a joke because, of course, there is no feasible way to do so for so many of the useful and widely used vulnerable codebases.

                                                                                      • ksec 1 year ago
                                                                                        >Well, technically, Rust is unsafe, unless they remove “unsafe”.

                                                                                        I am somewhat surprised this is being mentioned. And the whole thread is without the usual people complaining it about unsafe.

                                                                                        Interesting changes happening on HN.

                                                                                      • justin66 1 year ago
                                                                                        I'm sure the federal government's advocacy will aid Rust adoption massively. I mean, look at how Ada's adoption skyrocketed when it received DoD's stamp of approval.
                                                                                        • BaculumMeumEst 1 year ago
                                                                                          the united states government is not going to outlaw the use of memory unsafe languages. that is an absurd idea. nothing in your links suggests they would even consider it. "moving the culture of software development" to memory safe language does not mean "we want to put you in jail for writing C".
                                                                                          • grumpyprole 1 year ago
                                                                                            Where did you get the idea that jails are involved? Governments are clearly forming a position, if they fund new projects, they are quite likely to enforce that position. That's a significant market already.
                                                                                            • BaculumMeumEst 1 year ago
                                                                                              they can enforce that position by funding projects that are written in languages that they believe are memory safe. they do not need, or want, to legislate that.
                                                                                            • pjmlp 1 year ago
                                                                                              No, however it may require that like with other kinds of dangerous chemicals, or hazourds goods, their use must follow strict requirements, like they already have to for high integrity computing.
                                                                                              • dakom 1 year ago
                                                                                                Agreed, it's absurd. Jail time for writing javascript otoh...
                                                                                                • Borborygymus 1 year ago
                                                                                                  I guffawed, and I'm not afraid to admit it.
                                                                                              • dgb23 1 year ago
                                                                                                At some level you need languages that are not “memory safe”.

                                                                                                Memory safety comes with a cost. Either you pay for a GC runtime (Java) or for reference counting (Swift) or by not being able to express a correct program (Rust).

                                                                                                There are plenty of use cases where none of these tradeoffs are feasible.

                                                                                                To add, Zig comes with its own story around memory safety. Not at the static type system level and it’s not as comprehensive as other languages.

                                                                                                • aldanor 1 year ago
                                                                                                  "Express a correct program" that might end up being incorrect due to programmer's fault.

                                                                                                  The difference is, you can use unsafe blocks/fns in Rust, in which case it becomes equivalent to C expressiveness-wise; but you can also do the opposite and forbid(unsafe_code) altogether.

                                                                                                  • memefrog 1 year ago
                                                                                                    All programs can be incorrect. You cannot forbid unsafe code. Its use is necessary to implement basic functionality.
                                                                                                  • grumpyprole 1 year ago
                                                                                                    > At some level you need languages that are not “memory safe”.

                                                                                                    Perhaps as an escape hatch (unsafe Rust) or a compiler target, but ideally not as a "general purpose language" as Zig is marketed as.

                                                                                                    • Klonoar 1 year ago
                                                                                                      ...that's like, completely ignoring the escape hatch in Rust of unsafe {}.

                                                                                                      You're not limited by anything there, period.

                                                                                                  • quic5 1 year ago
                                                                                                    That totally misses the point of quality software. What good is memory safety if you medical device crashes because of an out of memory error?

                                                                                                    What I'm trying to say: There are use cases where areas of safety are required other than memory safety.

                                                                                                    • nevi-me 1 year ago
                                                                                                      It sounds like you'd be worrying about n-1 types of safety errors instead of n, which is arguably better.
                                                                                                      • lmm 1 year ago
                                                                                                        There are use cases where safety beyond memory safety is required. But there are no use cases where memory unsafety is desirable, yet alone required.
                                                                                                        • memefrog 1 year ago
                                                                                                          >there are no use cases where memory unsafety is desirable, yet alone required.

                                                                                                          There are plenty of 'use cases' where Rust's guarantees (some vague but unenforceable promises around memory) are not worth the cost of using Rust (a very high cost). This is doubly true if you want to, say, not use any third-party libraries. If you use third-party libraries, you get essentially zero guarantees. And if you don't, you have to reinvent the world - and writing new data structures in Rust is a series of research projects, whereas doing so in C is trivial.

                                                                                                          There are many situations where guaranteed 'memory safety' (a Rust propaganda term for 'having the guarantees we can provide but not the ones we can't provide') is not very important.

                                                                                                          • quic5 1 year ago
                                                                                                            That is absolutely true. But but you can write memory-bug-free code in Zig but you cannot prevent heap allocations in most of the languages listed in the article, making it outright impossible to write certain software in them.
                                                                                                            • jdrek1 1 year ago
                                                                                                              While that is true, there might be other requirements that prevent memory safe languages from being used. For example not having a heap available instantly disqualifies most of them. Or when you have simulations running where having constant OOB and other checks would be a massive slowdown. Now obviously your code should still be memory safe (because otherwise it's not correct anyway and you should fix the code), but not at the cost of runtime checks.
                                                                                                              • throwawaymaths 1 year ago
                                                                                                                > But there are no use cases where memory unsafety is desirable, yet alone required.

                                                                                                                Operating system bootstraps?

                                                                                                                DMA management/volatile driver access?

                                                                                                                Doubly linked lists?

                                                                                                              • grumpyprole 1 year ago
                                                                                                                Memory safety is one aspect of quality yes, but is there any evidence Zig is a good fit for other quality aspects, e.g. static analysis tooling and correctness proofs? ATS is a low-level language that allows embedded proofs of correctness in the type system.
                                                                                                                • johnisgood 1 year ago
                                                                                                                  That article does not even mention Ada/SPARK... So much for safety. :P Yup, there is static analysis with Ada/SPARK and it is great. It is much more general-purpose than ATS, and there are other things in Ada/SPARK that increases safety in general, not only memory safety.

                                                                                                                  For what it is worth, Ada/SPARK has a strong presence in safety-critical domains like aerospace and medical devices, while Rust is gaining popularity in system programming and web development. ^^ I'm surprised that it is not as widespread. That, or lots of misconceptions.

                                                                                                                • TheFragenTaken 1 year ago
                                                                                                                  Not to be snarky, but you argument works both ways :). What good is a medical device if it leaks sensitive data, because it had been exploited by a use-after-free?
                                                                                                                  • Ygg2 1 year ago
                                                                                                                    Memory errors are much, much less likely to occur with more memory than use after free.
                                                                                                                  • flohofwoe 1 year ago
                                                                                                                    Zig enforces much more correctness than C or C++, which also results in much more memory safety, it's just not as extremist as Rust.
                                                                                                                    • TheRoque 1 year ago
                                                                                                                      What would happen with existing codebases, sometimes built upon 2 decades of C or C++? Will the we "rewrite everything in Rust" ? lol
                                                                                                                      • pjmlp 1 year ago
                                                                                                                        No, we will Rewrite in ChatGPT (or similar), and only architect jobs and the few AI druids that write the tooling will be safe.
                                                                                                                        • grumpyprole 1 year ago
                                                                                                                          Maybe doing it for new projects is better than doing nothing?
                                                                                                                          • 31tor 1 year ago
                                                                                                                            AI will probably find all bugs or re-write all the software in minutes soon enough.
                                                                                                                          • templix 1 year ago
                                                                                                                            I ditched Rust a year ago in favor of Zig and have not regretted since

                                                                                                                            Number of memory bugs in several fairly huge projects: 0

                                                                                                                            Zig is way more maintainable, leads to less code which translates to fewer bugs

                                                                                                                            How about that?

                                                                                                                            • throwawaymaths 1 year ago
                                                                                                                              Someone will eventually build a static safety checker for zig. No reason memory safety has to be in the compiler.
                                                                                                                              • al_be_back 1 year ago
                                                                                                                                IF a Gov subcontracts a company to design + impl a system, they as Customer (if you like) have the right to request specifics; maintenance & integration with the wider ecosystem is a massive concern in this case. That's not "legislation" though.
                                                                                                                                • bachback 1 year ago
                                                                                                                                  seriously?

                                                                                                                                  "The National Security Agency (NSA) has recommended only using 'memory safe' languages, like C#, Go, Java, Ruby, Rust, and Swift, in order to avoid exploitable memory-based vulnerabilities."

                                                                                                                                  • grumpyprole 1 year ago
                                                                                                                                    Yes seriously. The west is getting hacked and owned on a daily basis. The NSA recommendation shows that governments are starting to identify where the problem is.
                                                                                                                                    • ArtixFox 1 year ago
                                                                                                                                      ah yes the east! The lovers of memory safety. West is getting hacked daily because every country is getting hacked daily.
                                                                                                                                    • DrBazza 1 year ago
                                                                                                                                      log4shell enters the chat.

                                                                                                                                      https://en.wikipedia.org/wiki/Log4Shell

                                                                                                                                      • pjmlp 1 year ago
                                                                                                                                        Yes, it belongs to the remaining 30% of exploits, when we remove the 70% ones caused by memory corruption.
                                                                                                                                    • johnisgood 1 year ago
                                                                                                                                      And they have not even mentioned Ada/SPARK... right.
                                                                                                                                      • 0xfedbee 1 year ago
                                                                                                                                        [flagged]
                                                                                                                                        • grumpyprole 1 year ago
                                                                                                                                          You might think that, if you live in a small world. I want memory safety, but I am otherwise not a big fan of Rust. Rust tries to be too high-level like C++, making it opaque where allocations are happening. For a low-level systems language, with embedded proofs, I quite like ATS, but Vale is also promising and more like Zig.
                                                                                                                                          • ArtixFox 1 year ago
                                                                                                                                            The way zig is designed, I think it will be fairly easy to embed Ada's Spark like proof system in it.
                                                                                                                                          • graboid 1 year ago
                                                                                                                                            Where did he/she even mention Rust?
                                                                                                                                            • johnisgood 1 year ago
                                                                                                                                              Well, you do not see people mentioning Ada/SPARK whenever memory safety is the topic of discussion, do you? They mention Rust! Well, I do mention Ada/SPARK as much as I can because it is still a much safer language in general than Rust.
                                                                                                                                        • keb_ 1 year ago
                                                                                                                                          I wanted to try learning Zig, but found the resources to be incomplete and lacking in examples. Rust (or Go) in comparison has a plethora of online resources with great examples.

                                                                                                                                          I realize Zig is just 0.11, but wondering what resources people relied on to pick it up?

                                                                                                                                          • rgrmrts 1 year ago
                                                                                                                                            I’ve been using the language reference [0] and also just browsing the standard library source code [1] for examples.

                                                                                                                                            [0]:https://ziglang.org/documentation/0.11.0/

                                                                                                                                            [1]:https://github.com/ziglang/zig/tree/master/lib/std

                                                                                                                                            • flohofwoe 1 year ago
                                                                                                                                              That's important: don't be afraid to look into the stdlib source code when questions arise. It's easy to read and stuff is easy to find, and it's also a great teacher.
                                                                                                                                              • bsaul 1 year ago
                                                                                                                                                Since go, this has been a really great way for me to judge a langage: how readable is the stdlib ?

                                                                                                                                                If it's layer upon layer of unscrutable abstractions, then you know there's a high chance your codebase will end up looking the same after a few years.

                                                                                                                                            • kristoff_it 1 year ago
                                                                                                                                              The main available resources are listed here

                                                                                                                                              https://ziglang.org/learn/

                                                                                                                                            • andy_herbert 1 year ago
                                                                                                                                              Are people supposed to realise this version number is related to Zig?
                                                                                                                                              • Tor3 1 year ago
                                                                                                                                                Somebody fixed the title from 0.11.0 to Zig 0.11, so it's ok now.
                                                                                                                                              • ksec 1 year ago
                                                                                                                                                @WalterBright In case any of the sh*t got into you. Ignore all the trolls about you appearing in Zig thread. ( Although I think some of them are just joking )
                                                                                                                                                • whiterock 1 year ago
                                                                                                                                                  It‘s a shame macOS Arm is deprecated :(
                                                                                                                                                  • BaculumMeumEst 1 year ago
                                                                                                                                                    this comment is misleading. aarch64, the architecture for apple silicon, is still fully supported. did you see "arm" with a skull next to it and assume that meant all ARM architectures became recently deprecated?
                                                                                                                                                    • quic5 1 year ago
                                                                                                                                                      I don't believe there ever was support for macOS on 32-bit ARM.
                                                                                                                                                    • flohofwoe 1 year ago
                                                                                                                                                      Wait what? I use Zig just fine on my M1 Mac. Did macOS ever run on non-Apple-ARM chips?
                                                                                                                                                      • sai_c 1 year ago
                                                                                                                                                        Whoa, thanks for the heads-up. I've been reading news about Zig from time to time, and planned giving it an honest try at 1.0 (whenever that may be) but it seems I'm out of luck.

                                                                                                                                                        Do you, by chance, know the reasoning behind this step?

                                                                                                                                                        • candrewlee14 1 year ago
                                                                                                                                                          Aarch64 is supported (M series chips) if that’s what you’re worried about.
                                                                                                                                                          • sai_c 1 year ago
                                                                                                                                                            No, I actually have a bunch of older Macs I keep running for certain experiments.
                                                                                                                                                      • xchkr1337 1 year ago
                                                                                                                                                        does it support tabs yet?
                                                                                                                                                      • cod1r 1 year ago
                                                                                                                                                        [flagged]
                                                                                                                                                        • bmacho 1 year ago
                                                                                                                                                          > If the Operating System is proprietary then the target is not marked deprecated by the vendor. The icon means the OS is officially deprecated, such as macos/x86.

                                                                                                                                                          Not supporting proprietary OSes is a bummer. Especially if it is marked as deprecated since it is unlikely to change. People choosing Zig to anything choose their users to throw away their devices.

                                                                                                                                                          .. the number of hardware and software just keeps growing and growing endlessly, and the number of their combinations grows even faster. We probably need some more virtual machines as targets to cover them all.

                                                                                                                                                          • kristoff_it 1 year ago
                                                                                                                                                            > People choosing Zig to anything choose their users to throw away their devices.

                                                                                                                                                            Apple is asking you to throw away your devices, not Zig. Getting proper CI coverage for supported versions of the OS is already pretty expensive and doing the same for unsupported systems is entirely unfeasible at this moment.

                                                                                                                                                            Don't buy Apple if you don't want to throw away functioning hardware.

                                                                                                                                                            • bmacho 1 year ago
                                                                                                                                                              Yeah, sure. It is still a bummer when people that try actively to underpin the whole world tell you 'fuck you'.

                                                                                                                                                              Having 'we support proprietary systems until their makers support it' as a hard rule is unnecessary and harsh. It is a simple rule, but I don't think it is good. Why not choose the supported systems on individual merits, e.g. on usage statistics? I think for example the Linux kernel does that.

                                                                                                                                                              edit: I just continued the previous thought. If your reply means that you are open or likely to target deprecated systems in the future, that's much better!

                                                                                                                                                              • kubkon 1 year ago
                                                                                                                                                                Hi, kubkon here, the author of Zig's MachO linker. I just wanted to explain our reasoning here a little bit. As you have hopefully noticed in the release notes, there are 5 core team members that are paid either full- or part-time for their work on Zig. That's not an awful lot, and as you can see in our latest roadmap for 0.12 release, we have quite a few challenging components to develop including functioning linkers for the most common platforms, and not only macOS/Apple. This makes it really tricky to justify spending a considerable amount of time trying to support an OS that was officially dropped by a vendor such as macOS/x86, or watchOS/arm32 (FYI, as a fun fact, arm32 is considered private as opposed to public by Apple according to comments and conditional includes in Apple's libc headers). That said, after 1.0/stable release of Zig, I would love to spend more time into adding backwards support for old Apple platforms in the MachO linker and Zig as a whole.
                                                                                                                                                                • kristoff_it 1 year ago
                                                                                                                                                                  > I just continued the previous thought. If your reply means that you are open or likely to target deprecated systems in the future, that's much better!

                                                                                                                                                                  It would be nice to eventually provide support older systems but first we need to get to a point where doing so doesn't mean taking away resources from more worthy endeavors.

                                                                                                                                                                • 1 year ago
                                                                                                                                                                • jmull 1 year ago
                                                                                                                                                                  I think the “not” in there is a typo? It reads logically if you remove it.

                                                                                                                                                                  So it’s not really zig deprecating 32-bit macos’s, but Apple, and there’s not a lot zig can do about that.