frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

An ancient archaeological site meets conspiracy theories – and Joe Rogan

https://www.npr.org/2025/08/09/nx-s1-5492477/gobleki-tepe-archaeology
1•geox•48s ago•0 comments

Show HN: I made a Ruby on Rails-like framework in PHP (Still in progress)

https://github.com/al3rez/tracks
1•al3rez•1m ago•0 comments

Doge-Pilled

https://www.bloomberg.com/features/2025-luke-farritor-doge/
1•bediger4000•2m ago•1 comments

Long-term exposure to outdoor air pollution linked to increased risk of dementia

https://www.cam.ac.uk/research/news/long-term-exposure-to-outdoor-air-pollution-linked-to-increased-risk-of-dementia
1•hhs•4m ago•0 comments

AGI is not coming – Yannic Kilcher

https://www.youtube.com/watch?v=hkAH7-u7t5k
2•randomgermanguy•10m ago•0 comments

New adhesive surface modeled on a remora works underwater

https://arstechnica.com/science/2025/08/new-adhesive-surface-modeled-on-a-remora-works-underwater/
1•burnt-resistor•12m ago•0 comments

Stanford to continue legacy admissions and withdraw from Cal Grants

https://www.forbes.com/sites/michaeltnietzel/2025/08/08/stanford-to-continue-legacy-admissions-and-withdraw-from-cal-grants/
2•hhs•12m ago•1 comments

Rich-syntax string formatter in TypeScript

https://github.com/vitaly-t/custom-string-formatter
1•VitalyTomilov•16m ago•1 comments

Exposing Satcom in the Sky: Aircraft Systems Vulnerable to Remote Attacks

1•hacker_might•19m ago•0 comments

Show HN: Dalle 3 AI turns words into vivid pictures fast

https://dalle-3.com
2•epistemovault•20m ago•0 comments

Countries with most GPT-5 users, esp. in advanced computation and reasoning?

2•mzk_pi•22m ago•1 comments

Local LLM Hardware in 2025: prices and token per second [video]

https://www.youtube.com/watch?v=GkTqxF_gJbg
2•bishopsmother•22m ago•0 comments

Show HN: I made a Google images clone for Pixiv (Japanese art website)

https://onegai.moe/
1•nameislonjuin•24m ago•0 comments

US-French SWOT Satellite Measures Tsunami After Quake

https://www.jpl.nasa.gov/news/us-french-swot-satellite-measures-tsunami-after-massive-quake/
1•perihelions•28m ago•0 comments

Machine learning highlights factors associated with Arabidopsis circadian clock

https://www.nature.com/articles/s41467-025-62196-w
2•bryanrasmussen•33m ago•1 comments

Constant-traffic padded and encrypted network tunnel

https://github.com/markasoftware/i405-tunnel
2•marcodiego•34m ago•0 comments

It's not detection, it's verification

https://www.clipcert.com
3•stuvinton•37m ago•1 comments

Private Welsh island with 19th century fort goes on the market

https://www.cnn.com/2025/08/08/business/thorne-island-fort-wales-scli-intl
9•makaimc•41m ago•2 comments

Yet Another LLM Rant

https://overengineer.dev/txt/2025-08-09-another-llm-rant/
3•sohkamyung•41m ago•1 comments

Show HN: Kimi K2 – Powerful Open-Source AI

https://kimik2ai.app
8•NoScopeNinja•42m ago•2 comments

Yes, the referee might be biased. Discipline in English football

https://blog.engora.com/2025/08/yes-referee-might-be-biased-discipline.html
3•Vermin2000•42m ago•1 comments

R0ML's Ratio

https://blog.glyph.im/2025/08/r0mls-ratio.html
2•zdw•44m ago•0 comments

A subtle bug with Go's errgroup

https://gaultier.github.io/blog/subtle_bug_with_go_errgroup.html
4•broken_broken_•46m ago•0 comments

Ohyaml.wtf: How good is your knowledge of YAML?

https://www.ohyaml.wtf/
2•thunderbong•46m ago•0 comments

Seeking

1•prairieroadent•47m ago•0 comments

The hard steps model and whole Earth-system transitions

https://royalsocietypublishing.org/doi/full/10.1098/rstb.2024.0105
2•Luc•48m ago•1 comments

Virtual Cell Challenge – win USD 100k

https://virtualcellchallenge.org/
1•Tdsone•50m ago•0 comments

Search Trusted API Access Network

https://staan.ai
1•corentin88•51m ago•0 comments

Show HN: I built an app that uses math to find restaurants nearby the sweet spot

https://settld.space/
2•mayukh180505•54m ago•0 comments

Show HN: Remembering the year you were 18

https://wheniwas18.zkarimi.com/
1•zknowledge•54m ago•0 comments
Open in hackernews

Partially Matching Zig Enums

https://matklad.github.io/2025/08/08/partially-matching-zig-enums.html
72•ingve•4h ago

Comments

spiffyk•2h ago
This post shows how versatile Zig's comptime is not only in terms of expressing what to pre-compute before the program ever runs, but also for doing arbitrary compile time bug-checks like these. At least to me, the former is a really obvious use-case and I have no problem using that to my advantage like that. But I often seem to overlook the latter, even though it could prove really valuable.
dwattttt•2h ago
I love the idea, but something being "provable" in this way feels like relying on optimisations.

If a dead code elimination pass didn't remove the 'comptime unreachable' statement, you'll now fail to compile (I expect?)

anonymoushn•2h ago
A lot of Zig relies on compilation being lazy in the same sort of way.
dwattttt•2h ago
For the validity of the program? As in, a program will fail to compile (or compile but be incorrect) if an optimisation misbehaves?

That sounds as bad as relying on undefined behaviour in C.

Laremere•2h ago
It's not an optimization. What gets evaluated via the lazy evaluation is well defined. Control flow which has a value defined at comptime will only evaluate the path taken. In the op example, the block is evaluated twice, once for each enum value, and the inner switch is followed at comptime so only one prong is evaluated.
anonymoushn•2h ago
Well, for example you may have some functions which accept types and return types, which are not compatible with some input types, and indicate their incompatibility by raising an error so that compilation fails. If the program actually does not pass some type to such a function that leads to this sort of error, it would seem like a bug for the compiler to choose to evaluate that function with that argument anyway, in the same way that it would be a bug if I had said "template" throughout this comment. And it is not generally regarded as a deficiency in C++ that if the compiler suddenly chose to instantiate every template with every value or type, some of the resulting instantiations would not compile.
dwattttt•1h ago
To take an extreme example, what if I asserted the Riemann hypothesis in comptime? It's relying on comptime execution to act as a proof checker.

Which is fine for small inputs and uses, but it's not something that would scale well.

9029•1h ago
Nope, this is not relying on optimization, it's just how compile time evaluation works. The language guarantees "folding" here regardless of optimization level in use. The inline keyword used in the original post is not an optimization hint, it does a specific thing. It forces the switch prong to be evaluated for all possible values. This makes the value comptime, which makes it possible to have a comptime unreachable prong when switching on it.

There are similarities here to C++ if constexpr and static_assert, if those are familiar to you.

dlahoda•2h ago
fn main() {

    if false {

        const _:() =  panic!();

    }
}

Fails to compile in Rust.

Ygg2•2h ago
Why would it? If I recall correctly, const and static stuff basically gets inlined at the beginning of the program.
Sharlin•2h ago
Sure, because it's compile-time code inside a (semantically) run-time check. In recent Rust versions you can do

    fn main() {
        const {
            if false {
                let _:() = panic!();
            }
        }
    }
which compiles as expected. (Note that if the binding were `const` instead of `let`, it'd still have failed to compile, because the semantics don't change.)
judofyr•2h ago
This is one the reasons I find it so silly when people disregard Zig «because it’s just another memory unsafe language»: There’s plenty of innovation within Zig, especially related to comptime and metaprogramming. I really hope other languages are paying attention and steals some of these ideas.

«inline else» is also very powerful tool to easily abstract away code with no runtime cost.

Ygg2•2h ago
> «inline else» is also very powerful tool to easily abstract away code with no runtime cost.

Sure, but you lose the clarity of errors. The error wasn't in `comptime unreachable` but in `inline .a .b .c`.

jeltz•2h ago
I disagree, I would say the error is in "comptime unreachable" or maybe the whole "switch (ab)".
binary132•1h ago
Adding a new case is legitimate, failing to handle it (by reaching unreachable) is an error.
diegocg•2h ago
As someone who uses D and has been doing things like what you see in the post for a long time, I wonder why other languages would put attention to these tricks and steal them when they have been completely ignoring them forever when done in D. Perhaps Zig will make these features more popular, but I'm skeptic.
brabel•1h ago
I was trying to implement this trick in D using basic enum, but couldn't find a solution that works at compile-time, like in Zig. Could you show how to do that?
chrismorgan•1h ago
What I’ve seen isn’t people disregarding Zig because it’s just another memory-unsafe language, but rather disqualifying Zig because it’s memory-unsafe, and they don’t want to deal with that, even if some other aspects of the language are rather interesting and compelling. But once you’re sold on memory safety, it’s hard to go back.
Sytten•1h ago
This is really the crust of the argument. I absolutely love the Rust compiler for example, going back to Zig would feel a regression to me. There is a whole class of bugs that my brain now assumes the compiler will handle for me.
pron•58m ago
Problem is, like they say the stock market has predicted nine of the last five recessions, the Rust compiler stops nine of every five memory safety issues. Put another way, while both Rust and Zig prevent memory safety issues, Zig does it with false negatives while Rust does it with false positives. This is by necessity when using the type system for that job, but it does come at a cost that disqualifies Rust for others...

Nobody knows whether Rust and/or Zig themselves are the future of low-level programming, but I think it's likely that the future of low-level programming is that programmers who prefer one approach would use a Rust-like language, while those who prefer the other approach would use a Zig-like language. It will be intesting to see whether the preferences are evenly split, though, or one of them has a clear majority support.

tialaramex•4m ago
C++ already illustrates this idea you're talking about and we know exactly where this goes. Rust's false positives are annoying, so programmers are encouraged to further improve the borrowck and language features to reduce them. But the C++ or Zig false negatives just means your program malfunctions in unspecified ways and you may not even notice, so programmers are encouraged to introduce more and more such cases to the compiler.

The drift over time is predictable, compared to ten years ago Rust has fewer false positives, C++ has more false negatives.

You are correct to observe that there is no middle choice here, that's Rice's Theorem, non-trivial semantic correctness is Undecidable. But I would argue we already know what you're calling the "false positive" scenario is also not useful, we're just not at the point where people stop doing it anyway.

pron•1h ago
> just another memory unsafe language

Also, treating all languages that don't ensure full memory safety as if they're equally problematic is silly. The reason not ensuring memory safety is bad is because memory unsafety as at the root of some bugs that are both common, dangerous, and hard to catch. Only not all kinds of memory unsafety are equally problematic, Zig does ensure the lack of the the most dangerous kind of unsafety (out-of-bounds access) while making the other kind (use-after-free) easier to find.

That the distinction between "fully memory safe" and "not fully memory safe" is binary is also silly not just because of the above, but because no lanugage, not even Java, is truly "fully memory safe", as programs continue to employ components not written in memory safe languages.

Furthermore, Zig has (or intends to have) novel features (among low-level languages) that help reduce bugs beyond those caused by memory unsafety.

veber-alex•40m ago
I don't understand. Isn't this only useful if the value you match on is known at compile time?