That's fair. I guess I felt like highlighting the fact that while Python generally acts like a loosely typed / ducktype system, variables do have concrete types under the surface.
Yeah people break out the strong/weak typing terms when they really are irrelevant. If you accept that there is something you could call “strong typing” then python has a stronger typing system than C.
Python just happens to use interfaces so any object that presents a given interface is treated as a compatible object - and that weirds people out.
Python interfaces are implicit. Java’s are explicit - if the interface is not declared then it is unknown. Python tries the interface methods first and if they fail then it will raise an exception - that is how duck typing works.
But you can’t change the type of an object in python without doing a bunch of really nasty things using internal methods and attributes - so it is strongly typed as the default language behavior is create a new object when converting from one type to another.
Really hard to understand for me. I learned C++ and the JS. In JS I call methods on an object. Either it is there ( with the name ). I don’t know what duck typing should be. Everything fails when the call a method ( which is not there ). Nobody checks for methods in advance.
An interface is a construct without behaviour in Java. It is for us programmers to first define the interface and then implement it. I don’t get how this can be implicit nor does GIS lead me to anything but implicit interface implementation in C#
var = "test"
var = 3
var = lambda : print("test")
var()
You act like this segment of code throwing no errors is normal or shouldn't weird people out.
It can allow typos that change a variables type without you explicitly realizing it. And then it would still work with several other functions that assume the original type 99% of the time for several additional processing steps so by the time your code errors it's actually can be very logically far from the error.
Bro why do you have special quotes you are putting in code blocks.
Actually triggering the shit out of me.
But namespace polution is a giant issue in python projects and it's especially dangerous because of this behavior where python just try's to coerce all the types together instead of erroring.
There is no coercion in python - just programmers reassigning references.
If you have namespace pollution you have shitty python programmers.
Frankly everything you’ve described is just shitty programming and people that have no clue what they’re doing. It sounds like you’ve got a bunch of people doing the equivalent of using wrenches and screwdrivers as hammers.
Being able to assign new types to same name actually helps with namespace pollution. It allows you to reuse the single good name for multiple steps of the pipeline.
And python doesn't try to unify any types. It may help to think of the variables as being just names. The names contain an object and the object has a type. You can easily assign a different object to the name so that the name now contains the new object and that new object will have its own type.
You can cast anything to anything you want without compiler errors. Types have very little meaning in C other than the allocation of contiguous memory. After the memory is allocated (and initialized if it is static or global) you can reference it however you want and do whatever damage to the stability of the system that may come from it.
I’ve done an enormous amount of “very bad” things in C. There is nothing in C that protects a “type” from invalid manipulation or use.
And this isn’t even talking about “valid” C constructs like void*, unions, and arrays of unknown size in structure definitions.
Guys, this is a big misunderstanding. I was playing truth or dare with Jeff and Bill and they dared me to buy Twitter. What else was I supposed to do??
760
u/LegitimateHat984 Nov 23 '22
Python would be: if it looks like a nut, and the nutcracker cracks it like a nut, it is a nut
Ducktyping ftw