为什么 Android 使用 Java 概念而不是 D 语言或 C 或 C++?但是 Chromium 网络浏览器是用 C++ 编写的,它的匹配非常复杂
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5605575/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why Android used Java concept instead of D language or C or C++? But Chromium web browser is in C++, its very complicated match
提问by Stephen C
Android is 32-bit ARM. wiki
Android 是 32 位 ARM。维基
Description:
描述:
1) So, 32/64 or 8/12/16 Bit compiler is available with D language if not it can be builded by a compiler, if i am not wrong?
1) 所以,32/64 或 8/12/16 位编译器可用于 D 语言,如果没有它可以由编译器构建,如果我没有错?
2) Linux standard kernel: Libraries written in C and other languages can be compiled to ARM wtih D language i believe, not only D language also possible with C/C++.
2)Linux标准内核:我相信用C和其他语言编写的库可以用D语言编译成ARM,不仅D语言也可以用C/C++编译。
According to Android wiki information starts my confusion:
根据 Android wiki 信息开始我的困惑:
wiki: Modified version of the Linux kernel (its not linux but its modified linux, beause hardware compatibility? So i cant use RPM packaging? Because its not standard linux anymore?)
wiki: While most Android applications are written in Java, there is no Java Virtual Machinein the platform and Java byte code is not executed. Java classes are compiled into Dalvik executables and run on the Dalvik virtual machine. Dalvik is a specialized virtual machine designed specifically for Android and optimized for battery-powered mobile devices with limited memory and CPU. J2ME support can be provided via third-party-applications.
wiki:Linux 内核的修改版本(它不是 linux 而是它修改后的 linux,因为硬件兼容性?所以我不能使用 RPM 封装?因为它不再是标准的 linux 了?)
wiki:虽然大多数Android应用程序是用Java编写的,但平台中没有Java虚拟机,也不执行Java字节码。Java 类被编译成 Dalvik 可执行文件并在Dalvik 虚拟机上运行。Dalvik 是专门为 Android 设计的专用虚拟机,并针对内存和 CPU 有限的电池供电移动设备进行了优化。J2ME 支持可以通过第三方应用程序提供。
Question: Why just Android is not written either with D or C/C++ languages? Instead of dealing with all those mess, this is the only company proved that Bigtable they needed (world cant solve there issue yet) and Mobile platform also requires changes such as Android? Whats wrong with iPhone/Nokia implementation then?
问题:为什么 Android 不是用 D 或 C/C++ 语言编写的?这是唯一一家证明他们需要 Bigtable 的公司,而不是处理所有这些混乱(世界还无法解决那里的问题)并且移动平台也需要更改,例如 Android?那么 iPhone/Nokia 的实现有什么问题呢?
Question: Why Android dont run JVM but they build a Java concept does alternative JVM processing, instead of doing same such as MeeGo or others. Is that a marketing terms or is that a technical term? Can it not be written in C/C++ or D language only the whole Android? Instead of involving Java concept or Mess concepts?
问题:为什么 Android 不运行 JVM 但他们构建了一个 Java 概念来替代 JVM 处理,而不是像 MeeGo 或其他人那样做。这是营销术语还是技术术语?难道不能只用C/C++或D语言编写整个Android吗?而不是涉及Java概念或Mess概念?
if yes then Chromium-web browser why they used again C++? Why not just followed Java also for Chromium-web?
如果是,那么 Chromium-web 浏览器为什么他们再次使用 C++?为什么不对 Chromium-web 也遵循 Java 呢?
Its all about to learn how its getting used in practical life, to me again, its just to know why they did such mess for Android? Are we then learning programming languages in University wrong way (knowing later, oh Big Google just used Java for Android) ?
一切都是为了了解它如何在实际生活中得到使用,再次对我来说,只是想知道他们为什么对 Android 造成如此混乱?那么我们在大学学习编程语言是不是错误的方式(后来知道,哦,Big Google 只是将 Java 用于 Android)?
Thanks in advance, for your valuable advise on this.
在此先感谢您就此提出宝贵建议。
回答by Stephen C
Why just Android is not written either with D or C/C++ languages?
为什么 Android 不是用 D 或 C/C++ 语言编写的?
Because none of them is a fully managed language. D isgarbage collected, but you can also do manual memory management ... with all of the risks that that entails.
因为它们都不是完全托管的语言。D是垃圾收集器,但您也可以进行手动内存管理......伴随着所有风险。
Also, because starting from a Java base (in the form of Apache Harmony, etc) meant that:
此外,因为从 Java 基础(以 Apache Harmony 等形式)开始意味着:
- Java developers would be able to transition to Android, and
- there would be less for the Android development team to implement.
- Java 开发人员将能够过渡到 Android,并且
- Android 开发团队实施的工作会更少。
However, as @Marchy points out, it wasn't Google that made the original decision:
然而,正如@Marchy 所指出的,最初的决定并不是谷歌:
"... Google didn't BUILD Android. [Android Inc]was a startup they bought, and as a startup you use whatever is out there and optimize to gain momentum FAST and with VERY limited resources. ..."
“ ......谷歌没有构建 Android。[Android Inc]是一家他们收购的初创公司,作为一家初创公司,你可以使用现有的任何东西并进行优化,以快速获得动力,而且资源非常有限。......”
Though obviously Google did have a hand, since (according to Wikipedia) Google helped finance Android Inc prior to the buyout.
尽管显然谷歌确实有帮助,因为(根据维基百科)谷歌在收购之前帮助资助了 Android Inc。
Why Android dont run JVM but they build a Java concept does alternative JVM processing.
为什么 Android 不运行 JVM 但他们构建了一个 Java 概念来替代 JVM 处理。
Ultimately, because the restrictions that Sun / Oracle places on the Java language and platform would have made it impossible to innovate in the way Google has done with Android. Specifically, Sun / Oracle won't license vendors to implement Java SE on mobile platforms.
归根结底,因为 Sun/Oracle 对 Java 语言和平台的限制使得 Google 无法像 Android 那样进行创新。具体来说,Sun/Oracle 不会许可供应商在移动平台上实施 Java SE。
Are we then learning programming languages in University wrong way.
那么我们在大学学习编程语言的方式是错误的吗?
Maybe youdid!!
也许你做到了!!
But when I learned programming at University, it was in the full knowledge that I'd never use some of the languages I was taught about. For instance, I've never used Algol-60, Simula-67, SNOBOL or CDC assembly language since. But that did not invalidate the reasons that they were taught, or the valuable lessons I gained in learning them.
但是当我在大学学习编程时,我完全知道我从来没有使用过我教过的一些语言。例如,从那以后我就再也没有使用过 Algol-60、Simula-67、SNOBOL 或 CDC 汇编语言。但这并没有否定他们被教导的原因,或者我在学习它们时获得的宝贵经验。
回答by dsimcha
I'd guess it's because a lot of programmers are familiar with Java and Java, for all its faults as a language, has excellent library and tool support. Also, the layer of VM indirection prevents the apps from being too tightly coupled to the hardware.
我猜这是因为很多程序员都熟悉 Java 和 Java,尽管它作为一种语言存在所有缺陷,但具有出色的库和工具支持。此外,VM 间接层可防止应用程序与硬件过于紧密地耦合。
回答by Monkey
There is a lot of Java programmers, a whole ecosystem to build upon. Much more than D :p An OS running most of the programs for it on a virtual machine have nice advantages for security (http://en.wikipedia.org/wiki/Language-based_system). But doing some exception for a very important application, from user point of view, can help performance. The choice of a specific JVM, it seems to be clear, it's to have something adapted to typical embedded resources. I think Google choices are quite pragmatic in that regard.
有很多 Java 程序员,可以建立一个完整的生态系统。远不止 D :p 在虚拟机上运行大多数程序的操作系统在安全性方面具有很好的优势 (http://en.wikipedia.org/wiki/Language-based_system)。但是从用户的角度来看,为一个非常重要的应用程序做一些例外可以帮助提高性能。特定JVM的选择,似乎很明确,就是要有一些适合典型嵌入式资源的东西。我认为谷歌在这方面的选择非常务实。
For the (rant on ?) teaching of languages at the university, I don't think it's about learning the latest fashionable language. It's about learning to learn computer related technologies, such as programming languages. The concepts did not changed much since, say 1960, 1970, although that ok, their implementation is different.
对于大学里的(咆哮?)语言教学,我认为这不是学习最新流行的语言。它是关于学习学习计算机相关技术,例如编程语言。这些概念自 1960 年和 1970 年以来没有太大变化,尽管可以,但它们的实现方式不同。