News for hackers. Stuff that matters.

travisd

Re:Much Ado About None: Sentinel Values in Python on Sunday November 01, 2026 @06:20PM (#50330941)
Yeah, this is basically what we do. It ends up a bit more ergonomic to not have explicit result types because union types are pretty easy in Python. For example, we have functions like

    # courses.py
    def create(...) -> Course | ErrInvalid:
and they get used like

    match courses.create(...):
        case courses.Course() as course:
            # We use `course` below.
            pass
        case courses.ErrInvalid() as err:
            # Error conditions are usually translated into early returns
            raise fastapi.HTTPException(
                status.HTTP_422_UNPROCESSABLE_ENTITY, err.message
            )
    
    return APICourseCreateResponse(id=course.id, ...)
It has worked (for us at least) pretty well to reduce the number of unhandled errors that make their way into Sentry. The granularity of the error types depends on the need (e.g., sometimes we just have an `ErrInvalid` that returns a message which gets displayed to the user, but sometimes we'll have ErrInvalidAddress or ErrInvalidTaxCode to be more specific for the context).

And yeah, without nodiscard, we try™ to only do this on functions that return values that the caller will definitely need to use. Also combined with exhaustiveness checks on switch statements by default.

Re:Much Ado About None: Sentinel Values in Python on Saturday October 31, 2026 @04:42PM (#50319992)
it’s maybe less “pythonic” but at $dayjob we’ve very actively moved away from exceptions for things in favor of things that are statically type checked. too many things that become runtime bugs instead of type checking bugs.

with match now being available, we even return explicit error objects and the ergonomics are pretty good (reminds me of rust).

The AI generated images are classic slop to the point of being actively distracting.
I found two separate bugs in GCP products. One with gVisor where it would sometimes null-truncate large network packets (this was very hard to diagnose – why is my JSON full of null bytes?) and one where Cloud Run broke sudo sporadically (sudo in a FaaS is definitely niche, I had essentially containerized a very old application written by undergraduates).

Both times they were serious production bugs that took at least a week to resolve, though I only had the lowest tier of support package.

Re:Show HN: Figma-use – CLI to control Figma for AI agents on Sunday January 18, 2026 @12:57PM (#46670219)
At $DAYJOBSTARTUP, we do hackathons twice a year. At the most recent one, an engineer sat down with a designer and set him up with Cursor. The designer looked like a kind in a candy shop, he was so excited to be able to rapidly prototype with natural language and not be clicking in Figma for hours.

A month later, he comes back to the engineering team with a 10k line "index.html" file asking "How do I hand this off?" (he was definitely smart enough to know that just passing that file to us was not gonna fly). We decided to copy the designs into Figma for the handoff, both because that was the existing way we did design/engineering handoffs and also because creating high fidelity designs (e.g., "this color from our design system" and "this standard spacing value") isn't in Cursor's wheelhouse.

We're probably going to spend more time working on a better setup for him. At the very least he should be working against our codebase and components and colors and design tokens. But I'm very curious to see where it goes from here.

Re:I'd tell you a UDP joke… on Sunday January 11, 2026 @05:52PM (#46581302)
packets udp bar walk a into
Re:Can Bundler be as fast as uv? on Thursday January 01, 2026 @05:23PM (#46458785)
Many of these package managers get invoked countless times per day (e.g., in CI to prepare an environment and run tests, while spinning up new dev/AI agent environments, etc).
Re:Starbucks: Location closures and elimination of roles on Thursday September 25, 2025 @02:30PM (#45376904)
Starbucks is airport drink/food for me. Being able to order as I enter the TSA line and pick it up on the way to the gate is unmatched convenience, and the coffee options at airports generally aren't great.
Re:The Seven-Year Rule on Saturday April 26, 2025 @04:53PM (#43807115)
Of course! It helped your friend realize what kind of person you are and hopefully spurred them to find better friends who possess actual human empathy.
Re:Go is my hammer, and everything is a nail on Monday August 12, 2024 @06:52PM (#41230270)
Making an HTTP request and dealing with JSON data is a weed-out question at best. Not sure if you are interpreting the grandparent comment as actually having them write a JSON parser, but I don't think that's what they meant.
Re:Simple CLI Tool for Optimizing Your CSS Files on Saturday August 10, 2024 @02:49PM (#41211413)
I don’t want to disparage your work, OP, but micro-optimizing text files is often not very effective, especially after gzip. I’m curious to see if there’s any noticeable difference for a representative gzipped CSS file (since these assets are almost always served from a CDN with compression).
Re:C++ left arrow operator (2016) on Sunday March 24, 2024 @09:47PM (#39812218)
Thanks! I hate it!
Re:Why did we wait so long for the bicycle? (2019) on Thursday March 21, 2024 @01:12AM (#39775038)
I highly highly highly recommend the book “Two Wheels Good: The History and Mystery of the Bicycle.” It explores the origin, the various social implications across various cultures (it often became a symbol of perversion due to its association with women’s liberation), and even the modern day e-bike movement. 12/10 book, very well written too.
Based on the article, it sounds like this doesn't activate a device's microphone at all. If it did, most (all?) browsers would give a pop-up requesting permission for that.
Re:Ask HN: Embeddings as "Semantic Hashes" on Thursday November 09, 2023 @11:02AM (#38206691)
Pardon the pedantry, but this reflects the casual/conversational uses of “hash function” not the more general definition. To be a hash function, it just has to map a set to another set of fix sized values (usually some finite set of the natural numbers).

Returning unrelated (distant) hashes for similar inputs is a possible property of a hash function, and oftentimes a desirable one (especially for cryptography), but there are in fact use cases where one wants similar inputs to map to similar (or the same) hash. https://en.m.wikipedia.org/wiki/Locality-sensitive_hashing

Re:Fixing for Loops in Go 1.22 on Tuesday September 19, 2023 @06:23PM (#37577790)
It's worth noting that it's much less of a problem in Python due to the lack of ergonomic closures/lambdas. You have to construct rather esoteric looking code for it to be a problem.

    add_n = []
    for n in range(10):
        add_n.append(lambda x: x + n)
    add_n[9](10)  # 19
    add_n[0](10)  # 19
This isn't to say it's *not* a footgun (and it has bit me in Python before), but it's much worse in Go due to the idiomatic use of goroutines in a loop:

    for i := 0; i < 10; i++ {
        go func() { fmt.Printf("num: %d\n", i) }()
    }
Re:Ink: React for interactive command-line apps on Monday May 08, 2023 @01:42PM (#35864610)
Curious to know -- how do these kinds of things affect accessibility for visually impaired people? If you're using a screenreader, do these kinds of things work?
Re:Defining interfaces in C++ with ‘concepts’ (C++20) on Wednesday April 19, 2023 @03:20AM (#35625303)
Yep, I think those things are all related.
Re:Defining interfaces in C++ with ‘concepts’ (C++20) on Wednesday April 19, 2023 @03:14AM (#35625256)
Go generally is pretty conservative about that kind of thing (namely, compiler optimizations). Go generally abides by a “what you write is what you get” kind of thing, especially when it comes to “non-local” optimizations. It’s generally opposed to anything that’s “clever.” (Just my feeling as someone who uses Go pretty often and who respects the choice they’ve made on that spectrum).
I suspect this is a bad-faith argument, but just to be clear, NPR get's a tiny fraction of its funding from the government *and* maintains editorial independence.

> The news organization says that is inaccurate and misleading, given that NPR is a private, nonprofit company with editorial independence. It receives less than 1 percent of its $300 million annual budget from the federally funded Corporation for Public Broadcasting.

Re:Maps show how parking lots “eat” U.S. cities on Sunday April 02, 2023 @03:45AM (#35408185)
We’re not talking about why Seattle is far from Miami. American city sprawl is largely a recent phenomenon (post WWII) and was enabled by the rise of the personal automobile. Even the sprawl-iest of cities (Houston, TX) used to be respectably dense and walkable. The need for a car to achieve basic needs (groceries, school, work) is a phenomenon well less than 100 years old. America has this problem in part because it’s much younger than a lot of European cities, but it’s certainly not purely a function of topography.
Re:We updated our RSA SSH host key on Friday March 24, 2023 @12:48PM (#35291839)
Parent comment is concerned with privacy, not authenticity. They're not worried that someone modified their code, they're worried that someone saw it.
Re:Python is two languages now, and that's great on Monday February 27, 2023 @11:48AM (#34958663)
The author just spends the final paragraphs… guessing?

> TypeScript… JavaScript… Going to guess it's similar.

> I haven't touched Java for almost a decade

> I don't really know enough Rust to be able to comment with any confidence

Re:Shells Are Two Things on Thursday February 09, 2023 @01:26AM (#34720403)
Oil is a decently interesting “competitor” in this space. They’ve also acknowledged the dual nature of shell as REPL and programming language.

https://www.oilshell.org/blog/2021/01/why-a-new-shell.html

Since the author is responding to comments here: are there any changes coming soon that necessitated this?
Lot of people confused here -- the "running JavaScript when the browser is idle" part is a bit misleading.

It doesn't run stuff when you're the tab is backgrounded (browsers already heavily reduce what sites can do when not in focus[1]). Instead, it just lets you delay work until the page isn't doing anything else (such as rendering the page). For example, you might do this when updating a visualization on a page so that the other updates can complete first (e.g., update the input UI and redraw the visualization when that's done).

[1] https://blog.chromium.org/2020/11/tab-throttling-and-more-pe...

Re:Retrofitting null-safety onto Java at Meta on Tuesday November 22, 2022 @02:08PM (#33709785)
I also hate this about Go, but its (partial) saving grace here is the `x, err := NewX()` pattern which (at least for me) tends to prevent a decent number of these issues in practice since usually either `x` is non-nil xor `err` is non-nil.

Makes the

    // Java
    name = personService.getPerson(123).getName()
problem less likely since you'd generally have to write:

    // Go
    person, err := personService.GetPerson(123)
    if err != nil { ... }
    name, err := person.Name()
    if err != nil { ... }
Definitely more verbose than maybe

    // TypeScript
    personService.getPerson(123)?.getName()
but I think that's part of Go's tradeoffs -- much more likely that errors will be annotated more correctly (i.e., in Go you'd be more likely return an error like "failed to load person: 123" if it was the GetPerson call that failed rather than a generic error that doesn't describe which step failed)

Older »