Java 是 100% 面向对象的吗? [英] Is Java 100% object oriented?

查看:31
本文介绍了Java 是 100% 面向对象的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java 具有原始数据类型,它不像在 Ruby 中那样从对象派生.那么我们可以将 Java 视为 100% 面向对象的语言吗?另一个问题:为什么 Java 不以对象方式设计原始数据类型?

Java has primitive data types which doesn't derive from object like in Ruby. So can we consider Java as a 100% object oriented language? Another question: Why doesn't Java design primitive data types the object way?

推荐答案

当 Java 首次出现(版本 1.x)时,JVM 真的非常非常慢.不将原语实现为一流对象是他们为了速度目的而做出的妥协,尽管我认为从长远来看这是一个非常糟糕的决定.

When Java first appeared (versions 1.x) the JVM was really, really slow. Not implementing primitives as first-class objects was a compromise they had taken for speed purposes, although I think in the long run it was a really bad decision.

面向对象"对很多人来说也意味着很多事情.您可以拥有基于类的 OO(C++、Java、C#),也可以拥有基于原型的 OO(Javascript、Lua).

"Object oriented" also means lots of things for lots of people. You can have class-based OO (C++, Java, C#), or you can have prototype-based OO (Javascript, Lua).

100% 面向对象实际上并没有多大意义.Ruby 也有您不时会遇到的问题.

100% object oriented doesn't mean much, really. Ruby also has problems that you'll encounter from time to time.

Java 困扰我的地方在于,它没有提供有效地抽象思想的方法,也没有提供在有问题的地方扩展语言的方法.每当提出这个问题时(参见 Guy Steele 的Growing a Language")哦,不,但是 Joe Sixpack 呢?"给出了论证.即使你设计了一种语言来防止自己被踢到脚下,意外的复杂性和真实的复杂性之间还是有区别的(参见 No Silver Bullet) 和平庸的开发者总会找到创造性的方式来拍摄自己.

What bothers me about Java is that it doesn't provide the means to abstract ideas efficiently, to extend the language where it has problems. And whenever this issue was raised (see Guy Steele's "Growing a Language") the "oh noes, but what about Joe Sixpack?" argument is given. Even if you design a language that prevents shooting yourself in the foot, there's a difference between accidental complexity and real complexity (see No Silver Bullet) and mediocre developers will always find creative ways to shoot themselves.

例如 Perl 5 不是面向对象的,但它的可扩展性足以允许 Moose,一个对象系统,它允许使用非常先进的技术来处理 OO 的复杂性.而且语法糖没问题.

For example Perl 5 is not object-oriented, but it is extensible enough that it allows Moose, an object system that allows very advanced techniques for dealing with the complexity of OO. And syntactic sugar is no problem.

这篇关于Java 是 100% 面向对象的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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