4 ms·
> This is exactly how I felt moving from a Python codebase to Go. But you realize on the 100th or so Python stacktrace that it's worth the investment up front,
by timothycrosley 7y ago
> This is exactly how I felt moving from a Python codebase to Go. But you realize on the 100th or so Python stacktrace that it's worth the investment up front, if not for type safety alone.
Luckily, you don't have to choose between those two outcomes:
https://github.com/python/mypy https://github.com/python/mypy
- kissgyorgy 7y agoPython's optional type hints even with mypy are nowhere near strict/expressive than a statically typed language like Go. Type hints in Python are an afterthought and it shows in a lot of cases.
- timothycrosley 7y agoDo you have any concrete examples?
- emptysea 7y agoType hints in Python are IMO great and quite expressive! You can create sum types (a bit verbose but they are there). You can introspect them at run time and create things like pydantic[0] and fastapi[1]. Strict null checks with Optional[T] are great! Now I'm not too familiar with Go's type system, but with protocols, Unions, Optional[T] and other generics offered by MyPy[2] I'd wager the type system is __more__ expressive than Go. [0]: https://pydantic-docs.helpmanual.io https://pydantic-docs.helpmanual.io [1]: https://fastapi.tiangolo.com https://fastapi.tiangolo.com [2]: https://mypy.readthedocs.io/en/stable/protocols.html https://mypy.readthedocs.io/en/stable/protocols.html
- weberc2 7y agoThe type system is more expressive, but much clunkier and also it needs to be expressive to accommodate all of the weird things people do in Python (and you still can’t model SQLAlchemy types).