frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Mac history echoes in current Mac operating systems

http://tenfourfox.blogspot.com/2025/08/mac-history-echoes-in-mac-operating.html
40•classichasclass•1h ago•7 comments

Claude Code IDE integration for Emacs

https://github.com/manzaltu/claude-code-ide.el
588•kgwgk•14h ago•193 comments

Rules by Which a Great Empire May Be Reduced to a Small One (1773)

https://founders.archives.gov/documents/Franklin/01-20-02-0213
80•freediver•4h ago•25 comments

A Candidate Giant Planet Imaged in the Habitable Zone of α Cen A

https://arxiv.org/abs/2508.03814
26•pinewurst•2h ago•9 comments

Project Hyperion: Interstellar ship design competition

https://www.projecthyperion.org
162•codeulike•7h ago•136 comments

Litestar is worth a look

https://www.b-list.org/weblog/2025/aug/06/litestar/
198•todsacerdoti•8h ago•50 comments

We'd be better off with 9-bit bytes

https://pavpanchekha.com/blog/9bit.html
103•luu•8h ago•192 comments

Jules, our asynchronous coding agent

https://blog.google/technology/google-labs/jules-now-available/
241•meetpateltech•11h ago•164 comments

Show HN: Kitten TTS – 25MB CPU-Only, Open-Source TTS Model

https://github.com/KittenML/KittenTTS
790•divamgupta•22h ago•322 comments

Writing a Rust GPU kernel driver: a brief introduction on how GPU drivers work

https://www.collabora.com/news-and-blog/blog/2025/08/06/writing-a-rust-gpu-kernel-driver-a-brief-introduction-on-how-gpu-drivers-work/
224•losgehts•11h ago•28 comments

The Day MOOCs Died: Coursera's Preview Mode Kills Free Learning

https://www.classcentral.com/report/coursera-preview-mode-paywall/
34•deepakkarki•3d ago•20 comments

Running GPT-OSS-120B at 500 tokens per second on Nvidia GPUs

https://www.baseten.co/blog/sota-performance-for-gpt-oss-120b-on-nvidia-gpus/
5•philipkiely•1h ago•0 comments

More than two hard disks in DOS

https://www.os2museum.com/wp/more-than-two-hard-disks-in-dos/
5•userbinator•3d ago•0 comments

You know more Finnish than you think

https://dannybate.com/2025/08/03/you-know-more-finnish-than-you-think/
62•infinate•2d ago•28 comments

A fast, growable array with stable pointers in C

https://danielchasehooper.com/posts/segment_array/
143•ibobev•9h ago•58 comments

The Bluesky Dictionary

https://www.avibagla.com/blueskydictionary/
119•gaws•7h ago•41 comments

Apple increases US commitment to $600B, announces American Manufacturing Program

https://www.apple.com/newsroom/2025/08/apple-increases-us-commitment-to-600-billion-usd-announces-ambitious-program/
26•Zenbit_UX•4h ago•10 comments

301party.com: Intentionally open redirect

https://301party.com/
69•nahikoa•7h ago•13 comments

Multics

https://www.multicians.org/multics.html
102•unleaded•11h ago•21 comments

Out-Fibbing CPython with the Plush Interpreter

https://pointersgonewild.com/2025-08-06-out-fibbing-cpython-with-the-plush-interpreter/
23•Bogdanp•4h ago•0 comments

Show HN: HMPL – Small Template Language for Rendering UI from Server to Client

https://github.com/hmpl-language/hmpl
7•aanthonymax•17h ago•5 comments

Comptime.ts: compile-time expressions for TypeScript

https://comptime.js.org/
104•excalo•3d ago•17 comments

A Man Who Beat IBM

https://every.to/feeds/b0e329f3048258e8eeb7/the-man-who-beat-ibm
45•vinnyglennon•3d ago•15 comments

Breaking the sorting barrier for directed single-source shortest paths

https://www.quantamagazine.org/new-method-is-the-fastest-way-to-find-the-best-routes-20250806/
139•baruchel•13h ago•43 comments

The Inkhaven Blogging Residency

https://www.inkhaven.blog/
29•venkii•3h ago•28 comments

Zig Error Patterns

https://glfmn.io/posts/zig-error-patterns/
124•Bogdanp•12h ago•33 comments

Automerge 3.0

https://automerge.org/blog/automerge-3/
250•surprisetalk•3d ago•21 comments

303Gen – 303 acid loops generator

https://303-gen-06a668.netlify.app/
180•ankitg12•15h ago•62 comments

AI in Search is driving more queries and higher quality clicks

https://blog.google/products/search/ai-search-driving-more-queries-higher-quality-clicks/
46•thm•10h ago•61 comments

Rethinking DOM from first principles

https://acko.net/blog/html-is-dead-long-live-html/
192•puzzlingcaptcha•21h ago•169 comments
Open in hackernews

Zig Error Patterns

https://glfmn.io/posts/zig-error-patterns/
124•Bogdanp•12h ago

Comments

ijustlovemath•11h ago
The website design is so pleasing, props!
etyp•10h ago
This goes to show how Zig's language design makes everything look nicer and simpler - the `errdefer` patterns in tests are super nice! I've debugged my Zig tests with simple print debugging (or try to narrow it down to a standalone case I can use a debugger), but I'll certainly use some of these tricks in the future.
ww520•10h ago
These are excellent tips. I especially like the debugger integration in build.zig. I used to grep the cache directory to find the exe. The integration avoids all the extra steps.
skrebbel•10h ago
Wow, errdefer sounds like the kind of thing every language ought to have.
jayd16•3h ago
Is it significantly different than a try-catch block?
ijustlovemath•3h ago
one less level of indentation; reading down is happy path, seems nice!
jiehong•10h ago
Nice Font! (Berkeley Mono)
vrnvu•10h ago
It's amazing how coherent Zig's fundamental building blocks are as a programming language, everything fits together like a puzzle.

This post reminds me of one of Andrew's early talks about the type system and the comptime... With the core building blocks, we can achieve elegant solutions without adding unnecessary syntax complexity.

delifue•1h ago
In my opinion Zig is elegant except for one thing: cannot attach data to error.

https://github.com/ziglang/zig/issues/2647

You have to workaround by things like passing into a pointer to error object.

davidkunz•9h ago
A little bit unrelated, but how do people deal with the abstinence of payloads in zig errors? For example, when parsing a JSON string, the error `UnexpectedToken` is not very helpful. Are libraries typically designed to accept an optional input to store potential errors?
maleldil•9h ago
> Are libraries typically designed to accept an optional input to store potential errors?

Yes. Stdlib's JSON module has a separate diagnostics object [1]. IMO, this is the weakest part of Zig's error handling story, although the reasons for this are understandable.

[1] https://ziglang.org/documentation/master/std/#std.json.Scann...

AndyKelley•7h ago
I'd like to note that std.json, as it currently stands, is not a good example of proper error handling. Unless you use that awkward lower level Scanner API, if you get a schema mismatch it reports some failure code and does not populate a diagnostics struct, which is painful and useless.

On the other hand the std.zon author did not make this mistake, i.e. `std.zon.parse.fromSlice` takes an optional Diagnostics struct which gives you all the information you need (including a handy format method for printing human readable messages).

dnautics•7h ago
I presume sometime in the not-immediate-but-not-too-distant-future there is going to be a push to "unify" std with a bunch of the "best practices" and call them out in the documentation.
AndyKelley•7h ago
Indeed: https://github.com/ziglang/zig/issues/1629
hansvm•9h ago
At a practical level, most of the language doesn't care about the distinction between errors and other types. You mostly just have to consider `try/catch/errdefer`. Your question then, mildly restated, is "how do people deal with cases where they want to use `try/catch/errdefer` but also want to return a payload?"

It's worth asking, at least a little, how often you want that in the first place.

Contrasting with Rust as an example, suppose you want Zig's "try" functionality with arbitrary payloads. Both functions need a compatible error type (a notable source of minor refactors bubbling into whole-project changes), or else you can accept a little more boilerplate and box everything with a library like `anyhow`. That's _fine_, but does it help you solve real problems? Opinions vary, but I think it mostly makes your life harder. You have stack unwinding available if you really need to see the source of a thing, and since the whole point of `try` is to bubble things up to callers who don't have the appropriate context to handle them, they likely don't really care about the metadata you're tacking on.

Suppose you want Zig's "catch" functionality with arbitrary payloads. That's just a `union` type. If you actually expect callers to inspect and care about the details of each possible return branch, you should provide a return type allowing them to do stuff with that information.

The odd duck out is `errdefer`. IMO it's reasonably common for libraries to want to do some sort of cleanup on "error" conditions, where that cleanup often doesn't depend on which error you hit, and you lose that functionality if you just return a union type. My usual workaround (in the few cases where I actually want that information returned and also have to do some sort of cleanup) is to have a private inner function and a public outer function. The inner function has some sort of `out` parameter where it sticks that unioned metadata. The outer function executes the code which might have to be cleaned up on errors, calls the inner function, and figures out what to do from there. Result location semantics make it as efficient as hand-rolled code for release builds. Not everything fits into that paradigm, but the exceptions are rare enough that the extra boilerplate really isn't bad on average (especially when comparing to an already very verbose language).

Depending on the API, your proposal of having a dedicated `out` parameter exposed further up the chain to callers might be appropriate. I'm sure somebody has done so.

Something I also do in a fair amount of my code is let the caller specify my return type, and I'll avoid work if they don't request a certain payload (e.g., not adding parse failure line numbers if not requested). It lets you write a reasonably generic API without a ton of code complexity, still allowing callers to get the information they want.

Ar-Curunir•7h ago
> suppose you want Zig's "try" functionality with arbitrary payloads. Both functions need a compatible error type (a notable source of minor refactors bubbling into whole-project changes), or else you can accept a little more boilerplate and box everything with a library like `anyhow`. That's _fine_, but does it help you solve real problems? Opinions vary, but I think it mostly makes your life harder.

This is not true, you simply need to add a single new variant to the callers error type, and either a From impl or a manual conversion at the call site

hansvm•5h ago
"compatible error type"

Which is prone to causing propagating changes if you're not comfortable slapping duck tape on every conversion.

dwattttt•4h ago
It depends on whether people depend on the structure of the errors. If they just stringify them, that shouldn't result in changes.

If people are getting into the structure of the errors, they might need to update their code that works with them.

jmull•8h ago
I think the idea is errors are for control flow. If you have other information to return from a function, you can just return it — whether directly as the return value or through an “out” parameter or setting it in some context.
quantummagic•8h ago
The idiomatic way in Zig is to return the simple unadorned error, but return detailed error data through a pointer argument passed into the function, allowing the function to fill in extra information before returning an error.

    const MyError = error{ FileNotFound, PermissionDenied };

    fn readFile(path: []const u8, outErrInfo: *ErrorInfo) ![]const u8 {
      if (fileMissing) {
        if (outErrInfo) |info| {
            info.* = ErrorInfo{
                .code = MyError.FileNotFound,
                .message = "File missing",
                .line = @line(),
            };
        }
        return MyError.FileNotFound;
      }
      return data; // success
    }
The advantage of this is that everything is explicit, and it is up to the caller to arrange memory usage for error data; ie. the compiler does not trigger any implicit memory allocation to accommodate error returns. This is a fundamental element of Zig's design, that there are no hidden or implicit memory allocations
dnautics•7h ago
should be ?*ErrorInfo in the header there =D
quantummagic•1h ago
Thanks. There are a few thinko/typoes in the example (which can no longer be edited), but the basic outline survived okay.
metaltyphoon•4h ago
So… pretty much how C does it.
dwattttt•4h ago
Culture and coding standards count for a lot. C _can_ do this, but it's not normal to.

If Zig can foster a culture of handling errors this way, it'll be the way the community writ large handle errors.

quantummagic•1h ago
The main difference is that C doesn't have error (result types) baked into the language. So the expectation would be in the Zig example above, the calling function would never even bother to inspect the error details, unless the error path was triggered by the called function.
dnautics•7h ago
I wrote an article about one possible pattern which is a concrete realization of your question -- though with more ceremony and complexity since the pathway is fully compiled out if you don't use it (vs a nullable pointer strategy):

> Are libraries typically designed to accept an optional input to store potential errors?

https://zig.news/ityonemo/sneaky-error-payloads-1aka

if you prefer video form:

https://www.youtube.com/watch?v=aFeqWWJP4LE

The answer is no, libraries are not typically designed with a standardized convention for payload return.

davidkunz•6h ago
Thank you all for these great and detailed explanations, I've learned a lot! I like the approach with an optional pointer, it fits to zig's philosophy quite well. Although there's a bit of a disconnect between the unadorned error and the corresponding data struct. I could imagine it requires care when the data struct is a union, as one needs to know which error corresponds to which variant.
rkagerer•9h ago
I love the formatting and coloring on this blog page, it's delightful to read. Like an old school DOS game.
sedatk•8h ago
It felt like a man page to me :)
pyth0•6h ago
I think the "Manual page for glfmn.io" text at the bottom confirms that. And I agree with the GP, it's very pleasant to read and look at!
yahoozoo•9h ago
Cool stuff, but the mixed casings I see here (and have in other Zig code) puts me on edge (not literally but yeah). You’ve got `addSystemCommand` then a variable named `debug_step` which has a call `dependOn`. That said, looks like most of the stdlib stuff is camel case so the snake case variables are just the authors preference.
schroffl•8h ago
The language reference has a section about naming identifiers https://ziglang.org/documentation/0.14.1/#Names
dnautics•7h ago
there was a proposal to rid of #3, but I guess that's not going to happen.