4 ms·
Good that Python supports types then
by baq 10mo ago
Good that Python supports types then
- lelanthran 10mo ago> Good that Python supports types then "Optional typing" is not the same as "Static typing". Great, my program will crash, because I forgot to opt-in to typing :-/
- paulddraper 10mo agoC has void pointers.
- lelanthran 10mo ago> C has void pointers. And? Void pointers are not the default type :-/ With Python I have to do extra work to get type errors. With C I have to do extra work to hide the type errors. I am battling to understand the point you are making.
- baq 10mo agoHard to argue with an argument which isn’t internally coherent.
- array_key_first 10mo agoHe's probably conflating static and strong typing. C is statically typed, but weakly typed - you need to throw away types to do a bunch of run of the mill things. Python is dynamically typed, but strongly typed, where it will just fail if typed don't resolve. C# and C++ are both statically typed and strongly typed, although C# more than C++ in practice.
- paulddraper 10mo agoI believe that is in fact the exact return type of malloc. You have to do extra work to type it. I’m not aware of any other statically typed language that does that. Hopefully that helps you in your battle.
- lelanthran 10mo ago> I believe that is in fact the exact return type of malloc. > You have to do extra work to type it. Nope. Casting the return from `malloc` is a code-smell in C. You have to do extra work if you use `malloc` in C++. > Hopefully that helps you in your battle. Not sure what you mean by this - weren't you the one who dragged C into a conversation about Python?
- SR2Z 10mo agoPoorly, though, and with lots of edge cases and foot guns to make you miserable once your code calls out to numpy or gets some JSON.
- Groxx 10mo agoPython has formalized magic comments. You can run a third party linter on those comments, but you must hope that they're correct. There are usually some checks for that, but they're only reliable in trivial cases. This is not static typing any more than "you can use emscripten to transpile JavaScript to C" means that JavaScript is a low level language with native assembly support. It's a huge step forward from "no system at all" and I'm thrilled it exists, but it's hardly the same thing.
- kccqzy 10mo agoThey are originally magic comments, unformalized. The feature is originally known as annotations and you can basically put anything there. def f(a: "something like an int", b: "another int-like thing"): pass def g(a: sys.stdin, b: sys.stderr): pass
- tasuki 10mo agoTell me more please: how does one use types in Python? Unfortunately I write Python professionally these days (it is the language that has all the libraries) and hate it with a passion.
- andrewl-hn 10mo agoIt's actually remarkable how with the success of TypeScript so many other dynamic languages switched to gradual typing. Erlang and Clojure were the early ones, TypeScript followed, and now Python, Ruby, and even Perl have ways to specify types and type check your programs.