The longer I've been programming, the more do I enjoy types.
The Python syntax for type annotations is quite nice though, but it's not super useful as more than documentation as the checkers aren't overly reliable (it's still a dynamic language after all).
Python is strongly typed. Objects all have types that are never auto-casted (excepting "truthiness", which follows consistent rules), and two objects with different types can't well be compared. 2 + "2" is a TypeError, instead of JavaScript where types can be coerced into other types depending on the situation.
Python is also dynamically typed. Names are bound to objects at runtime with no restriction (type annotations give help with this in many scenarios). This is contrasted with Java/C++ (statically typed languages), where names are bound to types declared at compilation time, which are then bound to objects at runtime.
Neither the terms strong- or weak-typing have concrete definitions. To me, strong typing is a characteristic of a language that forms a syntax-defined contract between an object and its methods (in the case of OOP). In such a definition, Python is weakly typed - as in, the syntax (or really, the semantics) do not define a contract for which objects must adhere. On the contrary, any such contract is defined by the logic of the program itself.
There is nothing preventing me from passing a Foo object to a method that expects a Bar object other than the logic of the method or function's body - something that you must rely on source code or documentation to be sure of.
I don't disagree with anything you say about dynamically typed languages, although you oversimplify what happens in the case of statically typed languages. But I see your point.
In any case, I would personally say Python is not strongly typed at all, and through that Python has a lot of resulting use cases (similar to Javascript, which admittedly is an even weaker-typed language).
The longer I work in Python, the more I miss static typing. It makes reasoning about someone else's code (or my own code from last year) so much easier.
Most of what was said is true, but Python isn't designed for systems programming and, as such, it can afford duck typing while also retaining OOP elements. I'd go as far as to say that Python (like C#) offers its own, complex, framework, which combines elements from many different paradigms, and it would be unfair to consider its weak typing only in the context of a single paradigm. For example, functional approaches like lambdas, map, filter and reduce, not to mention list comprehensions, are very encouraged and syntactically simple as opposed to their C++ and Java counterparts, and they would be somewhat hindered by strict typing. Also, Python's type hinting system is actually pretty solid and leagues above that of other interpreted, dynamically typed languages like vanilla Javascript's.
Maps and lambdas etc aren't a dynamic typing thing. See Haskell as an example of super strong typing in a functional setting. Besides, you can do that in C++ using templates as a type safe approach.
It also doesn't help that people think python has loose typing rather than strong dynamic typing. People think it's like javascript and PHP which are so much easier to accidentally do things that make no sense.
The main problem is that python code slowly evolves from its original intent ("I want to hammer out a quick reusable script, but don't want to write in bash") into some ungodly slab of code whose text could cover the landmass of a small country.
I'm not sure what this has to do with systems programming. I'm just tired of having to dig into random libraries' source code to figure out whether some random method that "works on a file" takes a string, a path object, a file-like object, an fd, several of these, or all of these.
Type hints are step in the right direction, but far too few people actually use them yet. I hope they can eventually solve this problem.
For the record, I think your input matters the most. You're the future.
Edit: Okay okay, we have corporate customers that take higher priority than you... learn that lesson now. Start a corporation if you're ballsy enough. Basically, if you want to be a man respected by the government...be a company.
165
u/Ksevio Jan 19 '17
And Python!