Hacker News new | past | comments | ask | show | jobs | submit login

> I have worse news for you about C or C++ or anything that isn't typed exclusively based on how wide its register is

I would be interested in hearing this nitpicking, I know little about C or C++




Honestly, if I'm going to nitpick myself, even that isn't a true statement. You might have an integer/float divide for your registers, like amd64 does, but even past that it's squishy and becomes human bookkeeping or compiler magic. Is %rax an 8-byte integer, or is it a pointer? Or is it garbage because you used %eax (the lower 4 bytes of %rax) for storing a 4-byte integer, and the top half is whatever(tm)? Ditto again for %ax (2-byte) or %al (1-byte). You have widths, but me calling them types was really even a stretch there.

And then everything else is just built from that, really. Strings/arrays? Either length+bytes/charpoints (hope you counted correctly) or "bytes/charpoints until you hit a NUL" (hope you put the NUL in or now your buffers are spewing somewhere they shouldn't). Structs? Pile of bytes, each of them special-cased by the compiler. (A polymorphic class would then have some virtual function tables somewhere too.) And if your language has a fixed-point decimal class, it's time to get weird.

Types are a really convenient, really helpful concept, but to sniff at them being compiler-only in something like TypeScript or typed Python is IMO misguided--because compilers have gotten pretty smart and it allows us to reasonably make flexibility tradeoffs because those compilers are good at doing things. Java will scream at runtime if I cast an object to something it can't be, and that's great, but also, I just won't do that if I validated my inputs in Python with something like Pydantic or TypeScript with something like Zod or Typebox or whatever, because an illegal action with a type becomes a compiler error. So, IMO, let's get over the argument and get back to making stuff. (Even the Golang people. All is forgiven, mostly.)


The problem with Python specifically is that the type system is such a massive bolted-on hack. It has to be, because it's such a dynamic language that all declarations and imports are executable statements - and it's hard to reconcile it with type declarations, which often need to be mutually recursive.

TypeScript is much better in that regard, though.


It is kind of hacky for sure, but I've gotten way more productive with it than I've ever been with Python before. Like I went my entire career (and time before that) where the words that came out of my mouth after "Python" were "is bullshit", but this year due to both AI jank and other unrelated tools having no path but Python, I've made my peace with it--and yeah it's spotty, though with Pylance I think it's fine, and it saves me from so many category errors that make old-Python infuriating.

Unfortunately for me, as an unreconstructed Ruby dork, Sorbet does not scratch the same itch. :(




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: