1. A resource-constrained device comprising: a processor; a memory, coupled to the processor, wherein the memory includes computer programs executable by the processor, wherein the computer programs comprise: an operating system to provide functions to native applications; a virtual machine; one or more native applications under scheduling control of the virtual machine, wherein each native application is associated with an application context, each application context at least (i) maps one or more services provided by the associated native application to one or more corresponding services of the virtual machine and (ii) maintains a state of the associated native application; and one or more platform independent applications executable by the virtual machine; wherein one or more of the native applications and one or more of the platform independent applications share resources available from the virtual machine.