为什么android是建立在一个VM(Dalvik) [英] why android is built on a VM (Dalvik)

查看:125
本文介绍了为什么android是建立在一个VM(Dalvik)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想知道谷歌选择在java虚拟机上开发android的框架。



在为Windows编写代码近6个月的过程中,我观察到在资源有限的平台上运行虚拟机上的代码真的很慢。有很多开销涉及。我知道java是可移植的等等,根本不可能使用母语,并获得VM提供的性能和功能?对于面向性能的应用程序,还是最终编写本机代码并用JNI包装,



那么为什么谷歌选择这个特定的堆栈:


  1. 基于ARM的核心(可以理解,ARM是最适合移动设备的)

  2. Linux(开源)

  3. Java VM(我的问题)

编辑:我知道java - JVM运行与我的服务器上的C ++应用程序相同,但不是在android。
关于android它不是这样 - 根据我的经验,用JNI包装的C ++代码运行得比java代码快得多(注意我甚至用java中的静态块的完全相同的代码来检查)将同意您在任何其他平台上的答案。

解决方案

Dalvik VM使用自己的字节码,而不是Java字节码。它的设计非常快(相对来说)。我认为它的标题的VM部分是一个红色的鲱鱼,因为人们倾向于认为这将是缓慢的无论什么。你自己说过,你正在使用一个资源有限的平台 - 这可能是你的主要原因,比Dalvik VM更糟糕。



免责声明:我不是一个Dalvik或Android的专家,无论如何,形状或形式。然而,似乎人们可以根据使用虚拟机和您在Java中编写应用程序这样的想法,倾向于对Android做出很多假设,而不用进一步研究平台。



请参阅此视频了解更多信息曾经想了解Dalvik VM内部(来自Google I / O 2008)。


I am curious to know what made google choose to develop android's framework on java VM.

In the process of writing code for android for nearly 6 months now, I observed that running code on a VM in a resource limited platform is really slow. There is a lot of overhead involved. I know that java is portable etc etc, is it not possible at all to use native languages and get both performance and features offered by a VM ? For performance oriented applications one still ends up writing native code and wrap it with JNI,

So why did google choose this particular stack :

  1. Arm based core (understandable, ARM is the best for mobile devices)
  2. Linux (Open source)
  3. Java VM (My question)

EDIT : I know java - JVM run's on par with C++ applications on my server, but not on android. With respect to android its not the case - As a matter of my experience, a C++ code wrapped with JNI runs far faster than java code (note I have even checked with exact same code from a static block in java) I will agree with your answer on any other platform.

解决方案

The Dalvik VM uses its own bytecode, not Java bytecode. It's designed to be very fast (relatively speaking). I think the "VM" part of its title is a bit of a red herring, as people tend to assume that it will be "slow" no matter what. You said it yourself, you're working with a "resource-limited platform" -- that's likely your main cause of slow performance, much more so than the Dalvik VM.

Disclaimer: I am not an expert on Dalvik or Android in any way, shape, or form. However, it seems like people can tend to make a lot of assumptions about Android based on ideas like "it uses a VM" and "you write applications in Java", without looking into the platform further than that.

See this video for more information than you probably ever wanted to know on the Dalvik VM Internals (from Google I/O 2008).

这篇关于为什么android是建立在一个VM(Dalvik)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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