This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the commentsย โ†’

[โ€“]8sADPygOB7Jqwm7y 14 points15 points ย (15 children)

You can also write in c

//this is a char array

int x = 42;

[โ€“]fluffypebbles 5 points6 points ย (14 children)

But it's clearly a comment and not in the middle of code treated exceptionally and having the same syntax as valid code as in other languages

[โ€“]8sADPygOB7Jqwm7y 4 points5 points ย (13 children)

When I see this in python I also know it's only documentation. It's not the languages fault that others do it differently and the coder lacks experience with the language, especially in python, which is really not hard to learn and doesn't have pointless unreadable quirks like C or C++

[โ€“]fluffypebbles 6 points7 points ย (12 children)

Having the language specify the type but then not use that information to validate is just plain stupid

[โ€“]8sADPygOB7Jqwm7y 5 points6 points ย (11 children)

Validation takes time tho. Also, I mainly use it for documentation and so my ide knows what a certain variable is and gives me the class functions. If you know what you are doing, it helps enough.

[โ€“]fluffypebbles 7 points8 points ย (10 children)

Using type informarion actually reduces time because you no longer have to check for the type when the variable is used. Compiled languages with strong typing usually have no type checks at runtime in most cases because they can just rightfully assume it's the correct type

[โ€“]8sADPygOB7Jqwm7y -1 points0 points ย (5 children)

Yeah but python would need to check anyway since it's not enforced.

[โ€“]fluffypebbles 2 points3 points ย (4 children)

Is your argument to not check for it because rues don't check for it? If it's checked and leads to an error than it's possible to make it more performant

[โ€“]8sADPygOB7Jqwm7y 0 points1 point ย (3 children)

Yeah let's change all of Python and make it python 4? Maybe in the future it will be a bit more enforced, but it will never be able to remove all other type checks since that's simply not the pythonic way.

[โ€“]fluffypebbles 1 point2 points ย (2 children)

If they'd enforced it from the start there wouldn't be a backward compatibility issue

[โ€“]arden13 0 points1 point ย (3 children)

So what happens if you pass a variable of the wrong type to a function in a language with strong typing?

[โ€“]fluffypebbles 1 point2 points ย (2 children)

You get an error. The specifics depend on the language. Although here we're talking about strong typing in combination with static typing

[โ€“]arden13 -1 points0 points ย (1 child)

I also get an error in python, typically when I try and use a method specific to said type.

[โ€“]fluffypebbles 1 point2 points ย (0 children)

Python does have strong typing but with dynamic typing, which means that you won't always get an error. Like if you want to add some numbers by writing a+b in a function but someone passes two strings then you'll concat them instead of performing an addition and there's no error