Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python/Ruby as mobile OS

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.

like image 924
Tacoman667 Avatar asked May 03 '09 03:05

Tacoman667


3 Answers

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.

like image 143
Steven Canfield Avatar answered Oct 17 '22 23:10

Steven Canfield


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. :-)

like image 2
glenra Avatar answered Oct 17 '22 23:10

glenra


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.

like image 2
Sam Stokes Avatar answered Oct 18 '22 00:10

Sam Stokes