In Zig, What's a Writer?

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
Nutrient – The #1 PDF SDK Library, trusted by 10K+ developers
Other PDF SDKs promise a lot - then break. Laggy scrolling, poor mobile UX, tons of bugs, and lack of support cost you endless frustrations. Nutrient’s SDK handles billion-page workloads - so you don’t have to debug PDFs. Used by ~1 billion end users in more than 150 different countries.
www.nutrient.io
featured
  1. rust-playground

    The Rust Playground

    I happen to be of the opinion that Rust programs tend to heavily overuse monomorphization. It's not always so clear cut that it's worth gaining a slight amount of runtime speed in exchange for losing a massive amount of compilation speed.

    What I'd love is a language which is able to compile 'impl TraitName' into dynamic dispatch in debug mode and only monomorphize it in release mode.

    Basically, an automation of this technique: https://play.rust-lang.org/?version=stable&mode=debug&editio...

  2. CodeRabbit

    CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.

    CodeRabbit logo
  3. swift-evolution

    This maintains proposals for changes and user-visible enhancements to the Swift Programming Language.

    Swift does that. https://github.com/swiftlang/swift-evolution/blob/main/propo...

  4. zig-interface

    A compile-time interface checker for Zig that enables interface-based design with comprehensive type checking and detailed error reporting.

    I find this part of Zig challenging. I like real interfaces as a language primitive, sue me!

    However, I recently just swallowed my pride and try to work by convention: provide a method on the implementation type by the same name as the `anytype` argument. `T.writer()` in this case, `T.allocator()` in others, etc.

    Previously trying to battle this, I went about as far as the language would let me attempt to automate the type validation: https://github.com/nilslice/zig-interface

    This at least allows you to leverage composition to combine "interfaces" - but the caller still faces the `anytype` issue.

    I'd like to re-write this (with admitted of help from Claude!) to follow the stdlib pattern used in things like `std.mem.Allocator`, but I reach for this too infrequently to dedicate the time.

  5. zig

    General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.

    `appendSliceOptimized` is implemented using knowledge of the underlying writer, the way that say an interface implementation in Go would be able to. It's a big part of the reason that reading a file in Zig line-by-line can be so much slower than in other languages (2)

    (1) https://gist.github.com/karlseguin/1d189f683797b0ee00cdb8186...

    (2) https://github.com/ziglang/zig/issues/17985

  6. zinter

    sketch of a PoC for interfaces in Zig userspace

    It's a very nontrivial amount of code to make the library that provides all of those features, even worse to do it well. Here's a PoC for one of them [0] (default implementations).

    The broad theme is that other languages use keywords for traits or subclasses or whatever. In Zig, you can define libraries using the language's metapgrogramming facilities that do the same thing (or similar things).

    Zig doesn't have a complete metaprogramming story yet either, which makes it harder (no custom types with custom decls, can't create a function dynamically, ...), but there are still a few options for creating something that looks like an interface. In my mind, they all have something like a "template" and utilities that operate on that template. The template serves as documentation and also a hint to the LSP.

    [0] https://github.com/hmusgrave/zinter

  7. Nutrient

    Nutrient – The #1 PDF SDK Library, trusted by 10K+ developers. Other PDF SDKs promise a lot - then break. Laggy scrolling, poor mobile UX, tons of bugs, and lack of support cost you endless frustrations. Nutrient’s SDK handles billion-page workloads - so you don’t have to debug PDFs. Used by ~1 billion end users in more than 150 different countries.

    Nutrient logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

Did you know that Zig is
the 22nd most popular programming language
based on number of references?