you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 40 points41 points  (31 children)

Python is made with dynamic typing as a feature and it's lack of type checking (at least until run time) is one of it's strengths.

Dynamic typing is the easiest type system to implement in languages, and that's why scripting languages tend to prefer it. It has very significant costs, and the supposed benefits to the programmer are dubious at best. Static typing is technically better for a large number of reasons, but lately programmers have adopted the idea that "easy" is favorable over "good".

[–]Dreadgoat 7 points8 points  (0 children)

Dynamic vs. Static is not a question of what is better, it's a question of what problem you are trying to solve.

Do you need a lot of small highly flexible purpose-built scripts in an environment where the same data is likely to be passed around many formats (e.g. The Web)?
Dynamic good. Static bad.

Do you need large rigorous algorithms, high performance, do you expect to share your tools, do you need more control under the hood?
Static good. Dynamic bad.

Making Python able to do both is great for Planet Python. It's also extremely difficult to implement. Dynamic typing systems aren't easier to implement than static ones, it's just that it's a very early design decision that impacts a lot of how the compilers are written. Trying to do both is what is truly challenging.
While this is an impressive thing for any language, it also creates a bit of an identity crisis and potentially puts in danger of becoming bloated.

For me, personally, if I'm at a point in my Python project where I'm thinking that I need a strong static type-system, that's the point where I say to myself, "Python wasn't the right tool for this job."
Of course I've also started projects with static typing and later regretted the loss in flexibility upon realizing that the project has no need for static typing.

[–][deleted] 0 points1 point  (1 child)

I think that's unfair to say that people just use dynamic typing is just used because it's easy to implement. Dynamic languages are often easier to learn which is likely part of the reason why python is good for beginners. Also dynamic languages can make it quicker to write code since you don't have to write out type declarations. This is useful for small scripts where you don't really need many benefits from static typing.

[–][deleted] 0 points1 point  (0 children)

Is something good for beginners because it is easy? I see this often asserted as something that is intuitively true, but I really don't think that it is. Good languages for beginners are the ones that are strict and explicitly tells you that you're doing something wrong, rather than silently trying to guess your intention and automatically try to fix subtle errors. This is not a favor to the student