NHacker Next
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
▲Union Types and Option Types (2025) (tibleiz.net)
p1necone 2 hours ago [-]
One simple but non obvious (at least to me) trick when implementing tagged unions: put the union discriminator/tag at the end, not the beginning - that way a pointer to a union is also a pointer to the value, no need to increment the pointer to point past the tag after discriminating.
beached_whale 1 hours ago [-]
when serializing these things it's generally going to be best to put the tag first though. That way it's cheap to figure out how to parse it.
ks2048 2 hours ago [-]
What is the best source for cross-language description of language features? Eg: “optional types”: which langs have them and how do they work? Same with “union types” etc.
DonaldPShimoda 33 minutes ago [-]
There's no single oracle for these things, unfortunately. One common citation is "Types and Programming Languages" by Benjamin Pierce (2002), but otherwise people generally just use the nomenclature of a specific language and hope cross-linguistic adventurers will figure it out. I think there's somewhat less variance with more modern languages, though, so in some ways it's less of an issue than it once was.
tylermk04 1 hours ago [-]
Rosetta code is often helpful. Not exactly for language features, necessarily: https://rosettacode.org/wiki/Monads/Maybe_monad
gnabgib 1 days ago [-]
(2025) And about CopperLang (203 points, 3 days ago, 120 comments) https://news.ycombinator.com/item?id=50308754
direwolf20 3 hours ago [-]
i read Onion Types
smnrchrds 34 minutes ago [-]
Philomena Cunk on Programming

https://www.youtube.com/shorts/XK_D7Z-cKZ4

budro 58 minutes ago [-]
Well poor design can require you to peel off multiple layers of optionals, and so they're often a significant smell just like onions are.
andyferris 44 minutes ago [-]
Shrek would argue the layers are a feature not a bug
SoleilAbsolu 2 hours ago [-]
So shallot be...
3 hours ago [-]
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 02:36:09 GMT+0000 (Coordinated Universal Time) with Vercel.