frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

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

https://openciv3.org/
616•klaussilveira•12h ago•180 comments

The Waymo World Model

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

What Is Ruliology?

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

How we made geo joins 400× faster with H3 indexes

https://floedb.ai/blog/how-we-made-geo-joins-400-faster-with-h3-indexes
105•matheusalmeida•1d ago•26 comments

Jeffrey Snover: "Welcome to the Room"

https://www.jsnover.com/blog/2026/02/01/welcome-to-the-room/
8•kaonwarb•3d ago•2 comments

Unseen Footage of Atari Battlezone Arcade Cabinet Production

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

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

https://github.com/valdanylchuk/breezydemo
214•isitcontent•12h ago•25 comments

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

https://github.com/pydantic/monty
207•dmpetrov•12h ago•102 comments

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

https://vecti.com
319•vecti•14h ago•141 comments

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

https://github.com/microsoft/litebox
356•aktau•19h ago•181 comments

Sheldon Brown's Bicycle Technical Info

https://www.sheldonbrown.com/
367•ostacke•18h ago•94 comments

Hackers (1995) Animated Experience

https://hackers-1995.vercel.app/
474•todsacerdoti•20h ago•232 comments

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

https://eljojo.github.io/rememory/
270•eljojo•15h ago•159 comments

Vocal Guide – belt sing without killing yourself

https://jesperordrup.github.io/vocal-guide/
13•jesperordrup•2h ago•4 comments

An Update on Heroku

https://www.heroku.com/blog/an-update-on-heroku/
400•lstoll•18h ago•271 comments

Delimited Continuations vs. Lwt for Threads

https://mirageos.org/blog/delimcc-vs-lwt
25•romes•4d ago•3 comments

Dark Alley Mathematics

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

PC Floppy Copy Protection: Vault Prolok

https://martypc.blogspot.com/2024/09/pc-floppy-copy-protection-vault-prolok.html
56•kmm•4d ago•3 comments

How to effectively write quality code with AI

https://heidenstedt.org/posts/2026/how-to-effectively-write-quality-code-with-ai/
243•i5heu•15h ago•185 comments

Was Benoit Mandelbrot a hedgehog or a fox?

https://arxiv.org/abs/2602.01122
10•bikenaga•3d ago•2 comments

Introducing the Developer Knowledge API and MCP Server

https://developers.googleblog.com/introducing-the-developer-knowledge-api-and-mcp-server/
51•gfortaine•10h ago•17 comments

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

https://infisical.com/blog/devops-to-solutions-engineering
139•vmatsiiako•17h ago•61 comments

Understanding Neural Network, Visually

https://visualrambling.space/neural-network/
277•surprisetalk•3d ago•37 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/
1055•cdrnsf•21h ago•433 comments

Show HN: R3forth, a ColorForth-inspired language with a tiny VM

https://github.com/phreda4/r3
69•phreda4•12h ago•13 comments

Why I Joined OpenAI

https://www.brendangregg.com/blog/2026-02-07/why-i-joined-openai.html
128•SerCe•8h ago•113 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...
28•gmays•7h ago•10 comments

Learning from context is harder than we thought

https://hy.tencent.com/research/100025?langVersion=en
173•limoce•3d ago•94 comments

FORTH? Really!?

https://rescrv.net/w/2026/02/06/associative
62•rescrv•20h ago•22 comments

WebView performance significantly slower than PWA

https://issues.chromium.org/issues/40817676
30•denysonique•9h ago•6 comments
Open in hackernews

C++: Zero-cost static initialization

https://cofault.com/zero-cost-static.html
84•oecumena•6mo ago

Comments

pbsd•6mo ago
>Even after the static variable has been initialised, the overhead of accessing it is still considerable: a function call to __cxa_guard_acquire(), plus atomic_load_explicit(&__b_guard, memory_order::acquire) in __cxa_guard_acquire().

No. The lock calls are only done during initialization, in case two threads run the initialization concurrently while the guard variable is 0. Once the variable is initialized, this will always be skipped by "je .L3".

menaerus•6mo ago
Right, I was scratching my head exactly for that reason too. Even if the analysis was correct it would still be a solution for the problem that doesn't exist.
ot•6mo ago
That's a nice trick, but contrary to function statics, it is susceptible to SIOF. This kind of optimization is useful only on extraordinarily hot paths, so I wouldn't generally recommend it.

> On ARM, such atomic load incurs a memory barrier---a fairly expensive operation.

Not quite, it is just a load-acquire, which is almost as cheap as a normal load. And on x86 there's no difference.

One thing where both GCC and Clang seem to be quite bad at is code layout: even in the example in the article, the slow path is largely inlined. It would be much better to have just a load, a compare, and a jump to the slow path in a cold section. In my experience, in some rare cases reimplementing the lazy initialization explicitly (especially when it's possible to use a sentinel value, thus doing a single load for both value and guard) did produce a noticeable win.

surajrmal•6mo ago
FDO/PGO seem to really improve optimizations for hot/cold functions. I wonder if it does the kind of thing you're suggesting.
ot•6mo ago
Not with any of the Clang versions I tried, but last time I checked it was a couple of years ago.
Someone•6mo ago
> That's a nice trick, but contrary to function statics, it is susceptible to SIOF.

For those (like me) who don’t recognize that abbreviation, “The static initialization order fiasco (ISO C++ FAQ) refers to the ambiguity in the order that objects with static storage duration in different translation units are initialized in” (https://en.cppreference.com/w/cpp/language/siof.html)

ot•6mo ago
Yes, thanks for the clarification, what I probably should have said is that the trick is basically syntactic sugar to declare a scoped global static variable, and as such it inherits all the problems of global static variables.
TuxSH•6mo ago
TIL about encapsulation symbols.

Why not just use constinit (iff applicable), construct_at, or lessen the cost with -fno-threadsafe-statics?

forrestthewoods•6mo ago
> For this we need a certain old, but little-known feature of UNIX linkers

STOP WRITING NON-PORTABLE CODE YOU BASTARDS.

The correct answer is, as always, “stop using mutable global variables you bastard”.

Signed: someone who is endlessly annoyed with people who incorrectly think Unix is the only platform their code will run on. Write standard C/C++ that doesn’t rely on obscure tricks. Your co-workers will hate you less.

spauldo•6mo ago
I tell my coworkers, "Hey, we need this coded up as a Windows service!" and I get crickets.

So I spin up a Debian VM and POSIX the hell out of it. If they dare to complain, I tell 'em to do their damn jobs and not leave all the hard stuff to the guy that only programs on UNIX.

forrestthewoods•6mo ago
Their tasks would be less hard if the UNIX guy would stop writing non-portable POSIX code =P
spauldo•6mo ago
That's what I know. I wasn't hired to program Windows machines, I was hired to program PLCs and SCADA systems. But every now and then something best done in .NET comes up and none of the Windows guys can get off their butts to do it. So then they get to whine about having to deal with Linux and I get to tell them to suck it up.

Sure, I could learn to program on Windows... Or I could pick up another PLC or SCADA platform that looks good on my resume. Guess which I choose to do?

forrestthewoods•6mo ago
I have nothing to nice to say in response. Good luck!
wasmperson•6mo ago
To be fair to your coworkers, coding a windows service and setting up logging for it is surprisingly complicated. I'm the only person at my place of work that can do it, and even then only if I can use a compile-to-native language or .NET.
jojobas•6mo ago
Every time someone ships successful code that's hard to port to Windows the world becomes a better place.
delta_p_delta_x•6mo ago
> Every time someone ships successful code that's hard to port to Windows

Until your boss tells you to port your so-far Linux-only code to Windows, and you run that struggle.

Signed, someone who spent the past year or so porting Linux code to Windows and macOS because the business direction changed and the company saw what was the money-maker.

P.S. Not the parent commenter, because I just realised they, too, had a paragraph beginning with 'signed, ...'

jojobas•6mo ago
Looks like you're complaining about too much job security. Also it's you choice to accept that task and make the world a slightly worse place again.
1718627440•6mo ago
Can you setup Windows to install WSL if it isn't there yet and then set it up, in a Windows installer?
forrestthewoods•6mo ago
Forcing Windows users to use WSL is generally a non-starter. That’s just not how things work. You can force someone to change their entire execution environment without further consequences.

If you only support WSL then you don’t support Windows, imho.

1718627440•6mo ago
I see were you are coming from, but programs also depend on an SQL server, a python installation or a Java instance. You also don't complain about device drivers, support for filesystems, the network stack and hooks to Windows Explorer.

In the end it is just part of the OS and a bunch of extra userspace programs. I mean nobody complains about the Windows Subsystem for Win32.

But yeah, you can just use a non-MS GNU/Windows implementation instead, do you like that better?

Is it possible though? Is it possible to have isolated WSLs (per programm)?

forrestthewoods•6mo ago
> Is it possible though? Is it possible to have isolated WSLs (per programm)?

Maybe. But my experience is that there is very little “program code” and it’s mostly “library code”.

And if you did have a program that required WSL and you followed the UNIX model of bash chaining programs then you’re now mandating the “meta program” be run under WSL.

I treat WSL as a hacky workaround for dealing with bad citizens. It’s not a desirable target environment. It exists as a gap stop until someone does it right. YMMV.

1718627440•6mo ago
> But my experience is that there is very little “program code” and it’s mostly “library code”.

Sorry I am confused, what does that refer to?

> you’re now mandating the “meta program” be run under WSL

As long as bash and the tools are in path, can't you run any program normally?

> WSL as a hacky workaround for dealing with bad citizens

Yes, but some parts are out of scope for C and you need to target the OS. Also f.e. passing around file descriptors and sockets are convenient.

delta_p_delta_x•6mo ago
We actually tried that at first.

The technical requirement of installing WSL before installing our software was already a non-starter, since most Windows users expect one installer or zip to do-it-all. WSL2 isn't (yet) like a C/C++/DirectX redistributable which can be plugged in as a dependency to a given program. Additionally our program is expected to work natively with Windows paradigms.

More critically, we work with high-performance filesystems. The performance impact of files going a round-trip through the Linux Plan9 driver, then through a Linux kernel context switch, into the kernel, and down into Hyper-V, and then up back through the Windows Plan9 driver was completely unacceptable. It was deemed worthwhile to rewrite targeting Windows natively. And even then it was only a partial rewrite: we ended up using MinGW because we had too much of a direct dependency on the pthread API.

vrighter•6mo ago
wsl also has the issue that when windows decides to auto update and there is a wsl update while there is a wsl instance running, it will just kill it right there and then to carry on with the update.

This has bitten me once when I was doing a distro upgrade and windows just killed the WSL vm midway.

1718627440•6mo ago
Even if I now MS Windows can be annoying (why I don't use it), I'm completely out-of-touch with the hoops MS Windows user have to jump to have a usable computer. This is kind-of also a disadvantage, because you can't anticipate bugs that you can't imagine.
CoolCold•6mo ago
just curious, what would be the business direction to "Linux-only code"? Don't need any trade secrets, just quick expression on the area/target auditory.

I.e. - I have tried WSLg (running GUI apps in WSL) but disabled it all together, as after running xclock and couple of things like that to ensure it works, I couldn't find any interest in running GUI apps on Linux.

I can somewhat imagine need for work purposes, if you are falling into some webdev area and need to run some tests against local browser, but that's different from my POV.

delta_p_delta_x•6mo ago
> what would be the business direction to "Linux-only code"

Deep interaction with Linux filesystem and kernel behaviour; we've done some intercepting and trampolining Linux syscalls in run-time, and tying it all up to cloud storage APIs.

We had to fundamentally re-architect some of our code to support macOS and Windows.

forrestthewoods•6mo ago
Attitudes like this are the absolute worst. Fellow HN readers, don’t be like this person.
hollerith•6mo ago
I'm not sure what to think. What argument do you have for your position?
forrestthewoods•6mo ago
Windows and *nix are different platforms. Writing crossplatform code is pretty easy and a solved problem. At least 99.5% of code can be platform agnostic. Only a few tiny bits are special.

My background is video games. Which is well known to be a Windows-first environment. I currently work on robotics. The vast majority of robotics ecosystem code is Unix only.

You know what is extremely useful for teleoperation? Virtual reality. You know what platform doesn’t have a way to do VR currently? Linux. Womp womp sad trombone. Mistakes were made.

It’s really easy and not hard to write crossplatform code. My experience is that Linux devs are by far the most resistant to this. It’s very annoying.

Should you care about Windows? I certainly think so. Linux still doesn’t have a good debugger (no, gdb/lldb) aren’t good. Quite frankly every Linux dev would be more productive if they supported Windows where debuggers exist and are decent. So really they’re just shooting themselves in the foot. IMHO.

hollerith•6mo ago
There are probably international traders who can tell a similar story with Linux replaced with "the US" and Windows replaced with "Russia", but I wouldn't consider that similar story to be an argument for ending the sanctions on Russia.

However, there is an important difference between the sanctions on Russia and the strategy of the pro-Linux "activist" that started this thread: namely, Windows is so heavily entrenched in the niche of enterprise IT that there is no significant chance of Linux's replacing it in that niche with the result that there is no realistic chance of a positive effect of this activism that might cancel out the negative effect you describe. So, I am tentatively in agreement with you.

jojobas•6mo ago
You're complicit with Windows living on, being long overdue in the landfill of computing history.
forrestthewoods•6mo ago
Disrespectfully disagree.
vrighter•6mo ago
When I'm writing software, I'm writing it for me, not anyone else. I use linux. If I decide to release anything I wrote, I am under no obligation, nor am I "ethically compelled" to make it cross platform. I wrote it for me. Use it or not.
ndanilov•6mo ago
Author here. This is part of SPDK-based server code. Transportability outside of UNIX (mostly Linux) is entirely irrelevant. By the way, the global variables here are immutable after the initialisation, that's the point.
menaerus•6mo ago
Unless you missed it from another comment in this thread, the optimization you made is based on a wrong assumption and misreading the asm code: "je .L3" will skip all the costs you consider.
foota•6mo ago
Funny enough I recently wrote my own hack using this linker feature in C, to implement an array of static counter definitions that can be declared anywhere and then written out (e.g., to prometheus) in one place.

Note that as I later found out, this doesn't work with Mac OS's linker, so you need to use some separate incantations for Mac OS.

haberman•6mo ago
I wrote a portable abstraction for this that works across Linux, MacOS, and Windows: https://github.com/protocolbuffers/protobuf/blob/4917ec250d3...

I call them "linker arrays". They are great when you need to globally register a set of things and the order between them isn't significant.

rockwotj•6mo ago
Looks similar to absl::NoDestructor

https://github.com/abseil/abseil-cpp/blob/master/absl/base/n...

Which is basically the only usage of std::launder I have seen

jandrewrogers•6mo ago
std::launder should probably be used more than it is in low-level code if you care about correctness, even though it doesn’t always bite you in the ass. It is a logical no-op. std::launder is a hint to the compiler to forget everything it thinks it knows about the type instance, sort of like marking it “volatile” only for a specific moment in time.

The use of std::launder should be more common than it is, I’ve seen a few bugs in optimized builds when not used, but compilers have been somewhat forgiving about not using it in places you should because it hasn’t always existed. Rigorous code should be using it instead of relying on the leniency of the compiler.

In database engine code it definitely gets used in the storage layers.

ot•6mo ago
`NoDestructor` just ensures that the destructor is not called on the wrapped object, but you still need to manage the lifetime. If you look at the example, its recommended usage is with a function static. In other words, it's a utility to implement leaky Meyers' singletons.

std::launder is a bit weird here. Technically it should be used every time you use placement new but access the object by casting the pointer to its storage (which NoDestructor does). However, very little code actually uses it. For example, every implementation of std::optional should use it? But when you do, it actually prevents important compiler optimizations that make std::optional a zero-cost abstraction (or it did last time I looked into this).

naruhodo•6mo ago
The rabbit hole I just went down is called C/C++ Statement Expressions [1] which are a GCC extension:

    #define FAST_STATIC(T) \
      *({ \
          \                                // statements separated by semicolons
          reinterpret_cast<T *>(ph.buf); \ // the value of the macro as a statement
       })
The reinterpret_cast<T*>(...) statement is a conventional C++ Expression Statement, but when enclosed in ({}), GCC considers the whole kit and kaboodle a Statement Expression that propagates a value.

There is no C equivalent, but in in C++, since C++11 you can achieve the same effect with lambdas:

    auto value = [](){ return 12345; }();
As noted in the linked SO discussion, this is analogous to a JS Immediately-Invoked Function Expression (IIFE).

[1] https://stackoverflow.com/questions/76890861/what-is-called-...

viralsink•6mo ago
Lambdas are not fully equivalent since return statements in statement expressions will return at the function level, whereas return statements in lambdas will only return at the lambda level.
quibono•6mo ago
Just for clarity, since I didn't understand on first reading.

    int foo() {
    int result = ({ 
        if (some_condition) 
            return -1;  // This returns from foo(), not just the statement expression
        42; 
    });
    // This line might never be reached
}
Someone•6mo ago
FTA:

“Dynamic initialization of a block-scope variable with static storage duration or thread storage duration is performed the first time control passes through its declaration

[…]

this would initialise everything correctly: by the time foo() is called, its b has already been initialised.”

I guess that means this trick can change program behavior, especially if the function containing the static is never called in a program’s execution.

kazinator•6mo ago
The way block scope statics are handled in C++ is a mistake. Block scope statics that don't depend on any non-static local variables should be initialized when the program starts up. E.g.:

  void fun(int arg)
  {
     static obj foo(arg);   // delayed until function called (dependency on arg)
     static obj bar();      // inited at program start (no dependency on arg)
  }
In other words, any static that can be inited at program startup should be, leaving only the troublesome cases that depend on run-time context.
cherryteastain•6mo ago
Why not just use constexpr in the second case?
kazinator•6mo ago
What if the object is to be mutable?
TuxSH•6mo ago
You use constinit. But this means constexpr constructor (easy with 2-phase init, not too much of a problem for singleton objects), and trivial destruction
kazinator•6mo ago
Does that guarantee that the static object is constructed before the first execution of the block?
TuxSH•6mo ago
Yes, it will be constructed at compile time. Not everything can be constinit.
bruce343434•6mo ago
In theory I agree, but in practice this just increases compile time by a lot, and we need to be able to manually toggle the code that gets executed at compile time.
kazinator•6mo ago
What?

Edit: what?

bruce343434•6mo ago
When every eligible piece of code becomes automatically constexpr, as you suggest, the compile time will just balloon. The code still needs to be compiled and executed, just all at once now. Optimization is one of those annoying problems for which we currently don't have the compute to fully bruteforce it. We need to be selective with which code is marked constexpr.
kazinator•6mo ago
> constexpr, as you suggest

I made no mention of constexpr.

Program start-up isn't compile time.

The idea is that since "static obj bar()" doesn't depend on anything in the function, it could in principle be moved outside of the function. So in actual fact, it can be treated that way by the loading semantics of the program (can be constructed without the function having to be called), except that the name bar is only visible inside the function.

I don't understand why C++ wouldn't have specified it this way going back to 1998, but that's just me.

ahartmetz•6mo ago
I think that would cause some surprising behavior changes for certain code changes, not something that C++ (or any language) needs more of.
kazinator•6mo ago
Which is why it should have been sorted out decades ago.
ahartmetz•6mo ago
I mean when making (apparently) small changes to the initialization of the static even in the proposed new system.