frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

France's homegrown open source online office suite

https://github.com/suitenumerique
105•nar001•1h ago•50 comments

Start all of your commands with a comma (2009)

https://rhodesmill.org/brandon/2009/commands-with-comma/
345•theblazehen•2d ago•117 comments

Hoot: Scheme on WebAssembly

https://www.spritely.institute/hoot/
50•AlexeyBrin•2h ago•10 comments

OpenCiv3: Open-source, cross-platform reimagining of Civilization III

https://openciv3.org/
735•klaussilveira•17h ago•230 comments

Reinforcement Learning from Human Feedback

https://arxiv.org/abs/2504.12501
29•onurkanbkrc•2h ago•2 comments

The Waymo World Model

https://waymo.com/blog/2026/02/the-waymo-world-model-a-new-frontier-for-autonomous-driving-simula...
990•xnx•22h ago•562 comments

Coding agents have replaced every framework I used

https://blog.alaindichiappari.dev/p/software-engineering-is-back
75•alainrk•2h ago•71 comments

Vocal Guide – belt sing without killing yourself

https://jesperordrup.github.io/vocal-guide/
115•jesperordrup•7h ago•53 comments

Unseen Footage of Atari Battlezone Arcade Cabinet Production

https://arcadeblogger.com/2026/02/02/unseen-footage-of-atari-battlezone-cabinet-production/
84•videotopia•4d ago•17 comments

Making geo joins faster with H3 indexes

https://floedb.ai/blog/how-we-made-geo-joins-400-faster-with-h3-indexes
144•matheusalmeida•2d ago•39 comments

Ga68, a GNU Algol 68 Compiler

https://fosdem.org/2026/schedule/event/PEXRTN-ga68-intro/
24•matt_d•3d ago•5 comments

Show HN: Look Ma, No Linux: Shell, App Installer, Vi, Cc on ESP32-S3 / BreezyBox

https://github.com/valdanylchuk/breezydemo
247•isitcontent•17h ago•27 comments

Cross-Region MSK Replication: K2K vs. MirrorMaker2

https://medium.com/lensesio/cross-region-msk-replication-a-comprehensive-performance-comparison-o...
6•andmarios•4d ago•1 comments

Monty: A minimal, secure Python interpreter written in Rust for use by AI

https://github.com/pydantic/monty
257•dmpetrov•17h ago•136 comments

Show HN: Kappal – CLI to Run Docker Compose YML on Kubernetes for Local Dev

https://github.com/sandys/kappal
6•sandGorgon•2d ago•2 comments

Show HN: I spent 4 years building a UI design tool with only the features I use

https://vecti.com
350•vecti•19h ago•157 comments

Hackers (1995) Animated Experience

https://hackers-1995.vercel.app/
518•todsacerdoti•1d ago•252 comments

Sheldon Brown's Bicycle Technical Info

https://www.sheldonbrown.com/
400•ostacke•23h ago•104 comments

What Is Ruliology?

https://writings.stephenwolfram.com/2026/01/what-is-ruliology/
52•helloplanets•4d ago•51 comments

Show HN: If you lose your memory, how to regain access to your computer?

https://eljojo.github.io/rememory/
316•eljojo•20h ago•196 comments

Microsoft open-sources LiteBox, a security-focused library OS

https://github.com/microsoft/litebox
365•aktau•23h ago•189 comments

An Update on Heroku

https://www.heroku.com/blog/an-update-on-heroku/
445•lstoll•23h ago•293 comments

Dark Alley Mathematics

https://blog.szczepan.org/blog/three-points/
99•quibono•4d ago•26 comments

PC Floppy Copy Protection: Vault Prolok

https://martypc.blogspot.com/2024/09/pc-floppy-copy-protection-vault-prolok.html
79•kmm•5d ago•12 comments

How to effectively write quality code with AI

https://heidenstedt.org/posts/2026/how-to-effectively-write-quality-code-with-ai/
285•i5heu•20h ago•238 comments

Female Asian Elephant Calf Born at the Smithsonian National Zoo

https://www.si.edu/newsdesk/releases/female-asian-elephant-calf-born-smithsonians-national-zoo-an...
48•gmays•12h ago•21 comments

Was Benoit Mandelbrot a hedgehog or a fox?

https://arxiv.org/abs/2602.01122
26•bikenaga•3d ago•15 comments

I spent 5 years in DevOps – Solutions engineering gave me what I was missing

https://infisical.com/blog/devops-to-solutions-engineering
162•vmatsiiako•22h ago•73 comments

I now assume that all ads on Apple news are scams

https://kirkville.com/i-now-assume-that-all-ads-on-apple-news-are-scams/
1098•cdrnsf•1d ago•479 comments

Introducing the Developer Knowledge API and MCP Server

https://developers.googleblog.com/introducing-the-developer-knowledge-api-and-mcp-server/
70•gfortaine•15h ago•29 comments
Open in hackernews

When compilers surprise you

https://xania.org/202512/24-cunning-clang
244•brewmarche•1mo ago

Comments

dejj•1mo ago
It’s neat. I wonder if someone attempted detecting a graph coloring problem to replace it with a constant.
emih•1mo ago
Graph coloring is NP-hard so it would be very difficult to replace it with an O(1) algorithm.

If you mean graph coloring restricted to planar graphs, yes it can always be done with at most 4 colors. But it could still be less, so the answer is not always the same.

(I know it was probably not a very serious comment but I just wanted to infodump about graph theory.)

andrepd•1mo ago
I'm actually surprised that gcc doesn't do this! If there's one thing compilers do well is pattern match on code patterns and replace with more efficient ones; just try pasting things from Hacker's Delight and watch it always canonicalise it to the equivalent, fastest machine code.
nikic•1mo ago
This particular case isn't really due to pattern matching -- it's a result of a generic optimization that evaluates the exit value of an add recurrence using binomial coefficients (even if the recurrence is non-affine). This means it will work even if the contents of the loop get more exotic (e.g. if you perform the sum over x * x * x * x * x instead of x).
f1shy•1mo ago
Doing something like that with a pattern is obvious, but also useless, as it will catch very limited cases. The example presented, is known there is a closed form (it’s believed Gauss even discovered it being 6 yo). I’m sure this optimization will catch many other things, so is not trivial at all.
morkalork•1mo ago
First time I encountered that book was seeing it on the desk of a compiler engineer.
g0wda•1mo ago
If you now have a function where you call this one with an integer literal, you will end up with a fully inlined integer answer!
loeg•1mo ago
Could do that whether SCEV’d or not with C++20 consteval, lol.
JonChesterfield•1mo ago
That one is called scalar evolution, llvm abbreviates it as SCEV. The implementation is relatively complicated.
gslin•1mo ago
More similar optimizations: https://matklad.github.io/2025/12/09/do-not-optimize-away.ht...
Lvl999Noob•1mo ago
Couldn't the compiler optimise this still? Make two versions of the function, one with constant folding and one without. Then at runtime, check the value of the parameter and call the corresponding version.
saagarjha•1mo ago
Yes, a sufficiently smart compiler can always tell you’re doing a benchmark and delete it. It’s just unlikely.
wging•1mo ago
The beginning of that article is slightly wrong: the compiler should compute N(N-1)/2 (and does), because the original code adds up all the numbers from 0 to N excluding N. The usual formulation in math includes the upper bound: the sum of integers from 1 to N, including N, is N(N+1)/2, so you have to replace N by (N-1) if you want a formula for the sum where the last number is N-1.
phplovesong•1mo ago
This exact content was posted a few months ago. Is this AI or just a copy paste job?
mattgodbolt•1mo ago
This exact content was only posted today? :)
ForceBru•1mo ago
You're probably thinking of another post (https://xania.org/202512/11-pop-goes-the-weasel-er-count) where an entire loop was optimized to a single instruction
dist-epoch•1mo ago
> I love that despite working with compilers for more than twenty years, they can still surprise and delight me.

This kind of optimization, complete loop removal and computing the final value for simple math loops, is at least 10 years old.

nebezb•1mo ago
Learning something old can be surprising. Enjoying that learning can be delightful.

Seems like the author is both surprised and delighted with an optimization they learned of today. Surely you’ve been in the same situation before.

f1shy•1mo ago
10 years is not a lot. Is almost “yesterday” things being done in a field 10 years old, can still surprise experts in the field. With 30+ years experience I still find relatively new things, that are maybe 15 yo.

In topics like compiler optimization, is not like there are many books which describe this kind of algorithms.

bumholes•1mo ago
The code that does this is here, if anyone is curious:

https://github.com/llvm/llvm-project/blob/release/21.x/llvm/...

https://github.com/llvm/llvm-project/blob/release/21.x/llvm/...

vodou•1mo ago
Almost 16000 lines in a single source code file. I find this both admirable and unsettling.
zahlman•1mo ago
I do too, but I'm pretty sure I've seen worse.
loeg•1mo ago
Does it really matter where the lines are? 16,000 lines is still 16,000 lines.
vodou•1mo ago
Even though I do find your indifference refreshing I must say: it does matter for quite a few people.
MobiusHorizons•1mo ago
If you don’t rely on IDE features or completion plugins in an editor like vim, it can be easier to navigate tightly coupled complexity if it is all in one file. You can’t really scan it or jump to the right spot as easily as smaller files, but in vim searching for the exact symbol under the cursor is a single character shortcut, and that only works if the symbol is in the current buffer. This type of development works best for academic style code with a small number (usually one or two) experts that are familiar with the implementation, but in that context it’s remarkably effective. Not great for merge conflicts in frequently updated code though.
godelski•1mo ago

  > but in vim searching for the exact symbol under the cursor is a single character shortcut
* requires two key presses which is identical to <C-]> or g]

https://kulkarniamit.github.io/whatwhyhow/howto/use-vim-ctag...

neerajsi•1mo ago
If you want recognize all the common patterns, the code can get very verbose. But it's all still just one analysis or transformation, so it would be artificial to split into multiple files. I haven't worked much in llvm, but I'd guess that the external interface to these packages is pretty reasonable and hides a large amount of the complexity that took 16kloc to implement
afiori•1mo ago
Part of the issue is that it suggests that the code had a spaghettified growth; it is neither sufficient nor necessary but lacking external constraints (like an entire library developed as a single c header) it suggests that code organisation is not great.
anon291•1mo ago
Hardware is often spaghetti anyway. There are a large number of considerations and conditions that can invalidate the ability to use certain ops, which would change the compilation strategy.

The idea of good abstractions and such falls apart the moment the target environment itself is not a good abstraction.

afiori•1mo ago
I was not expressing an opinion on giant files, I was just postulating on why people dislike them.
jiggawatts•1mo ago
... yes.

If it was 16K lines of modular "compositional" code, or a DSL that compiles in some provably-correct way, that would make me confident. A single file with 16K lines of -- let's be honest -- unsafe procedural spaghetti makes me much less confident.

Compiler code tends to work "surprisingly well" because it's beaten to death by millions of developers throwing random stuff at it, so bugs tend to be ironed out relatively quickly, unless you go off the beaten path... then it rapidly turns out to be a mess of spiky brambles.

The Rust development team for example found a series of LLVM optimiser bugs related to (no)aliasing, because C/C++ didn't use that attribute much, but Rust can aggressively utilise it.

I would be much more impressed by 16K lines of provably correct transformations with associated Lean proofs (or something), and/or something based on EGG: https://egraphs-good.github.io/

mananaysiempre•1mo ago
On the other end of the optimizer size spectrum, a surprising place to find a DSL is LuaJIT’s “FOLD” stage: https://github.com/LuaJIT/LuaJIT/blob/v2.1/src/lj_opt_fold.c (it’s just pattern matching, more or less, that the DSL compiler distills down to a perfect hash).
j-o-m•1mo ago
I find the real question: are all 16,000 of those lines require to implement the optimization? How much of that is dealing with LLVM’s internal representation and the varying complexity of LLVM’s other internal structure?
loeg•1mo ago
What would it mean to implement the optimization without dealing with LLVM's internal structure? Optimizations don't exist in a vacuum.
bitwizeshift•1mo ago
Thank you, bumholes
vatsachak•1mo ago
Compilers can add way more closed forms. Would it be worth it?

https://en.wikipedia.org/wiki/Wilf%E2%80%93Zeilberger_pair

j16sdiz•1mo ago
The first thing I had in mind was: the final answer needed to be /2. keeping the number before dividing not overflowing needs some tedious work
trehalose•1mo ago
It's not very tedious. Instead of dividing the product by 2, you can just divide whichever of x or x+1 is even by 2 before multiplying.
Neywiny•1mo ago
I'm once again surprised at GCC being slower than clang. I would have thought that GCC, which had a 20? year head start would've made faster code. And yet, occasionally I look into the assembly and go "what are you doing?" And the same flags + source into clang is better optimized or uses better instructions or whatever. One time it was bit extraction using shifts. Clang did it in 2 steps: shift left, shift right. GCC did it in 3 I think? I think it maybe shifted right first or maybe did a logical instead of arithmetic and then sign extended. Point is, it was just slower.
stmw•1mo ago
Compiler know-how and resources available during compilations made very signicant progress between gcc and LLVM/clang era.

gcc was and is an incredible achievement, but it is traditionally considered difficult to implement many modern compiler techqniques in it. It's at least unpleasant, let's put it this way.

uecker•1mo ago
Not sure whether this is generally true. GCC appears to have similar optimizations and I personally find LLVM's code much more intimidating. But it is certainly true that LLVM seems to see more investment. I assume the license may also play a role. For comparison, here is some related code:

https://github.com/gcc-mirror/gcc/blob/master/gcc/tree-chrec... https://github.com/llvm/llvm-project/blob/release/21.x/llvm/...

saagarjha•1mo ago
GCC has almost the same modern compiler techniques implemented.
fweimer•1mo ago
Did it involve bitfields? GCC is notoriously bad at optimizing them. There are some target-specific optimizations, but pretty much nothing in the middle-end.
Neywiny•1mo ago
It did, yes. On an architecture without bit field extracts.
saagarjha•1mo ago
GCC and Clang are largely similar when it comes to performance as each implements passes the other does not. It’s always possible to find examples where they optimize a piece of code differently and one comes out ahead of the other.
userbinator•1mo ago
I'm not. GCC started out as a work of idealistic licensing purists and was deliberately "obfuscated" to make it hard to extend and embed. That stance has since been softened considerably, but the code generator is still far more complex than it needs to be, and I think that has made it harder to modify for efficiency. Clang is far less ideology-focused and its structure makes implementing optimisations easier.

On the other hand, I find MSVC and especially ICC output to be quite decent, although I have never seen their source code.

Having inspected the output of compilers for several decades, it's rather easy to tell them apart.

tester756•1mo ago
A lot of hardcoding, making expression consistent, e.g transforming a+3 into 3+a for easier pattern matching
vardump•1mo ago
Only thing that surprised me was that GCC didn't manage to optimize it. I expected it to be able to do so.
MobiusHorizons•1mo ago
I will admit I was initially surprised Matt was not already familiar with this behavior given his reputation. I remember discovering it while playing with llvm intermediate representation 10 years ago in college. I would never have considered myself very knowledgeable about modern compilers, and have never done any serious performance work. In that case it had solved a recursion to a simple multiplication, which completely surprised me. The fact that Matt did not know this makes me think this pass may only work on relatively trivial problems that he would never have written in the first place, and therefore never have witnessed the optimization.
pwdisswordfishy•1mo ago
He was: he brought up the very same example in a talk in 2017.

https://www.youtube.com/watch?v=bSkpMdDe4g4&t=2640

MobiusHorizons•1mo ago
Ah that makes much more sense. I guess he means the optimization is surprising when you first discover it, which it certainly was for me!
WalterBright•1mo ago
These sorts of things are fun and interesting. Compiler optimizations fall into two categories:

1. organized data flow analysis

2. recognizing a pattern and replacing it with a faster version

The first is very effective over a wide range of programs and styles, and is the bulk of the actual transformations. The second is a never-ending accumulation of patterns, where one reaches diminishing returns fairly quickly.

The example in the linked article is very clever and fun, but not really of much value (I've never written a loop like that in 45 years). As mentioned elsewhere "Everyone knows the Gauss Summation formula for sum of n integers i.e. n(n+1)/2" and since everyone knows it why not just write that instead of the loop!

Of course one could say that for any pattern, like replacing i*2 with i<<1, but those pattern replacements are very valuable because they are generated by high level generic coding.

And you could say I'm just being grumpy about this because my optimizer does not do this particular optimization. Fair enough!

Validark•1mo ago
It might have more value than you think. If you look up SCEV in LLVM you'll see it's primarily used for analysis and it enables other optimizations outside of math loops that, by themselves, probably don't show up very often.
WalterBright•1mo ago
You might be right.
gizmo686•1mo ago
It's not clear to me what optimizations the compiler actually did here. Years ago, I worked on a niche compiler, and was routinely surprised by what the optimizer was able to figure out; despite having personally written most of the optimization transformations myself.
steveklabnik•1mo ago
I can't actually speak to the specifics here but usually this is "idiom recognition", that is, it just notices that the pattern is there and transforms it directly.
lucyjojo•1mo ago
isn't that kind of stuff mostly useful for generated code?
WalterBright•1mo ago
One recognizes different patterns for both the intermediate representation and the generated code.
jojomodding•1mo ago
The point is not really that the compiler is able to spot the Gaussian sum. It uses a general infrastructure to turn many "math loops" that sum/multiply numbers into closed-form solutions. This handles Gauss but is much more general. In turn it allows you to write simple code that still does the right thing, instead of a complicated-looking large multiplication with a bunch of random-seeming constants.
Animats•1mo ago
That's neat.

A hard problem in optimization today is trying to fit code into the things complex SSE-type instructions can do. Someone recently posted an example where they'd coded a loop to count the number of one bits in a word, and the compiler generated a "popcount" instruction. That's impressive.

mattgodbolt•1mo ago
It may be a different post, but I covered this earlier this month in the same series of blog posts/YouTube videos.
Validark•1mo ago
What's actually way cooler about this is that it's generic. Anybody could pattern match the "sum of a finite integer sequence" but the fact that it's general purpose is really awesome.
cjdell•1mo ago
This is really bluring the line between implementation and specification. You may think you're writing the implementation but it is really a proxy for the specification. In other words, the compiler creating an illusion of an imperative machine.