Earlier quoted context omitted.
Ruby has the advantage of 'duck typing', due to its strong OOP foundations. Not quite sure what Python has that reduces the demand for static type declaration. I think part of the popularity of TypeScript could be down to a large proportion of javascript coders that have a background/preference for static typing. It could also be that certain classes of bugs are more prone to happen in JavaScript or it's harder to de…
Ruby has been my first professional language and I've sticked with it for a decade, but I never really understood duck typing before switching to Go, with its interfaces (a type implements an interface if it implements its methods, so we can use interface as function parameter type). I don't get why we talk of duck typing about ruby : if I pass as parameter an object that does not quack like a duck, nothing will prev…
Duck-typing can be boiled down to: The type of a parameter to a function is defined by the methods that will be called on it, not by its class.
E.g. if you have:
def foo source
dosomething(source.shift)
end
Then absent additional restrictions inferred from requirements of dosomething(), the class of "source" is irrelevant. The relevant type information is whether or not "source" responds to "shift".A proper Ruby-ish type checker will need to be able to handle that, or it'll push people to write non-idiomatic Ruby.