A place to be (re)educated in Newspeak

Sunday, January 24, 2010

Closing the Frontier?

How is a programming language interpreter like pornography? They’re both banned at the iPhone App store. The restrictions on interpreters disturb me (this blog does not deal with the other topic).

What if I want to write an iPhone app in my favorite programming language? Or my second favorite? The freedom to program in the language of my choice is a big concern of mine. Even though Squeak Smalltalk runs on the iPhone, and Newspeak runs on top of Squeak, I’m out of luck. Packaging the entire runtime with each app is not attractive.

Tangent: In principle, one should be able to write a compiler that spits out Objective-C. After all, Objective-C incorporates Smalltalk style message sends, down to the keyword syntax. In practice, Objective-C on the iPhone doesn’t support true garbage collection, so it just seems too painful. This may change soon - maybe as soon as Wednesday., with iPhone OS 4 and/or the iTablet (pick your favorite rumor).

The iPhone is a prime example of a trend where our computing platforms become more restricted. As we move toward software as a service rather than an artifact, the computer is no longer as personal; it is very much under control of the service provider. In this case Apple, in other cases Amazon or Google or Microsoft. I’d be surprised if the rumored iTablet won’t work on the same model: rather than an open version of MacOS, a semi-closed world with an app store.

I completely understand why service providers place these restrictions. What if my app is a storefront for apps? Whither the app store’s revenue? And then there are security concerns.

On the iPhone, there are administrative restrictions. Other platforms are more open in that respect - but you tend to run into technical problems. Take Android - you can distribute a language runtime, but it is the Javanese VM that’s in charge.

No one will prevent you from implementing your own system on a JVM or on .Net. However, the VM, by its architecture, will make things difficult. If it does not support the right primitives, you find that your language is a second or third class citizen.

Examples: the typed VM instruction sets are a problem for dynamically typed languages. On .Net, the DLR provides some support, but you’ll never get to peak performance using it as it stands today. On the JVM, invokedynamic will ship some sunny day, and that will be better. Even then, if you want real dynamism, you’ll find it very hard. How do you change the class of an object? How do you change the shape of a class? Or its superclass? The solutions are convoluted and/or suboptimal.

On the desktop, you can choose to bypass these platforms, but the action is increasingly moving elsewhere. Looking ahead, the dominant platforms won’t be traditional operating systems like Windows, MacOS and Linux; far fewer people will use them directly than today. Instead, we’ll have the web (as in, e.g., ChromeOS), and semi-enclosed service platforms: The moral equivalent of iTablet OS (regardless of what Apple does this Wednesday). The “real OS” may still be there underneath, but virtually no one will care.

Each of these service platforms will combine a client side, running on phones, tablets, e-books, laptops (e.g., iPhone, Android, Kindle, ChromeOS) and desktops; and a server side (e.g., Azure, Google, E3, iTunes/MobileMe) supporting storage/backup, software update and distribution and services we haven't invented yet.

The most open of these virtual platforms is of course, the web browser. Mercifully, it is relatively free of administrative restrictions and its machine language is much more flexible than MSIL or JVM byte codes (JVML). Which is not to say that you don’t have to go through some very convoluted and costly hoops. Think of weak pointers/finalization; or stack manipulation (debuggers, tail recursion) etc.

There are two threads here:

  1. The narrow technical one, which is about providing abstractions that are good enough to support alternate ways of doing things. One wants flexible designs, especially in the languages that are supposed to be at the heart of general purpose open platforms. Of course, this is much easier said than done.
  2. The broad technological/social/commercial one: the trend toward software services and the cloud is pulling us away from the personal computer and the individual control it entails. Of course, one of the great attractions here is the idea of a service that relieves much of the responsibility for digital housekeeping. The vast majority of people don’t want all that control with the trouble that goes with it. Balancing this with the freedom to innovate at the platform and language level, and the freedom to choose among languages, is hard.
Long term, the platforms that have more flexibility will benefit more from new ideas, which gives me a basis for unnatural optimism :-)

8 comments:

Fergal Daly said...

"""Take Android - you can distribute a language runtime, but it is the Javanese VM that’s in charge."""

I'm not sure what you mean by that but for example Scumm VM is mostly jut a recompile of the C-based VM with a Java wrapper to launch it and some messing around to get display, sound and mouse events working. It's even on the available through the official android. Of course if you decide to leave the Java VM you then have to start worrying about processor architectures etc.

If you want to see more flexibility in your phone, don't give your money to the guys who want you locked-in.

Gilad Bracha said...

Fergal,

Thanks for the pointer. This is exactly the sort of comment I was hoping to provoke - people telling me how you can get these things done!

When Android first came out, it wasn't obvious that you could do it, and I have not tracked it. I think it may still qualify as a contortion, but its great to see an existence proof.

Gilad Bracha said...

Fergal: Your comment prompted me to take another look at Android. Now there is an NDK, which is exactly what was missing when the platform came out.

Plus, a Squeak port is in progress. Which is a good point of departure for a Newspeak port - though for Newspeak, we'll want JavAliens for connecting to the platform, a Brazil mapping for the native GUI and a few other things. But eminently doable. I just need more volunteers.

Fergal Daly said...

I forgot aboutAndroid scripting engine which lets you run python, lua and beanshell. Python and lua have limited bindings to the system lib but there might be some generic stuff in there that you could use and improve.

Gilad Bracha said...

Fergal: Great, thanks!

Robert said...

"Long term, the platforms that have more flexibility will benefit more from new ideas, which gives me a basis for unnatural optimism :-)"

Would that this were true.

To evaluate this claim, have a look at the iPhone store, and then the dog's dinner that is the Android Market. :-(

Steve Wart said...

I think a lot of people confuse the App Store with the iPhone platform.

Ad-hoc deployment doesn't have any restrictions at all. The fact is that Apple has a responsibility to control what's distributed through the app store. Any other vendor would do the same thing.

Fergal Daly said...

@Steve Wart. Citation needed :) because wikipedia's article says

"""The iPhone's operating system is designed to only run software that has an Apple-approved cryptographic signature. This restriction can be overcome by "jailbreaking" the phone,[181] which involves replacing the iPhone's firmware with a slightly modified version that does not enforce the signature check."""

Also when Voice Central was removed from the app store, one of the main problems cited was that it was impossible for existing happy users to get any updates or bug fixes.