Why the claim that c# people don't get object-oriented programming? (vs class-oriented)

前端 未结 14 1909
有刺的猬
有刺的猬 2021-02-07 12:15

This caught my attention last night.

On the latest ALT.NET Podcast Scott Bellware discusses how as opposed to Ruby, languages like c#, java et al. are not truly object o

14条回答
  •  醉酒成梦
    2021-02-07 12:50

    I don't think this is specifically about duck typing. For instance C# supports limited duck-typing already - an example would be that you can use foreach on any class that implements MoveNext and Current.

    The concept of duck-typing is compatible with statically typed languages like Java and C#, it's basically an extension of reflection.

    This is really the case of static vs dynamic typing. Both are proper-OO, in as much as there is such a thing. Outside of academia it's really not worth debating.

    Rubbish code can be written in either. Great code can be written in either. There's absolutely nothing functional that one model can do that the other can't.

    The real difference is in the nature of the coding done. Static types reduce freedom, but the advantage is that everyone knows what they're dealing with. The opportunity to change instances on the fly is very powerful, but the cost is that it becomes hard to know what you're deaing with.

    For instance for Java or C# intellisense is easy - the IDE can quickly produce a drop list of possibilities. For Javascript or Ruby this becomes a lot harder.

    For certain things, for instance producing an API that someone else will code with, there is a real advantage in static typing. For others, for instance rapidly producing prototypes, the advantage goes to dynamic.

    It's worth having an understanding of both in your skills toolbox, but nowhere near as important as understanding the one you already use in real depth.

提交回复
热议问题