Comment by hardwaresofton

Comment by hardwaresofton a day ago

128 replies

I'm not a Zig PM but the first obvious fix for the issues the OP wrote about is to write better documentation, including usage examples (the more the better, almost to a fault). Also doubles as a good time to reflect on whether the user is having to do too much.

If the tradeoff was absolute performance/avoiding introducing load-bearing performance-lowering abstraction I think that goal was achieved, but DX may have gone out the window.

brabel a day ago

You’re not familiar with Zig’s culture, I guess. Complain about the lack of documentation and be prepared for the flood of “just read the stdlib code” helpful comments by pretty much everyone who writes Zig right now. Because most APIs are just as hard to use as in this post (check things like HTTP and even basic file system operations) only the strongest survive.

  • virtualritz a day ago

    I do not think this is a viable excuse any more.

    I am just editing docs now that Claude Code writes for me. I am fanatic about developer docs (and I guess an exception as I love writing them) but with a set of concise instructions for CC and some writing style examples I get 90% there, sometimes 99%.

    If you believe you don't have time for the last 1--10% you should not be in charge of writing any API used by anyone but yourself. Just my two c.

    • aDyslecticCrow a day ago

      Ai is great at block comments, there is no excuse. Add to that a small anotated usage example written by a human and this whole post would have not existed.

      Lack of docs also cripple AI from understanding, so future adoption becomes even more bleak.

      If an api or library developer didnt bother doing even bare minimum docs, my confidence in the library drops aswell.

      Did they skip testing aswell? Ran the happy path for a day and called it good?

      This post sour my interest in zig. Its now obvious to me now why rust took much of its market.

      • felixgallo a day ago

        Zig is just getting started and came way after rust.

      • [removed] a day ago
        [deleted]
    • mikepurvis a day ago

      As a senior dev I’m also passionate about docs and communication, and actually kind of love the process of agonizing over a bunch of rST files to get the perfect manual that’s both an on-boarding guide and also a reference of all the nooks and crannies.

      I think what I’ve come to realize is that when I feel a barrier toward doing that work, it’s a sign that I don’t actually like the underlying API. I don’t want to document it or craft examples or tutorials because in my mind the API sucks, it’s transitional, and documenting it in its current state is going to somehow lock in a bad interface and further increase the effort required to change and fix it up later.

    • throwawaymaths a day ago

      It's just not reasonable to expect volunteers to write eloquent documentation when it's likely it will just get flushed

    • tel a day ago

      At the same time, if you want to use Claude to read the source and narrate how it works to you that’s trivial to do as a user.

    • [removed] a day ago
      [deleted]
    • foxes a day ago

      I don't want to read ai slop comments. If you cant be bothered writing docs, I cant be bothered learning to use your library.

      • BobbyJo a day ago

        Just because and AI produced it doesn't mean it is slop.

  • keyle a day ago

    That would hurt adoption. I understand things move fast but if you want people to make the switch other than hello world, it has to be at a minimum cosy. Sending them to hell and find your way out isn't a good move long term.

    I tried Zig a couple of times and I got that feeling: very powerful and clever language but not really for me, I don't have the headspace, sorry. I need something I can debug after an 8 hours dayjob, a commute and having put the kids to bed. It better be inviting & fun! (Hi, C).

    • skupig a day ago

      Yeah, I had the same experience. I had an embedded project where I would need to use C libraries, and it seemed like a great excuse to try Zig, but it spat out a ton of esoteric errors I couldn't be bothered to figure out and I went back to Nim.

    • throwawaymaths a day ago

      after chasing some insane macro gymnastics whivh are there to make the c portble, i came to understand that zig is more easy to debug than c

      • keyle a day ago

        I don't live in that universe! I thanos flicked it off!

  • hardwaresofton a day ago

    Yeah, thinking about this attitude positively, maybe it’s a feature — if only hard core people can comfortably figure it out, you get higher quality contributions?

    Not trying to imply that’s an explicit goal (probably instead just a resource problem), but an observation

    • ksec a day ago

      I think it is a trade off for between zig's development speed and documentation. It is Pre 1.0, extreme beta mode with lots of breaking changes.

      Generally speaking I think it is the right trade off for now. Purely inferring from Andrew and the Zig's team online character as I don't know them in person, I think they do care a lot of DX, things like compiling speed and tools. So I think once 1.0 come I won't be surprised if it will have extremely good documentation as well.

      And I would argue, writing good, simple, clear, detailed documentation is actually harder than writing code itself.

      • brabel a day ago

        I've written many APIs. Never have I got it right without first writing lots of tests, finding the rough corners, improving it... and so on. Writing documentation after that is absolutely mandatory for the end result to be a high quality API. As you write how it is meant to work, you will definitely find things that don't really make sense, or that should not be as hard ( I think this post shows just such an API that hasn't gone through this process ). IMHO documentation is NOT optional. The implementation is NOT how you mean for the API to be used.

      • hardwaresofton a day ago

        On the one hand, I totally get that pre 1.0 is the wild west (somewhat) and should be. The team is right in jealously guarding their ability to make changes.

        That said, others have pointed out that writing documentation and tests helps improve quality quite a bit, and in this case it would also increase usability. I think I'd agree with this stance, but there is no way I could make the statement that even most of the code I've written for public consumption had excellent documentation or examples. So I've got no leg to stand on there, just the armchair.

        > And I would argue, writing good, simple, clear, detailed documentation is actually harder than writing code itself.

        All the more reason why it must be done! A little silly but from my armchair maybe it's one of those "start with the interface you want and work backwards", but the problem is that approach can be at odds with mechanical sympathy and we know which side Zig lands on (and arguably should land on based on it's values).

      • LambdaComplex a day ago

        My quick skim of Wikipedia may not be telling the complete story, but it says the initial release was 9 years ago (February 2016). After nearly a decade, I would hope that things would be out of "extreme beta mode," but I guess this isn't the case?

      • sshine a day ago

        Unstable APIs are a good example of something that's extremely valuable early on.

        They unarguably cause confusion for everyone as they change.

        But it lets you choose the right abstractions that are going to stick for decades.

        If you're going to make a python2 -> python3 transition in your language, make sure it's X0 -> X1.

    • chrisandchris a day ago

      Contributions to the Zig language or contributions to software using Zig (the latter is the one the post is about as I understand)?

      If so, I believe Zig will stay within a niche. Lower entry barriers allow "script kiddies" to easily start withe language, and they eventually will become leading engineers. Only a few people tend to go straight for the highest practice without "playing around". IMHO the reason, why PHP got so popular (it was not good back then, just very very easy to start with).

      • hardwaresofton a day ago

        > Contributions to the Zig language or contributions to software using Zig (the latter is the one the post is about as I understand)?

        Yes.

        I think a contributor that really wanted to help the ecosystem would start in the stdlib and then start moving outwards. Even if it was LLM-assisted, I think it could be high value.

        IIRC Loris already has an engine for building websites with Zig, but making sure that every Zig library has docs (similar to rustdocs) might be a great start. It is incredibly useful to have a resource like rustdocs, both the tooling and the web sites that are easily browsable.

        Again, maybe everyone in the Zig ecosystem just has amazing editor setups and massive brains, but I personally really like the ease of browsing rustdoc.

        > If so, I believe Zig will stay within a niche. Lower entry barriers allow "script kiddies" to easily start withe language, and they eventually will become leading engineers. Only a few people tend to go straight for the highest practice without "playing around". IMHO the reason, why PHP got so popular (it was not good back then, just very very easy to start with).

        I agree, but I'd add that the niche they're aiming for is systems programming, so they're probably fine :). The average hacker there is expecting C/C++ or to be near the metal, and I think Zig is a great fit there. They're likely not going to convince people who write Ruby, but it feels reasonable for C hackers.

        Also I want to just be clear that I think Zig has a lot of motivating factors! They're doing amazing things like zig cc, unbelievably easy, "can't believe it's not butter" cross-compilation, their new explicit/managed I/O mechanism, explicit allocators as a default, comptime, better type ergonomics. It's a pretty impressive language.

    • rjh29 a day ago

      I think it is intentional. They don't want to attract low-commitment beginners while the language is heavily changing (and explicitly in beta). Such people will ask questions and ask for documentation but contribute nothing.

    • DannyBee a day ago

      More likely you get people who have the same groupthink, which has both ups and downs. Their contribution quality is probably not that well correlated.

  • [removed] a day ago
    [deleted]
  • littlestymaar a day ago

    The key problem with Zig nowadays is how much of its community and adoption is driven by anti-Rust sentiment. As a result, while Rust puts beginner onboarding and documentation at the center of its culture, as opposed to the “C neckbeard”'s culture, Zig is going the other way around.

    (Loris Cro being a key community figure isn't helping in any way, and it's a good remainder that if you don't clear up your community from bullies from the beginning, they will turn your entire community to a miserable place. And that's a shame because from what I've seen, Andrew Kelley seems to be a very cool guy in addition to being very smart).

    • kristoff_it a day ago

      > The key problem with Zig nowadays is how much of its community and adoption is driven by anti-Rust sentiment. As a result, while Rust puts beginner onboarding and documentation at the center of its culture, as opposed to the “C neckbeard”'s culture, Zig is going the other way around.

      Maybe, or maybe the fact that Zig is a small independent project with limited resources has also something to do with it, and this kind of shaming says less about Zig than you'd think.

      When I first joined the Zig project, Zig was still using the bootstrap compiler written in C++ that would not free memory (it took more than 4GB to compile the Zig compiler). Some people at the time were asking us to prioritize work on the package manager but Andrew rightfully wanted to prioritize rewriting the compiler instead. In hindsight this was the obviously right decision: a package manager implies that one can very easily add an order of magnitude more code to their project, stressing the performance of the compiler. If we had not prioritized core infrastructure over giving people what they wanted faster, today we would have people complaining that adding a single dependency to their project makes the build impossible to complete.

      The Zig project has a huge scope and we are a small independent organization. This makes us extremely nimble and efficient, but it does mean that we need to do things in the order that makes the most sense for the project, not for what the public wants.

      The fact that we develop in the open doesn't mean that the language is ready yet.

      People that already have the required domain knowledge (and who have a tolerance for breaking changes) will have the opportunity to be early adopters if they wish to do so, others will have to wait for Zig to become more mature. And we do make this clear in releases and all forms of public communication.

      We have gone a long way since the bootstrap compiler days, but we are still missing key infrastructure:

      - we have a x86_64 custom backend but aarch64 is not complete yet - incremental compilation is showing that we can get instant rebuilds of large projects, but it has missing features and it doesn't work on all platforms yet - we need native fuzzing since AFL keeps regressing everytime a new version of LLVM comes out - for the longest time we haven't had a strong I/O story, now we're finally working on it

      The time for paving the road for a new generation of programmers will come (it's in the ZSF mission statement btw), but first we need to finish the plumbing.

      • mirashii a day ago

        > Maybe, or maybe the fact that Zig is a small independent project with limited resources has also something to do with it

        Or, maybe it's this kind of redirection and evidence of a victim complex. Part of the reason that there's a patina of anti-Rust sentiment includes the dismissive attitude and swipes you, a the VP of Community at the Zig Software Foundation, take towards Rust and Rust developers by writing about topics you aren't involved in and don't have a solid grasp of.

        https://kristoff.it/blog/raii-rust-linux/ https://lobste.rs/s/hxerht/raii_rust_linux_drama#c_gbn1q8

        Or similarly, comments like this one in this thread: https://news.ycombinator.com/context?id=44994749

      • adwn a day ago

        > […] Zig was still using the bootstrap compiler written in C++ that would not free memory […]

        That sounds strange. Modern C++ requires very little manual memory management, at least when you're writing something high-level like a compiler. C++11 had been out for years when development on Zig started. Were they writing C++ old-school as C-with-classes and malloc() everywhere? Why not use a more appropriate language for the first prototype of a compiler for a brand new language?

      • [removed] a day ago
        [deleted]
    • pjmlp a day ago

      Not only, the whole handmade movement puts me off.

      It is the anti-intelectualism from Go culture, gone wild against C++, Rust, Swift, anything modern, or even tools, using game engines versus doing the whole computer from scratch for a game.

      • kristoff_it a day ago

        Zig is not really a handmade project, case in point both Andrew and I are blocked on social media by the two gods of the handmade movement (casey and john) and, according to their die hard fans, Andrew gave a talk at the last handmade conference that caused the community to split apart (the reality is a bit more complex than this, but Andrew's talk is certainly one that you wouldn't see at their new "better software" conference).

        Andrew's talk is here (second event after the two people chatting while sitting on chairs): https://handmadecities.com/media/seattle-2024/hms-day-one/

        Here you can see a particularly funny (but also sad) reaction by one of these people https://drive.proton.me/urls/MB1EB4EF34#YZdvmAvBFp1C

        > using game engines versus doing the whole computer from scratch for a game

        That said you are doing yourself a disservice if you think that not using an engine to make a game is a form of "anti-intellectualism".

    • ksec a day ago

      That is actually a valid point on expectation given the attracted people's demographic.

      I will hopefully wait for comments from Ghostty, Bun or Tigerbeetle Devs.

      On another point that is wroth mentioning, I hope Andrew will at least put it out publicly, IMO Zig isn't Anti-Rust. But it did attract the type of people who are not too happy with Rust. I dont remember a single time Zig came out to bash anything about Rust. It isn't Anti anything at all. Its goal is to be a decent C replacement as very high level assembly languages, aiming at Data Oriented Design with some interesting features, and extremely fast compilation speed. ( Which was the reason why I was interested in it in the first place. I miss Turbo Pascal )

      Zig reminds me of the old school, traditional projects. It isn't perfect for everything, it never claims to be, if you like it, use it. If not, there are plenty of options out there.

      At least Ghostty Dev seems to be enjoying it almost every day.

      • littlestymaar 20 hours ago

        I don't think Andrew is anti-Rust. But Loris, whose hn profile says he's “vp of community of the zig software foundation” is as anti-Rust as you can get: he's pathologically obsessed by Rust and spent significant amount of energy outright insulting Rust maintainers here or on Twitter (when he's not buzzy writing anti-Rust rant on his blog).

        But as you say, there's no reason why Zig ought to be anti-Rust, both language are are fresh attempts at low level programming, both highly opinionated and with very different philosophies and trade offs and both language can cohabit peacefully (I've heard good things about using the Zig toolchain for cross compilation of C dependencies in rust projects, so the existence of Zig already has had a positive impact on the Rust ecosystem).

    • TUSF 18 hours ago

      > anti-Rust sentiment

      I have not seen much of any anti-Rust sentiment in the community. There's a lot of people in the community who do Rust, like rust, and work on rust projects. If the Zig community has an anti-anything sentiment, it's against C++.

      • littlestymaar 6 hours ago

        Tell that to the “VP of community @ zig software foundation” who spend a significant fraction of its time insulting Rust maintainers or mere users here or on Twitter when he's not busy writing anti-Rust rants on his blog.

        (You won't have to seek long in his HN history to find an instance of such behavior)

jakobnissen a day ago

There is a cost to writing documentation - it takes time, which could be used to improve Zig in other areas. For code that is work-in-progress, it can make sense to not document until things are more settled.

Of course documentation is good. But if you have to prioritize either a new feature, or a critical bugfix, or documentation, you often can't have it all

  • simonask a day ago

    I tend to actually disagree with this attitude, because I see writing documentation as really effective "rubber-ducking". If it's hard and time-consuming to properly document, it's probably hard to use, so extra effort should be spent to actually justify the design, not least to yourself in 6 months. If you can't justify it, it's probably wrong.

    • kelnos a day ago

      This really struck a chord with me. Writing documentation is an act of explaining something to others. Explaining something to others is a great way to test your own understanding. If it's hard to explain to someone else, then maybe it's the wrong design.

      If you don't through that exercise, you're much more likely to build confusing, difficult-to-use APIs.

      • throwawaymaths a day ago

        > you're much more likely to build confusing, difficult-to-use APIs.

        have not found this to be the case with zig in general. you could easily make the opposite argument, that documenting things (especially quirks) can give you license to build confusing APIs.

    • pmarreck a day ago

      100%.

      Similar to how TDD forces you to first figure out the API of your code due to the test code being its first client.

  • crote a day ago

    On the other hand, not writing documentation also has a cost.

    Code is rarely written from start to finish in a single session. Would you rather spend 5 minutes before you do a git commit to write down some very basic documentation, or spend an hour rediscovering it when you pick up development two weeks later?

    Nobody is expecting extensive and well-polished documentation here, but is a "Flags X, Y, and Z are mandatory, buffer A is required: I tested with 10MB, smaller might be fine too" really too much to ask for?

    Is the time you saved by not writing that one line worth someone else spending several hours figuring out how to do a "hello world"?

  • hardwaresofton a day ago

    This is a good point, but one could make a point for the usefulness of documentation in “thinking like a user” which is a valuable exercise.

    I do very much prefer moving fast though, so I get it, docs-later is obviously a very valid way of doing things.

    If someone is excited about Zig and wanted to make a difference I guess it’s now obvious where they could have outsized impact!

    • 7bit a day ago

      Docs later is an okay approach, when you build something in a closed environment, where the only users know the code inside out.

      But when working in open-source and your goal is to have people adopt your software, then it's a bad point and a lazy excuse.

  • aDyslecticCrow a day ago

    Then they should not have relead the new api at all. Why release half finnished library.

    • flohofwoe a day ago

      Zig as a whole is half-finished, should it be kept under wraps until it is ready?

      There's a reason for the 0.x version number, if you can't live with breaking changes, don't use Zig yet. It's as simple as that.

      • aDyslecticCrow a day ago

        Breaking changes and limited support is one thing. But docs is not something you add at at the end. Lacking docs and Lacking tests is code that should not be released.

        They target embedded c market. Limited support and features is expected and common. But being lax with docs and testing is not acceptable.

    • sureglymop a day ago

      Because the language is not stable at this point and hasn't reached 1.0?

      Are you saying one should never make anything half finished available to the public? This post proves why it is valuable to do so, they are getting valuable feedback and a discussion on hacker news for free.

      • viraptor a day ago

        There's an alternative of being much more up front about the status. For example the project page doesn't really say it's unstable/experimental. It only says "Zig has not yet reached v1.0" on the "getting started" page, which doesn't really mean that much - for example Putty is still at 0.83 after 26 years.

        If the project invites me to use it "for maintaining robust, optimal and reusable software." without putting "super unstable, we don't even care about docs" on the same page... that's also saying something.

        • throwawaymaths a day ago

          AIUI the team has a geberal consensus on what is left tp do before 1.0, there's even a tracking list of requirements on the github.

          if you have that attitude about docs, then likely you are being gatekept from the project until it hits 1.0.

  • 7bit a day ago

    Your argument implies that good documentation is not an improvement, which of course is wrong. It also belongs to the task of improving code. Why would you move away after half-assing the API, when you can add the docs and whole-ass it instead?

  • wordofx a day ago

    Na. It’s flat out laziness. Don’t make excuses. Either write docs or stop worrying code.

ulbu a day ago

i find that zig is too oriented at doling out directives for what not to do instead of just collecting and teaching variants of how and what to do. the lack of documentation on this interface is a sore case in point.

  • geon a day ago

    You can’t expect documentation this early. The new interface was just released.

    • viraptor a day ago

      In serious codebases docs are not an afterthought. There's lots of places where you're expected to add both a new interface and docs together.

      • rjh29 a day ago

        It's pre-1.0 beta. Nothing has been 'released' yet .

    • speed_spread a day ago

      You absolutely should expect documentation this early. The chances of quality documentation being added as an afterthought are not good. If proper documentation isn't part of the original goals after that time, things aren't looking well. Nobody is going to come and just write docs for months.

      • geon a day ago

        Zig is open source, so the docs are pretty much a wiki. You can spend 5 minutes.

    • wordofx a day ago

      So zig isn’t a serious language. It’s just some trash apis thrown together.

      • maxbond a day ago

        It's a serious language, it's just not a stable language yet.

0x696C6961 a day ago

Writing good docs/examples takes a lot of effort. It would be a waste considering the amount of churn that happens in zig at this point.

  • DannyBee a day ago

    Only in a world where features are made without thought. Documentation is not just for your users. Writing the development documentation helps you make better features in the first place.

    The zig users on this thread seem to not understand this, and all seem to think documentation is a thing you write later for users when everything settles down. Or is somehow otherwise "in the way" of feature and API development speed.

    That is a very strange view.

    If writing developer documentation is having serious affect on your language feature velocity, you are doing something very wrong. Instead, writing it should make things move faster, becuase, at a minimum, others understand what you are trying to do, how it is going to work, and can help. Also, it helps you think through it yourself and whether what you are writing makes any sense, etc.

    Yes there are people who can do this all without documentation, but there are 100x as many who can't, but will still give high quality contributions that will move you along faster if you enable them to help you. Throwing out the ability to have these folks help you is, at a minimum, self-defeating.

    I learned this the hard way, because i'm one of those folks who can just stare at random undocumented messy code and know what it actually does, what the author was probably trying to do, etc, and it took years till i learned most people were not like this.

    • 0x696C6961 a day ago

      You're conflating specs/RFCs with end-user documentation.

      • CRConrad 2 hours ago

        No, AFAICS GP wasn't conflating anything. Why would you think they were?

  • dns_snek a day ago

    That's a false dichotomy, I'll take minimal bitrotten docs in a community wiki over no docs. There's no excuse not to at least have a stub that says "these features are evolving quickly but here are 10 open source projects that should serve as good references".

    Something - anything. As much as I like Zig, I dread returning to it after a few months of being out of the loop.

    • 0x696C6961 a day ago

      It's not a false dichotomy, it's a bandwidth issue. I'd rather the core team focus on stuff like incremental compilation.

      • dns_snek a day ago

        "No documentation" and "Core devs 'wasting' time on writing high quality documentation" aren't the only two options, that's what a false dichotomy means.

        Other options include but are not limited to providing minimal, low effort examples, high-level overview, linking to projects using these features, linking to relevant tests, commits, or source code, setting up an official community wiki and encouraging people to contribute.

  • geon a day ago

    Yes. For now, that effort is better spent writing clear test cases that can serve to illustrate the intended usage.

    While tests aren’t quite as good documentation as actual documentation, they are guaranteed to not be out of date.

pharrington a day ago

I'm not a Zig developer, but I imagine one reason why the Zig documentation is so spartan is because the language is still young and constantly evolving. It's really hard to devote the time and energy to writing documentation when you know that what you've written will just be wrong at some uncertain point in the future.