Hacker News new | ask | show | jobs
by jompe 2588 days ago
I'm a fresh graduate from uni so I'd say that I don't have that much experience. My last years working on the side of studies using Python really made me prefer strongly typed languages like Haskell, Rust, Elm etc. My experience is that the compiler almost always finds my small errors and would-be-bugs which Python exposes at runtime (crashes with e.g. None-type errors).

What would you say the benefits are with dynamic typing?

4 comments

Python IS strongly typed. ie: 1 == '1' is FALSE, and 2 + '2' raises an exception.
So forgive jompe for using the wrong term. The point, however, was clear. It wasn't "strong vs weak"; the point clearly was "compile time vs run time". And, well, Python is, from jompe's perspective, on the wrong side of the line, no matter how "strong" Python's type system is.
There is nothing to forgive, many people conflate dynamic typing with weak typing, so I thought I would point it out.

Whether or not a specific method of typing is good or bad depends on the project and the developer(s) working on it. But if you're going to use that as a reason to make decisions, then you should understand the difference.

since python 3.6 you can use static types in python if you want.
I don't have any particular love for dynamic typing, but I really can't find a language I like developing in more than Python. I use type hints wherever I can so I (and others) know what the hell is going on, but I have yet to find a language as expressive and productive with so many great stdlib or community packages as Python.

I started futzing with Golang but I felt like I was always typing 50 lines to do what I could in 3-4 in Python. I might circle back as it matures more and there are more libraries.

Yeah, Go is that way on purpose. You're not meant to use magic that works mysteriously, but to be a bit "step-by-step" in your code, so it's obvious what's being done.
The article explains (very well) what the benefits of dynamic typing are, it's just that Python is a terrible language that spits in the face of Alan Kay's ideas. It's like someone went out of their way to create a language that would not be too paradigm shifting by discarding the crucial elements that Alan Kay keeps raving about and only choosing the most superficial with the only consideration being ease of use and popular appeal.

Try programming in Erlang, Common Lisp or Smalltalk. All dynamically typed languages. All meshing perfectly with Alan Kay's vision. All very different to Python. It's too bad that people's idea of "dynamic typing" has been - mostly - reduced down to Python and Javascript.

I wouldn't say current Smalltalk implementations mesh perfectly with Kay's vision. It's focus on class hierarchies and inheritance breaks with what Kay's initial vision was. That said, it's possible to write Smalltalk code favoring composition over inheritance or in a much more functional way that focuses on messages.
I think you're confusing strong and dynamic. It's static vs dynamic and strong vs weak.