frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

The Big Oops in type systems: This problem extends to FP as well

https://danieltan.weblog.lol/2025/07/the-big-oops-in-type-systems-this-problem-extends-to-fp-as-well
45•ksymph•2d ago

Comments

dang•3h ago
Recent and related. Others?

The Big OOPs: Anatomy of a Thirty-Five Year Mistake - https://news.ycombinator.com/item?id=44612313 - July 2025 (181 comments)

The Big Oops: Anatomy of a Thirty-Five-Year Mistake [video] - https://news.ycombinator.com/item?id=44596554 - July 2025 (91 comments)

hackyhacky•2h ago
Maybe I'm just missing something, but the "domain expert" that is described here is just... a function? The big win in Clojure is apparently using code instead of types?

  (defn apply-shipping-rules [order]
    (cond-> order
      (and (= :premium (:customer-type order))
           (> (:order-total order) 100))
      (assoc :shipping-cost 0)))
sirwhinesalot•2h ago
Yes, the point of the article is that people should do this (as is common in Clojure) rather than try and encode the rules in the type system (be it as a class hierarchy or a sum type).
rjknight•2h ago
The "domain expert" is the business-person who is, it is suggested, more capable of reading and comprehending the Clojure code than the Haskell code.

Since there is an equivalence between types and propositions, the Clojure program also models a "type", in the sense that the (valid) inputs to the program are obviously constrained by what the program can (successfully) process. One ought, in principle, to be able to transform between the two, and generate (parts of) one from the other.

We do a limited form of this when we do type inference. There are also (more limited) cases where we can generate code from type signatures.

I think op's point is that the Clojure code, which lays the system out as a process with a series of decision points, is closer to the mental model of the domain expert than the Haskell code which models it as a set of types. This seems plausible to me, although it's obviously subjective (not all domain experts are alike!).

The secondary point is that the Clojure system may be more malleable - if you want to add a new state, you just directly add some code to handle that state at the appropriate points in the process. The friction here is indeed lower. But this does give up some safety in cases where you have failed to grasp how the system works; a type system is more likely to complain if your change introduces an inconsistency. The cost of that safety is that you have two representations of how the system works: the types and the logic, and you can't experiment with different logic in a REPL-like environment until you have fully satisfied the type-checker. Obviously a smarter system might allow the type-checker to be overridden in such cases (on a per-REPL-session basis, rather than by further editing the code) but I'm not aware of any systems that actually do this.

vips7L•1h ago
I honestly doubt a business person would be able to read Clojure. I’ve been programming for 15 years and it doesn’t make any sense to me.
senderista•1h ago
I've been reading and writing English for half a century and Chinese doesn't make any sense to me, so I doubt any ordinary human could read it.
vips7L•1h ago
That’s quite the false equivalence.
michaelsbradley•34m ago
How so?
hackyhacky•1h ago
> The secondary point is that the Clojure system may be more malleable - if you want to add a new state, you just directly add some code to handle that state at the appropriate points in the process.

That's all certainly possible. But the same could be said of Python or JS. So if the big point here is "we can model business decisions as code!", I fail to see the innovation because we've been doing that for 50 years. Nothing unique to Clojure.

You could even do it Haskell if you want: just store data as a Map of properties and values, emulating a JS object.

sirwhinesalot•2h ago
I agree with the article, but I will note that we have a great tool for this problem that is (or at least can be) "statically typed": the relational model. Databases are precisely what you want for this sort of problem (even better if it's Datalog and you can encode rules that derive relevant information).

Most mainstream languages are very poorly equipped to do relational modeling. ORMs are a disaster (object-relational mismatch) and you don't necessarily need an actual database running in the background.

Clojure's approach is superior to the class hierarchy or sum type solution for this sort of very loose business domain modelling, for the reasons stated in the article, but it's also a local optima, and so is the "fat struct" solution (which is the statically typed equivalent). Even entity component systems are but a shadow of the relational model.

jiehong•1h ago
It’s part of the answer (the business logic stays as functions as expressed in the article).

I’m glad people seem to have left behind the feeling that relational model is bad during the NoSQL era.

mcphage•1h ago
> I will note that we have a great tool for this problem that is (or at least can be) "statically typed": the relational model. Databases are precisely what you want for this sort of problem

Relational databases still lock you into a specific design, and trying to work contrary to how your application was designed 10-15 years ago leads to terrible performance, high costs, and bugs galore.

It may be better than other options, but it's still not exactly a solved problem.

rorylaitila•2h ago
I mostly agree. I have quipped once that I write "spaghetti and meatballs" code. The meatballs are the core domain objects, explicitly typed. The spaghetti is the business rules, untyped. With experience you get a good intuition where to draw the line. But the untyped code needs extensive testing.

Where I disagree with the article is on refactoring. It's identically hard both ways. Migrating to new business rules while simultaneously running the old and new system is the hard part. I don't find static typing helps or hurts me in particular. Compiler warnings are useful, but my unit tests catch the dynamic parts as well. Either way a lot breaks and often needs temporary scaffolding between the versions.

moomin•2h ago
I feel like this article is missing the point by a country mile. FP proponents very much know that requirements can change and wreak havoc with their type systems forcing them to change large numbers of likes. What the author is missing is that this is be welcomed and vastly preferable to the situation we find ourselves in with Python codebases where those lines still need updating but the code will happily run incorrectly if you fail to find them all. Switching off the alarm doesn’t stop the fire spreading.
fellowniusmonk•1h ago
A mereological nihilist will never have anything but primitive types.

Everything more complex than those building block aren't in reality a Type.

Reality doesn't consiste of: X type made up of these primitives and other defined sub-types and let's hide the primitives as far down as we can.

It's instead primitives arranged X wise.

Or mapped a little better to programming terminology: A Schema.

It's about having the mental model that complex types can be useful as an abstraction but they aren't real and aren't worth fighting for or defending.

Types are for devs, devs aren't for types.

jayd16•1h ago
It's supposed to break when your assumptions break. That's the whole point.
jiggawatts•38m ago
I’ve watched a few good talks by people that have coded this kind of thing at the maximum level of scale and complexity, such as Amazon’s checkout system.

The endgame of this problem always turns into some sort of “log of events” with loosely coupled subscribers.

A single state machine suffers from a combinatorial explosion of states as it has to handle every corner case, combinations of every scenario, etc…

What if a single shopping basket contains both a digital good and a physically shipped one? What if some items are shipped separately and/or delayed? Etc…

Instead the business rules are encoded into smaller state machines that listen to events on the log and pay attention only to relevant events. This avoids much of the complexity and allows the OOP types to remain relatively clean and stable over time.

Now the “digital goods” shipping handler can simply listen to events where “delivery=authorized” and “type=digital”, allowing it to ignore how the payment was authorised (or just store credit!) and ignore anything with physical shipping constraints.

It then writes an event that marks that line item in the shopping cart as “delivered”, allowing partial cancellations later, etc…

yehoshuapw•32m ago
while this does bring up a valid point,

"classic" sql databases are still safer for many things then mongodb.

it is easier to do away with types and constraints, but in many cases they do end up being important safeguards

dboreham•7m ago
The same abstract pattern exists with many (most?) annoying things in the computing field: people focus on solving problem #1 but it turns out there's a complementary problem #2 that is now worse, that they either didn't know about or didn't much care about.

Telo MT1

https://www.telotrucks.com/
320•turtleyacht•5h ago•278 comments

6 weeks of Claude Code

https://blog.puzzmo.com/posts/2025/07/30/six-weeks-of-claude-code/
169•mike1o1•2d ago•237 comments

Remote hosting for your telescope

https://www.sierra-remote.com/
16•gregorvand•2d ago•5 comments

The Art of Multiprocessor Programming 2nd Edition Book Club

https://eatonphil.com/2025-art-of-multiprocessor-programming.html
217•eatonphil•8h ago•32 comments

Browser extension and local backend that automatically archives YouTube videos

https://github.com/andrewarrow/starchive
105•fcpguru•6h ago•49 comments

We may not like what we become if A.I. solves loneliness

https://www.newyorker.com/magazine/2025/07/21/ai-is-about-to-solve-loneliness-thats-a-problem
314•defo10•11h ago•667 comments

AWS deleted my 10-year account and all data without warning

https://www.seuros.com/blog/aws-deleted-my-10-year-account-without-warning/
94•seuros•3h ago•43 comments

PixiEditor 2.0 – A FOSS universal 2D graphics editor

https://pixieditor.net/blog/2025/07/30/20-release/
103•ksymph•2d ago•9 comments

Anandtech.com now redirects to its forums

https://forums.anandtech.com/
89•kmfrk•9h ago•19 comments

At a Loss for Words: A flawed idea is teaching kids to be poor readers (2019)

https://www.apmreports.org/episode/2019/08/22/whats-wrong-how-schools-teach-reading
50•Akronymus•10h ago•62 comments

Online Collection of Keygen Music

https://keygenmusic.tk
152•mifydev•3d ago•33 comments

Helion begins work on Washington nuclear fusion plant

https://www.nucnet.org/news/microsoft-backed-fusion-company-begins-work-on-washington-nuclear-fusion-plant-7-4-2025
58•mpweiher•2d ago•39 comments

Helsinki records zero traffic deaths for full year

https://www.helsinkitimes.fi/finland/finland-news/domestic/27539-helsinki-records-zero-traffic-deaths-for-full-year.html
318•DaveZale•3d ago•221 comments

Show HN: NaturalCron – Human-Readable Scheduling for .NET (With Fluent Builder)

https://github.com/hugoj0s3/NaturalCron
9•hugoj0s3•9h ago•0 comments

The /o in Ruby regex stands for "oh the humanity "

https://jpcamara.com/2025/08/02/the-o-in-ruby-regex.html
110•todsacerdoti•7h ago•27 comments

Double-slit experiment holds up when stripped to its quantum essentials

https://news.mit.edu/2025/famous-double-slit-experiment-holds-when-stripped-to-quantum-essentials-0728
41•ColinWright•2d ago•16 comments

Great Question (YC W21) Is Hiring a VP of Engineering (Remote)

https://www.ycombinator.com/companies/great-question/jobs/ONBQUqe-vp-of-engineering
1•nedwin•5h ago

Show HN: WebGPU enables local LLM in the browser – demo site with AI chat

https://andreinwald.github.io/browser-llm/
103•andreinwald•8h ago•37 comments

Compressing Icelandic name declension patterns into a 3.27 kB trie

https://alexharri.com/blog/icelandic-name-declension-trie
186•alexharri•11h ago•71 comments

The Big Oops in type systems: This problem extends to FP as well

https://danieltan.weblog.lol/2025/07/the-big-oops-in-type-systems-this-problem-extends-to-fp-as-well
45•ksymph•2d ago•19 comments

A.I. researchers are negotiating $250M pay packages

https://www.nytimes.com/2025/07/31/technology/ai-researchers-nba-stars.html
140•jrwan•11h ago•230 comments

I tried living on IPv6 for a day

https://www.xda-developers.com/the-internet-isnt-fully-ipv6-ready/
49•speckx•2d ago•59 comments

Australia’s gains in wheat-farm productivity

https://www.reuters.com/investigations/less-rain-more-wheat-how-australian-farmers-defied-climate-doom-2025-07-29/
50•tiarafawn•3d ago•7 comments

Financial lessons from my family's experience with long-term care insurance

https://www.whitecoatinvestor.com/financial-lessons-father-long-term-care-insurance/
93•wallflower•8h ago•109 comments

A dive into open chat protocols

https://wiki.alopex.li/ADiveIntoOpenChat
69•Bogdanp•3d ago•9 comments

Hiding secret codes in light protects against fake videos

https://news.cornell.edu/stories/2025/07/hiding-secret-codes-light-protects-against-fake-videos
58•CharlesW•6h ago•51 comments

ThinkPad designer David Hill on unreleased models

https://www.theregister.com/2025/08/02/thinkpad_david_hill_interview/
140•LorenDB•9h ago•69 comments

OpenAI's "Study Mode" and the risks of flattery

https://resobscura.substack.com/p/openais-new-study-mode-and-the-risks
92•benbreen•2d ago•103 comments

Modeling open-world cognition as on-demand synthesis of probabilistic models

https://arxiv.org/abs/2507.12547
8•PaulHoule•2h ago•0 comments

Linear Types for Programmers (2023)

https://twey.io/for-programmers/linear-types/
34•marvinborner•5h ago•4 comments