Python/Ruby 作为移动操作系统

发布于 2024-07-18 06:03:51 字数 305 浏览 4 评论 0原文

我想知道为什么智能手机/移动设备操作系统不支持动态语言作为首选语言? iPhone 使用 Objective-C,Google Android 使用 Java,Windows Mobile 使用任何方式的 .NET 语言。

使用 Python、Ruby 或任何其他动态语言编写移动操作系统背后的原因是什么? 我知道在低层次上他们不会削减它,但 C 或 C++ 就可以做到这一点,例如,Python 可以是与之交互的顶层。 我的意思是,有 Jython 或 CPython。

我只是想知道为什么我们在当今的移动操作系统中看不到更多的动态语言支持。

I was wondering why smartphone/mobile device OSs are not written to allow dynamic languages as the language of choice? iPhone uses Objective-C, Google Android uses Java, Windows Mobile uses any manner of .NET language.

What would be the reasoning behind a mobile OS being written in Python, Ruby, or any other dynamic language? I understand that at a low level they would not cut it but C or C++ would be fine for that and Python, for example, could be the layer on top to interact with it. I mean, there is Jython or CPython.

I was just wondering why we do not see more dynamic language support in today's mobile OS's.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

如痴如狂 2024-07-25 06:03:51

一般来说,就是所有这些事情。 内存、速度,可能最重要的是程序员的熟悉程度。 Apple对Objective C投入巨资,Java基本上人尽皆知,C#也很流行。 如果你想吸引大众程序员,那么从流行的东西开始是有意义的,即使它有点无聊。

实际上没有任何技术要求可以阻止它。 我们可以编写整个 Ruby 堆栈,然后让程序员用 C 重新实现慢速部分,这没什么大不了的。 对于任何制造移动操作系统的公司来说,这都将是一项投资,但归根结底,我不确定他们能从中获得多少收益。

最后,这是移动设备的开始。 五年后,如果看到更广泛的移动堆栈,我一点也不会感到惊讶。

In general it's all of these things. Memory, speed, and probably most importantly programmer familiarity. Apple has a huge investment in Objective C, Java is known by basically everyone, and C# is very popular as well. If you're trying for mass programmer appeal it makes sense to start with something popular, even if it's sort of boring.

There aren't really any technical requirements stopping it. We could write a whole Ruby stack and let the programmer re-implement the slow bits in C and it wouldn't be that big of a deal. It would be an investment for whatever company is making the mobile OS, and at the end of the day I'm not sure they gain as much from this.

Finally, it's the very beginning of mobile devices. In 5 years I wouldn't be at all surprised to see a much wider mobile stack.

幻想少年梦 2024-07-25 06:03:51

与问题的前提相反:最早的主流移动设备之一是 Newton,它旨在使用名为 NewtonScript 的专用动态语言进行应用程序开发。 Newton 开发环境和语言使应用程序能够特别轻松地协同工作和共享信息 - 几乎与当前 iPhone 的体验截然相反。 尽管许多从头开始编写新 Newton 应用程序的开发人员非常喜欢它 - NewtonScript“感觉”很像 Ruby - Newton 存在一些性能问题,并且移植现有代码并不容易,即使 Apple 后来添加了将 C 代码合并到其中的功能NewtonScript 程序。 此外,在 Newton 上保护一个人的知识产权非常困难 - 在大多数情况下,其他开发人员可以查看你的代码,甚至随心所欲地覆盖其中的某些部分 - 这是一个安全噩梦。

Newton 在商业上失败了。

Palm 采纳了 Apple 的一些最佳创意,并对其进行了改进,但放弃了动态语言支持作为整体简化的一部分,最终导致 PalmOS 赢得了移动设备的大部分市场随着独立移动软件开发商纷纷涌向新平台,市场份额(多年来)不断增加。

Newton 的失败有很多原因,但有些人可能将其归咎于 NewtonScript。 Apple 对 iPhone 采取了“不同的思维”,他们做出的早期决定之一似乎是尽可能地利用现有的核心开发者基础,让人们能够轻松地在 Objective C 中进行开发。如果 iPhone 正式发布对动态语言的支持,这将是经过长期仔细考虑如何最好地做到这一点,同时仍然提供安全和高性能平台之后添加的。

他们这样做 5 分钟后,其他人就会效仿。 :-)

Contrary to the premise of the question: One of the first mainstream mobile devices was the Newton, which was designed to use a specialized dynamic language called NewtonScript for application development. The Newton development environment and language made it especially easy for applications to work together and share information - almost the polar opposite of the current iPhone experience. Although many developers writing new Newton applications from scratch liked it a lot - NewtonScript "feels" a lot like Ruby - the Newton had some performance issues and porting of existing code was not easy, even after Apple later added the ability to incorporate C code into a NewtonScript program. Also, it was very hard to protect one's intellectual property on the Newton - other developers could in most cases look inside your code and even override bits of it at a whim - a security nightmare.

The Newton was a commercial failure.

Palm took a few of Apple's best ideas - and improved upon them - but tossed dynamic language support as part of an overall simplification that eventually led to PalmOS gaining a majority of the mobile market share (for many years) as independent mobile software developers flocked to the new platform.

There were many reasons why the Newton was a failure, but some probably blame NewtonScript. Apple is "thinking different" with the iPhone, and one of the early decisions they seem to have made is to leverage as much as possible off their existing core developer base and make it easy for people to develop in Objective C. If iPhone gets official support for dynamic languages, that will be a later addition after long and careful consideration about how best to do it while still providing a secure and high-performance platform.

And 5 minutes after they do, others will follow. :-)

樱娆 2024-07-25 06:03:51

移动设备上的多种语言的情况比问题所暗示的要好。 如今,即使在相当便宜的手机中也可以使用 Java(其 J2ME 版本)。 Symbian S60 正式支持 Python用于小部件的 Javascript,并且有一个 Ruby 端口,尽管它仍然相当实验性。 Charles Nutter 尝试过让 JRuby 在 Android 上运行rhomobile 声称允许使用 Ruby 开发应用程序,然后可以在所有主要平台上运行智能手机操作系统,尽管这种可移植性声明意味着对这些应用程序可以实现的功能的限制。

区分移动操作系统(执行共享和保护资源等操作系统功能)和运行时平台(为用户编写的应用程序提供工作环境和一组 API)非常重要。 操作系统可以支持多个运行时,例如如何在 Windows 中运行 C++ 和 Java 应用程序,即使 Windows 本身是用 C++ 编写的。

运行时将具有不同的性能特征,并或多或少地暴露操作系统和硬件的功能。 例如,J2ME 可在大量设备上使用,但在许多设备上,J2ME 运行时不提供对摄像头的访问或拨打电话的功能。 “本机”运行时(即应用程序使用与操作系统相同的语言编写的运行时)在这方面没有什么不同:“本机”应用程序可以做什么取决于运行时允许做什么。

The situation for multiple languages on mobile devices is better than the question implies. Java (in its J2ME incarnation) is available these days even in fairly cheap phones. Symbian S60 officially supports Python, and Javascript for widgets, and there's a Ruby port although it's still fairly experimental. Charles Nutter has experimented with getting JRuby running on Android. rhomobile claims to allow developing an app in Ruby which will then run on all the major smartphone OSes, although that kind of portability claim implies restrictions on what those apps can achieve.

It's important to distinguish between the mobile OS (which does operating system stuff like sharing and protecting resources) and the runtime platform (which provides a working environment and a set of APIs to user-written applications). An OS can support multiple runtimes, such as how you can run both C++ and Java apps in Windows, even though Windows itself is written in C++.

Runtimes will have different performance characteristics, and expose the capabilities of the OS and hardware to a greater or lesser degree. For example, J2ME is available on tons of devices, but on many devices the J2ME runtime doesn't provide access to the camera or the ability to make calls. The "native" runtime (i.e. the one where apps are written in the same language as the OS) is no different in this respect: what "native" apps can do depends on what the runtime allows.

向地狱狂奔 2024-07-25 06:03:51

越狱的 iPhone 可以安装 python,实际上我在我的 iPhone 上经常使用 python。

Jailbroken iPhones can have python installed, and I actually use python very frequently on mine.

等风来 2024-07-25 06:03:51

我认为性能问题可能是部分原因,但不是全部原因。 移动设备没有非常强大的硬件可供使用。

不过,我对此有些不确定。

I think that performance concerns may be part of, but not all of, the reason. Mobile devices do not have very powerful hardware to work with.

I am partly unsure about this, though.

内心荒芜 2024-07-25 06:03:51

最紧迫的问题之一是垃圾收集。 垃圾收集经常会在有时需要实时性能的嵌入式机器中引入不可预测的暂停。

这就是为什么有一个 Java 微型版本,它有一个不同的垃圾收集器,可以减少暂停以换取较慢的程序。

重新计数垃圾收集器(如 CPython 中的垃圾收集器)也不太容易暂停,但当具有许多嵌套指针(如链接列表)的数据被删除时可能会爆炸。

One of the most pressing matters is garbage collection. Garbage collection often times introduce unpredictable pauses in embedded machines which sometimes need real time performance.

This is why there is a Java Micro Edition which has a different garbage collector which reduces pauses in exchange for a slower program.

Refcounting garbage collectors (like the one in CPython) are also less prone to pauses but can explode when data with many nested pointers (like a linked list) get deleted.

梦里梦着梦中梦 2024-07-25 06:03:51

我怀疑根本原因是安全性和可靠性的结合。 您不希望有人能够轻松破解手机,并且您希望对正在安装的内容有一定的控制权。

I suspect the basic reason is a combination of security and reliability. You don't want someone to be easily able to hack the phone, and you want to have some control over what's being installed.

白云不回头 2024-07-25 06:03:51

记忆力也是一个重要因素。 不幸的是,Python 很容易消耗内存。

Memory is also a significant factor. It's easy to eat memory in Python, unfortunately.

她比我温柔 2024-07-25 06:03:51

原因有很多。 其中:

  • 商业原因,例如软件锁定策略、
  • 效率:动态语言通常被认为较慢(在某些情况下确实较慢,或者至少对您可以进行的优化数量提供了限制。移动设备上,优化代码的必要性比 PC 上的要高得多),并且往往会使用更多的内存,这对于内存有限且缓存很少的便携式设备来说是一个重要问题,
  • 保持开发简单:一个支持 Python 和开箱即用的 Ruby 和 Java:
    • 意味着编写文档和提供支持的工作量增加了三倍,
    • 将开发工作分为三部分; 有用的材料需要更长的时间才能出现在网络上,并且在您的平台上使用与您相同的语言的开发人员较少,
    • 需要更多设备存储空间才能支持所有这些语言,
  • 需要说服管理层。 我一直认为 Java 的优点很容易向非技术受众解释。 .Net 和 Obj-C 似乎也分别是 Microsoft 和 Apple 平台的自然选择。

There are many reasons. Among them:

  • business reasons, such as software lock-in strategies,
  • efficiency: dynamic languages are usually perceived to be slower (and in some cases really are slower, or at least provide a limit to the amount of optimsation you can do. On a mobile device, optimising code is necessary much more often than on a PC), and tend to use more memory, which is a significant issue on portable devices with limited memory and little cache,,
  • keeping development simple: a platform that supports say Python and Ruby and Java out of the box:
    • means thrice the work to write documentation and provide support,
    • divides development effort into three; it takes longer for helpful material to appear on the web and there are less developers who use the same language as you on your platform,
    • requires more storage on the device to support all these languages,
  • management need to be convinced. I've always felt that the merits of Java are easily explained to a non-technical audience. .Net and Obj-C also seem a very natural choice for a Microsoft and Apple platform, respectively.
别再吹冷风 2024-07-25 06:03:51

webOS——Palm 的新操作系统,将在 Pre 上首次亮相——让您可以在 JavaScript 中针对 webkit 运行时编写应用程序。 时间会证明它有多成功,但我怀疑它不会是第一个走这条路的人。 随着移动设备变得越来越强大,您将看到动态语言变得更加流行。

webOS -- the new OS from Palm, which will debut on the Pre -- has you write apps against a webkit runtime in JavaScript. Time will tell how successful it is, but I suspect it will not be the first to go down this path. As mobile devices become more powerful, you'll see dynamic languages become more prevalent.

守望孤独 2024-07-25 06:03:51

我的 Palm 有一个 Lua 实现,它允许你做合理的 GUI,一个相当无用的旧 Python 1.5 ,一个 出色的 Forth (它允许您生成编译的应用程序)和一个 方案 允许进行完整的 GUI 开发。

在最近举行的 Apple WWDC 2009 上,Symbian 联盟第一天在邻近的大楼举办了一场活动,并预告了免费的 诺基亚 5800,适合每个人,甚至只是为了营销宣传的午餐 - 一部 350 美元的手机。 该活动旨在宣传 Ovi 商店 的开发,他们有开发人员在那里,并在下午举行了编程竞赛。

他们强调用于 Symbian 开发的三种语言是 Java、Flash (lite) 和 Python。 Python 是允许您在设备或 PC 上工作的唯一选项a> 并包括具有 OpenGL ES 和其他手机功能的示例。

凭借将 Python 应用程序捆绑到可在商店托管的独立应用程序的实用程序,我认为 S60 上的 Python 是(仍然)占主导地位的平台上严肃的动态语言的有力竞争者。

My Palm has a Lua implementation that allows you to do reasonable GUIs, a fairly useless old Python 1.5, a superb Forth (which allows you to produce compiled apps) and a Scheme that allows for copmlete GUI dev.

At the recent Apple WWDC 2009, the Symbian alliance hosted an event the first day in an adjacent building with the teaser of a free Nokia 5800 for everyone coming even just for the lunch with marketing pitch - a US$350 phone. The event was to pitch developing for the Ovi Store and they had developers there and a programming competition on the afternoon.

The three languages they were emphasizing for development for Symbian were Java, Flash (lite) and Python. Python is the only option that allows you to work on the device or a PC and includes samples with OpenGL ES and other phone features.

With a utility to bundle Python apps into standalones that can be hosted on the store, I'd say Python on S60 is right up there as a contender for serious dynamic language on the (still) dominant platform.

铃予 2024-07-25 06:03:51

OpenMoko Freerunner 有一个名为 SHR 的 Linux 发行版。 它的大部分设置和框架代码都是用 python 编写的……嗯,它不是很快。 还可以忍受,不过一开始就计划用Vala重写。

另一方面,我的几个小型应用程序运行速度足够快(唯一的缺点是启动时间长),可以考虑使用 python 来开发用户应用程序。

郑重声明:Freerunner 具有 ARM 级别的 400MHz 和 128MB RAM。 我猜想,一旦移动设备跨越 1GHz,像 Python 这样的语言对于中层的东西来说也足够快了(低层是内核)。

There is a linux distribution for OpenMoko Freerunner called SHR. Most of its settings and framework code is written in python and... well, it isn't very fast. It is bearable, but it was planned from the beginning to rewrite it in Vala.

On the other side, my few smallish apps work fast enough (with the only drawback having big startup time) to consider python to develop user applications.

For the record: Freerunner has ARM-something 400MHz and 128MB of RAM. I guess that once mobile devices cross 1GHz, languages like Python will be fast enough for middle-level stuff too (the low-level being the kernel).

海风掠过北极光 2024-07-25 06:03:51

Rhomobile 的开源 Rhodes 框架今天提供了此功能。 世界上第一个适用于所有智能手机的 Ruby 实现。

Rhomobile's open source Rhodes framework offers this today. The world's first Ruby implementations for all smartphones.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文