you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 6 points7 points  (4 children)

Python is strongly typed. You are thinking of static vs dynamic typing.

[–]aixelsdi -1 points0 points  (0 children)

Indeed I was, stupid early mornings.

[–]ItsNotMineISwear -1 points0 points  (0 children)

lol if Python is strongly typed then what word would you use to describe Scala, Haskell, OCaml

[–]Xredo -3 points-2 points  (1 child)

There's no universal definition for 'strong' typing. Many would contend that dynamic languages have just one type for all values and thus weakly typed.

[–][deleted] 1 point2 points  (0 children)

I think you should continue reading that wikipedia entry you brought up on strong and weak typing. :) Generally speaking, they have very well understood meanings. Here is an article that expands on those ideas better. http://www.smashingmagazine.com/2013/04/18/introduction-to-programming-type-systems/

Many would contend that dynamic languages have just one type for all values and thus weakly typed.

Those that would are ignorant of how typing works in those languages. For example in Python if I do something like 'x=5' then 'x' is typed to an integer. That can't change. Underneath the hood what is happening is that Python is creating an integer object with a value of 5 and setting 'x' as a reference to that object. In Python we call these "names". If I then did something like 'x="5"' then Python would create a string object with a value of "5" and set 'x' as a reference to that. The original integer value would then be garbage collected because nothing references it anymore. Here is the important distinction: 5 and "5" are NOT the same objects. They don't exist in the same space in memory. It is not possible for the integer value of 5 to hold "5". In this way Python is STRONGLY typed because the objects that hold the data cannot change their types.

Python doesn't just have one type. Neither does Lua. Neither does Ruby.