▲ | viccis 3 days ago | |||||||||||||
>with a better type system than either Given Python's substantial improvements recently, I would put it far ahead of the structural typing done in Go, personally. | ||||||||||||||
▲ | diarrhea 3 days ago | parent | next [-] | |||||||||||||
Yes, Python is massively ahead there. The largest wart is that types can be out of sync with actual implementation, with things blowing up at runtime -- but so can Go with `any` and reflection. Python, for a number of years at this point, has had structural (!) pattern matching with unpacking, type-checking baked in, with exhaustiveness checking (depending on the type checker you use). And all that works at "type-check time". It can also facilitate type-state programming through class methods. Libraries like Pydantic are fantastic in their combination of ergonomics and type safety. The prime missing piece is sum types, which need language-level support to work well. Go is simplistic in comparison. | ||||||||||||||
| ||||||||||||||
▲ | slipperydippery 3 days ago | parent | prev | next [-] | |||||||||||||
Python with a library like Pydantic isn't bad—I wouldn't rate base Python as being near Go's level, at all, though you can get it up to something non-painful with libraries. Go (and lots of other languages...) wreck it on dependency management and deployment, though. :-/ As the saying goes, "it was easier to invent Docker than fix Python's tooling". | ||||||||||||||
| ||||||||||||||
▲ | falcojr 2 days ago | parent | prev | next [-] | |||||||||||||
Strong agree here. I learned Go after having worked in large typed Python code bases, and Go feels like a HUGE step backwards typing-wise. | ||||||||||||||
▲ | ansgri 3 days ago | parent | prev [-] | |||||||||||||
Python type system is very good. It’s enforcing it consistently that’s bad. Thankfully most new libraries are typed. |