frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Zero-Cost POSIX Compliance: Encoding the Socket State Machine in Lean's Types

https://ngrislain.github.io/blog/2026-3-25-zerocost-posix-compliance-encoding-the-socket-state-machine-in-lean-4s-type-system/
24•ngrislain•2h ago

Comments

yjftsjthsd-h•1h ago
> Lean 4 offers a fourth option: make the bug unrepresentable at the type level, then erase the proof at compile time so the generated code is identical to raw C.

Couldn't you do that in a more conventional type/class system without using an actual proof system? Instead of there being a Socket type/class, just make a Socket_Fresh, Socket_Bound, Socket_Listening, Socket_Connected, and maybe Socket_Closed (not 100% sure, would have to think about whether that's a thing or not), each of which takes the previous in its constructor. Or does that make it too hard to use?

paulddraper•1h ago
The innovation is making that have zero runtime cost. (Though to be fair, I doubt the runtime cost is really significant...)
skavi•3m ago
Their suggestion is also zero runtime cost.
wk_end•53m ago
Lean doesn’t have any kind of substructural typing, does it? At a glance it looks like you need to manually (lexically) rebind the socket at each step in the operation, and there’s nothing stopping you from holding onto a socket in a now-invalid state and making mess of things, right?

Also, boo AI slop. If you’re going to use AI to help write your technical blog posts please please please edit out all the “No X. No Y. Just pure Z.” marketing-speak.

tczMUFlmoNk•25m ago
This is what I was thinking, too. Without some kind of linearity, `connect` et al. don't give the claimed guarantees if you can just reuse the old socket handle. Especially if it's aliased in a list or something. I was surprised to see this not mentioned at all in the section specifically dedicated to double-close prevention.

Likewise, with implicit weakening, nothing stops you from dropping the socket without closing it.

khaledh•44m ago
Interesting take on enforcing state machine rules using a proof system. I'm interested in this space, and have been developing a new programming language to enable typestate / state-machine representation at the type system level[0].

I don't know where it will end up on the spectrum of systems languages; it may end up being too niche or incomplete, but so far I think I'm scratching the right itch, at least for myself.

[0] https://github.com/khaledh/machina

e-dant•43m ago
This is cool stuff, but a nitpick: It’s not undefined behavior in the language sense in C to do socket ops on a bad file descriptor. It’s just an error from the kernel’s point of view, and the kernel will throw -errno at you.
diowldxiks•40m ago
Does this work in the face of state changing out from under the socket? I'm not super familiar with low level socket details but I'm thinking something like connect returning EINPROGRESS and you not knowing if the connection has completed. It may complete, it may fail, but during that time this state machine is invalid I think. It seems like strict logical programming like this gets much harder in the face of mutable state changing out from under the program, but that can probably be worked around with enough effort.
russdill•5m ago
This is a based on such a surface level understanding of one type of posix socket. Calling close twice on a socket is a normal allowed thing, particularly for non blocking sockets. Datagram sockets can be operated with bind, without bind, with connect and bind and with both called multiple times.

Flighty Airports

https://flighty.com/airports
125•skogstokig•2h ago•39 comments

Goodbye to Sora

https://twitter.com/soraofficialapp/status/2036532795984715896
450•mikeocool•7h ago•353 comments

I wanted to build vertical SaaS for pest control, so I took a technician job

https://www.onhand.pro/p/i-wanted-to-build-vertical-saas-for-pest-control-i-took-a-technician-job...
223•tezclarke•6h ago•89 comments

In Edison’s Revenge, Data Centers Are Transitioning From AC to DC

https://spectrum.ieee.org/data-center-dc
96•jnord•2h ago•98 comments

Show HN: I took back Video.js after 16 years and we rewrote it to be 88% smaller

https://videojs.org/blog/videojs-v10-beta-hello-world-again
243•Heff•9h ago•36 comments

Apple Business

https://www.apple.com/newsroom/2026/03/introducing-apple-business-a-new-all-in-one-platform-for-b...
536•soheilpro•11h ago•324 comments

Arm AGI CPU

https://newsroom.arm.com/blog/introducing-arm-agi-cpu
288•RealityVoid•9h ago•229 comments

Tell HN: Litellm 1.82.7 and 1.82.8 on PyPI are compromised

https://github.com/BerriAI/litellm/issues/24512
531•dot_treo•15h ago•385 comments

Zero-Cost POSIX Compliance: Encoding the Socket State Machine in Lean's Types

https://ngrislain.github.io/blog/2026-3-25-zerocost-posix-compliance-encoding-the-socket-state-ma...
24•ngrislain•2h ago•9 comments

A Compiler Writing Journey

https://github.com/DoctorWkt/acwj
41•ibobev•3h ago•1 comments

Transformers Are Bayesian Networks

https://arxiv.org/abs/2603.17063
27•Anon84•4d ago•16 comments

Algorithm Visualizer

https://algorithm-visualizer.org/
30•vinhnx•4d ago•3 comments

An Aural Companion for Decades, CBS News Radio Crackles to a Close

https://www.nytimes.com/2026/03/21/business/media/cbs-news-radio-appraisal.html
33•tintinnabula•3d ago•5 comments

Show HN: Email.md – Markdown to responsive, email-safe HTML

https://www.emailmd.dev/
232•dancablam•10h ago•56 comments

Wine 11 rewrites how Linux runs Windows games at kernel with massive speed gains

https://www.xda-developers.com/wine-11-rewrites-linux-runs-windows-games-speed-gains/
723•felineflock•8h ago•256 comments

What happened to GEM?

https://dfarq.homeip.net/whatever-happened-to-gem/
53•naves•4d ago•25 comments

Hypura – A storage-tier-aware LLM inference scheduler for Apple Silicon

https://github.com/t8/hypura
194•tatef•11h ago•75 comments

Show HN: Gemini can now natively embed video, so I built sub-second video search

https://github.com/ssrajadh/sentrysearch
276•sohamrj•12h ago•75 comments

Hypothesis, Antithesis, synthesis

https://antithesis.com/blog/2026/hegel/
218•alpaylan•11h ago•82 comments

How the world’s first electric grid was built

https://worksinprogress.co/issue/how-the-worlds-first-electric-grid-was-built/
62•zdw•4d ago•18 comments

Missile defense is NP-complete

https://smu160.github.io/posts/missile-defense-is-np-complete/
281•O3marchnative•14h ago•288 comments

Intel Device Modeling Language for virtual platforms

https://github.com/intel/device-modeling-language
3•transpute•3d ago•0 comments

Epoch confirms GPT5.4 Pro solved a frontier math open problem

https://epoch.ai/frontiermath/open-problems/ramsey-hypergraphs
423•in-silico•1d ago•620 comments

No Terms. No Conditions

https://notermsnoconditions.com
231•bayneri•11h ago•104 comments

Lago (YC S21) Is Hiring

https://getlago.notion.site/Lago-Product-Engineer-AI-Agents-for-Growth-327ef63110d280cdb030ccf429...
1•AnhTho_FR•9h ago

Epic Games to cut more than 1k jobs as Fortnite usage falls

https://www.reuters.com/legal/litigation/epic-games-said-tuesday-that-it-will-lay-off-more-than-1...
290•doughnutstracks•12h ago•449 comments

Data Manipulation in Clojure Compared to R and Python

https://codewithkira.com/2024-07-18-tablecloth-dplyr-pandas-polars.html
101•tosh•2d ago•29 comments

Nanobrew: The fastest macOS package manager compatible with brew

https://nanobrew.trilok.ai/
189•syrusakbary•15h ago•115 comments

ARM AGI CPU: Specs and SKUs

https://sbcwiki.com/docs/soc-manufacturers/arm/arm-silicon/
101•HeyMeco•9h ago•26 comments

Is anybody else bored of talking about AI?

https://blog.jakesaunders.dev/is-anybody-else-bored-of-talking-about-ai/
569•jakelsaunders94•6h ago•397 comments