frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

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

https://openciv3.org/
391•klaussilveira•5h ago•85 comments

The Waymo World Model

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

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

https://github.com/pydantic/monty
118•dmpetrov•5h ago•48 comments

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

https://github.com/valdanylchuk/breezydemo
131•isitcontent•5h ago•14 comments

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

https://vecti.com
234•vecti•7h ago•113 comments

Dark Alley Mathematics

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

A century of hair samples proves leaded gas ban worked

https://arstechnica.com/science/2026/02/a-century-of-hair-samples-proves-leaded-gas-ban-worked/
57•jnord•3d ago•3 comments

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

https://github.com/microsoft/litebox
302•aktau•11h ago•151 comments

Sheldon Brown's Bicycle Technical Info

https://www.sheldonbrown.com/
304•ostacke•11h ago•82 comments

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

https://eljojo.github.io/rememory/
160•eljojo•7h ago•121 comments

Hackers (1995) Animated Experience

https://hackers-1995.vercel.app/
377•todsacerdoti•13h ago•214 comments

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

https://github.com/phreda4/r3
44•phreda4•4h ago•7 comments

An Update on Heroku

https://www.heroku.com/blog/an-update-on-heroku/
305•lstoll•11h ago•230 comments

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

https://infisical.com/blog/devops-to-solutions-engineering
100•vmatsiiako•10h ago•33 comments

How to effectively write quality code with AI

https://heidenstedt.org/posts/2026/how-to-effectively-write-quality-code-with-ai/
167•i5heu•8h ago•127 comments

Learning from context is harder than we thought

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

Understanding Neural Network, Visually

https://visualrambling.space/neural-network/
223•surprisetalk•3d ago•29 comments

FORTH? Really!?

https://rescrv.net/w/2026/02/06/associative
36•rescrv•12h ago•17 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/
956•cdrnsf•14h ago•413 comments

PC Floppy Copy Protection: Vault Prolok

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

Introducing the Developer Knowledge API and MCP Server

https://developers.googleblog.com/introducing-the-developer-knowledge-api-and-mcp-server/
8•gfortaine•2h ago•0 comments

Evaluating and mitigating the growing risk of LLM-discovered 0-days

https://red.anthropic.com/2026/zero-days/
33•lebovic•1d ago•11 comments

I'm going to cure my girlfriend's brain tumor

https://andrewjrod.substack.com/p/im-going-to-cure-my-girlfriends-brain
30•ray__•1h ago•5 comments

Claude Composer

https://www.josh.ing/blog/claude-composer
97•coloneltcb•2d ago•68 comments

The Oklahoma Architect Who Turned Kitsch into Art

https://www.bloomberg.com/news/features/2026-01-31/oklahoma-architect-bruce-goff-s-wild-home-desi...
17•MarlonPro•3d ago•2 comments

Show HN: Smooth CLI – Token-efficient browser for AI agents

https://docs.smooth.sh/cli/overview
76•antves•1d ago•56 comments

Show HN: Slack CLI for Agents

https://github.com/stablyai/agent-slack
37•nwparker•1d ago•8 comments

How virtual textures work

https://www.shlom.dev/articles/how-virtual-textures-really-work/
23•betamark•12h ago•22 comments

Evolution of car door handles over the decades

https://newatlas.com/automotive/evolution-car-door-handle/
38•andsoitis•3d ago•61 comments

The Beauty of Slag

https://mag.uchicago.edu/science-medicine/beauty-slag
27•sohkamyung•3d ago•3 comments
Open in hackernews

C++: Maps on Chains

http://bannalia.blogspot.com/2025/07/maps-on-chains.html
47•signa11•7mo ago

Comments

gsliepen•6mo ago
It's a somewhat interesting article, but it doesn't say much. It starts with:

> Suppose we want to have a C++ map where the keys are disjoint

And then we do something that goes against the whole point of such a map:

> But what happens if we try to insert an interval which is not disjoint with those already in the map?

And the solution is:

> Implementation-wise, we just have to [throw an exception if we are] comparing partially overlapping intervals

Much more interesting would be to show how to implement a proper interval map.

Gupie•6mo ago
Why can't you use this for the comparison operator:

  bool operator<(const interval& x, const interval& y)
  {
     if x.min < y.min return true;
     if x.min > y.min return false;
     return x_max < y.max;
   }
mgaunard•6mo ago
better implemented as

    tie(x.min, x.max) < tie(y.min, y.max)
gsliepen•6mo ago
Or since C++20, just default operator<=>: https://en.cppreference.com/w/cpp/language/default_compariso...
Sharlin•6mo ago
That’s fine if you just need any well-defined SWO, but I presume the author needs this specific ordering for some algorithmic reason. Still, it’s pretty ugly for a comparator to be throwing.
z_open•6mo ago
Throwing a runtime error seems like an absurd solution compared to changing the comparison operator or using an unordered_map

What's wrong with x.min < y.min || (x. min == y.min && x.max < y. max)

gsliepen•6mo ago
That would indeed satisfy std::map, but then the question is, is that a useful ordering for intervals? To answer that, you need to define what you want to use the interval map for. If you want to be able to lookup in which unique interval a given value is, then you shouldn't have overlapping intervals to begin with. If you do allow overlapping intervals, a query could result in multiple intervals. Are lookups by value (not by interval) still O(log N) with that ordering?
monkeyelite•6mo ago
He’s just asserting he’s using the data structure in the way he wants to.
derriz•6mo ago
I don’t understand the point of this article. There is no requirement stated regarding the properties of the ordering - in fact there is no code at all that depends on the traversing the map elements in a particular order. So you can pick any ordering you want.

If the requirement is “use std::map to store items but prevent adding items to the map if they have a particular relationship to existing map keys”, then this is a terrible solution - std::map like maps and dictionaries in all programming language is not designed for this - it should never be an error to add a value associated with a key to a map instance. Hacking the ordering to implement a requirement like this is brittle, obscure and strange.

If this were proposed as a solution to the problem “design a data structure to store values keyed by intervals that prevents overlapping intervals”, then I would mark it very low.

dm270•6mo ago
I agree. This seems very unintuitive and would be a code smell in a review.
monkeyelite•6mo ago
> then I would mark it very low.

What would you do differently?

I would also assert if any overlapping intervals were inserted - it’s an invariant.

If it was static I would just sort and binary search, but with inserts this seems like a fine way to reuse the std::map.

Std templates are designed for this kind of thing - make a custom comparator, document why it works, wrap it in a typedef.

AlotOfReading•6mo ago
This is one of those cases where being able to name the problem helps. It's a discrete interval problem and is typically solved by a discrete interval tree.

Diets are a particularly clever solution to this:

https://web.engr.oregonstate.edu/~erwig/diet/

monkeyelite•6mo ago
That’s the same idea as putting intervals in map, an ordered tree.
derriz•6mo ago
Unless you know about the internal implementation of std::map, then abusing the ordering function (which is expected be a total order according to the std::map documentation - i.e. capable of comparing any two elements of the key space) to throw exception when the API for std::map is used in a way you want to block - is not a robust solution. This will probably work but there’s nothing that constrains std::map to be implemented as a RB tree.

Nor is it intuitive - given it relies on understanding how balanced trees are typically implemented.

An “optimized” implementation of std::map should be entitled, for example, to cache results of previous comparisons and exploit the transitive rule for total orders to avoid unnecessarily performing comparisons. Then this solution breaks.

I know whining about downvotes is frowned upon here but I’m surprised to having lost karma here. I’m making what I believe is a good faith argument and am happy to debate my position.

monkeyelite•6mo ago
> internal implementation of std::map > abusing the ordering function

That's the thing about C++. It's not abuse - any strict weak ordering is valid. You are follow the rules and it's guaranteed mathematically to produce correct results.

> capable of comparing any two elements of the key space

You get to define the domain of keys which is almost always a restriction of the possible bits of the key. For example, you can use floats as keys even though nan would break.

> Nor is it intuitive

Intuitive too often means "I haven't seen it before" which is a bias to not learn new approaches of programming. All sufficiently technical knowledge is unintuitive.

- it relies on understanding how balanced trees are typically implemented.

No it doesn't. It's documented API.

> exploit the transitive rule for total orders to avoid unnecessarily performing comparisons

Yes, the comparison must satisfy transitivity. This doesn't violate that.

> I know whining about downvotes is frowned upon here

I downvote low-quality, not to disagree (I did not downvote).

diath•6mo ago
This had bit me in the past with std::sort that made seemingly benign code randomly crash a live service, cppreference has a list of all the standard facilities that need to meet these requirements: https://en.cppreference.com/w/cpp/named_req/Compare.html
monkeyelite•6mo ago
what did you try to use as a comparison function?
diath•6mo ago
This was the original sort function (it was meant to force "last" to be first on the list after the sort which obviously violated the requirement):

  std::sort(entries.begin(), entries.end(), [&last] (const auto &a, const auto &b) {
    if (last && last->getID() == a.id) {
      return true;
    }

    return a.time < b.time;
  });
monkeyelite•6mo ago
Interesting… I’m sure you resolved this. But the textbook solution is:

1. std::find last

2. std::iter_swap(first, found)

3. std::sort(front + 1, back)

delifue•6mo ago
The correct way of storing disjoint intervals is to key by min endpoint of each interval and use ordered querying