Is it just because of dynamic typing we don’t require a concept of interfaces(like in Java and C#) in python?
Is it just because of dynamic typing we don’t require a concept of interfaces(like
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
interfaceas a keyword and artifact was introduced by Java1 ( and C# took it from there ) to describe what the contract an object must adhere was.But, interface has always been a key part of Object Oriented Paradigm and basically it represents the methods an object has to respond. Java just enforces this mechanism to provide statically type checking.
So, dynamic ( OO ) programming languages do use interfaces, even thought they don’t statically check them. Just like other data types, for instance in Ruby:
You don’t have to declare
iof typeFixNumyou just use it. Same goes for interfaces, they just flow. The trade-off is, you can’t have a static check on that and failures are only show at runtime.In the other hand Structural type ( or static duck type as I call it 😛 ) used by languages as Go or Scala, gives the best of both worlds.
1. See Daniel Earwicker comment about CORBA
interfacekeyword