6 ms·
The whole Type thing in Python and all the workarounds to make Python type-safish looks and feels absolutely pathetic. I have no idea why a company like Faceboo
by dna_polymerase 7y ago
The whole Type thing in Python and all the workarounds to make Python type-safish looks and feels absolutely pathetic. I have no idea why a company like Facebook takes so much time to apologize for the inadequacy of Python as a programming language in the broader sense. Especially since they are utilizing a service based architecture they easily could make the switch to a language that actually supports types.
Also the obvious performance gains...
- deleted 7y ago[deleted]
- therealmarv 7y agoWhy this sounds pathetic (?) for a company like Facebook which essentially made their original backend PHP (!) type safe and compiled by developing their own sub language Hack and compilers HHVM around it. Python always supported dynamic types but on run time ;) and nowadays also static.
- Scarbutt 7y agoEspecially since they are utilizing a service based architecture They articles says it is mostly a monolith with several millions line of code.
- joshuamorton 7y agoPython does support types though. It's type system is, imo more pleasant and powerful than Javas.
- rytill 7y agoCan you elaborate on this? I’d love to actually use types in Python.
- acemarke 7y agoPython 3 has optional static typing: https://docs.python.org/3/library/typing.html https://docs.python.org/3/library/typing.html https://realpython.com/python-type-checking/ https://realpython.com/python-type-checking/
- nurettin 7y agoStatic typing is exactly what python doesn't have. It will remain dynamically typed. It has type hints which can be used with external tools to enforce type correctness to some degree, but python code will run even if you assign: def f(x: int): x = "str" f(42)
- joshuamorton 7y agoThis is true of java and c as well. You can cast things or subvert the type system and the code will still run. At least where I work, my build process prevents me from running Python code with invalid type annotations, so it's exactly the same as for Java is cpp or any other statically typed language.
- nurettin 7y agoIn my opinion, the main difference between the two from a developer's perspective is this; You can't grep for dynamic type errors. You can grep for a cast to see where you've made a mistake and find a way to do it without a cast. This of course goes for the named casts in C++. It is harder to grep for casts in C.
- joshuamorton 7y agoRight, but if you run mypy over your code, you're in the same situation as in java. It's a one liner to run mypy before you invoke your tests. You have to cast to subvert the type system. In c you have void ptr everywhere anyway.
- deleted 7y ago[deleted]
- fulafel 7y agoTerminology: static vs dynamic typing != typed vs untyped. You can't not use types in Python. Examples of untyped languages would be B, assembly, Forth(?) - where the system doesn't distinguish what type of objects are in memory or storage locations.
- diminoten 7y agoHey look, it's a time traveler from the year 2004! Everybody wave, and try not to let him know our cell phones have the Internet now.
- ChrisSD 7y agoJust to clarify, Python has always been strongly typed. Every object has to have an explicit concrete type. However this type is only known at runtime and variables can be bound to any type of object. Aka dynamic typing. What the "whole Type thing" adds is type hints. That is to say they tell the programmer what types are expected. These hints can also be used in static analysis to try to restrict the types that can be bound to any particular variable. This can be useful to detect bugs in large code bases.
- kigdihshbjdf 7y agoLike Islam and Judaism, Python and Go are immune to criticism on hacker news. You will be shadow banned or IP range banned soon.