是什么使语言成为面向对象的语言? [英] What makes a language Object-Oriented?

查看:77
本文介绍了是什么使语言成为面向对象的语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于没有有意义的术语的辩论是毫无意义的,我想我会指出大象在房间里问:什么使语言成为面向对象"?我不是在这里寻找教科书的答案,而是根据您对OO语言的经验而定的答案,无论您使用哪种OO语言都可以在您的域中很好地工作.

一个可能首先要回答的相关问题是:面向对象语言的原型是什么?为什么?

解决方案

面向对象的定义当然是一大罐蠕虫,但这是我的2美分:

对我来说,面向对象是关于通过发送消息进行协作的对象.对我来说,这就是面向对象语言的最重要的特征.

如果我必须列出面向对象语言必须具备的所有功能的有序列表,那么它将看起来像这样:

  1. 上传递给其他对象的消息
  2. 一切都是对象
  3. 后期绑定
  4. 子类型多态性上的多态性
  5. 继承或类似表达的内容,例如委派的委派继承
  6. 封装上的封装定义
  7. 信息隐藏
  8. 抽象

显然,此列表引起很大争议,因为它排除了被广泛认为是面向对象的多种语言,例如 Java C#C ++ ,所有这些都违反了第1、2和3.但是,毫无疑问,这些语言允许进行面向对象的编程(但是

作为典型的面向对象语言,我将命名为 Self Newspeak .

均满足上述要求.两者均受Smalltalk 的启发和继任者,并且实际上都设法成为更多面向对象"在某种意义上.我喜欢Self和Newspeak的地方在于,它们都将信息发送范式带到了极致(Newspeak比Self更是如此).

在Newspeak中,一切是消息发送.没有实例变量,没有字段,没有属性,没有常量,没有类名.它们都是通过使用getter和setter来模拟的.

在Self中,没有类,只有对象.这强调了,OO真正是关于什么的:对象,而不是类.

Since debate without meaningful terms is meaningless, I figured I would point at the elephant in the room and ask: What exactly makes a language "object-oriented"? I'm not looking for a textbook answer here, but one based on your experiences with OO languages that work well in your domain, whatever it may be.

A related question that might help to answer first is: What is the archetype of object-oriented languages and why?

解决方案

Definitions for Object-Orientation are of course a huge can of worms, but here are my 2 cents:

To me, Object-Orientation is all about objects that collaborate by sending messages. That is, to me, the single most important trait of an object-oriented language.

If I had to put up an ordered list of all the features that an object-oriented language must have, it would look like this:

  1. Objects sending messages to other objects
  2. Everything is an Object
  3. Late Binding
  4. Subtype Polymorphism
  5. Inheritance or something similarly expressive, like Delegation
  6. Encapsulation
  7. Information Hiding
  8. Abstraction

Obviously, this list is very controversial, since it excludes a great variety of languages that are widely regarded as object-oriented, such as Java, C# and C++, all of which violate points 1, 2 and 3. However, there is no doubt that those languages allow for object-oriented programming (but so does C) and even facilitate it (which C doesn't). So, I have come to call languages that satisfy those requirements "purely object-oriented".

As archetypical object-oriented languages I would name Self and Newspeak.

Both satisfy the above-mentioned requirements. Both are inspired by and successors to Smalltalk, and both actually manage to be "more OO" in some sense. The things that I like about Self and Newspeak are that both take the message sending paradigm to the extreme (Newspeak even more so than Self).

In Newspeak, everything is a message send. There are no instance variables, no fields, no attributes, no constants, no class names. They are all emulated by using getters and setters.

In Self, there are no classes, only objects. This emphasizes, what OO is really about: objects, not classes.

这篇关于是什么使语言成为面向对象的语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆