5 ms·
This is nice and everything, but why can't they just give up the charade and let people write applications for mobile devices in whatever language they like wit
by AnthonyMouse 13y ago
This is nice and everything, but why can't they just give up the charade and let people write applications for mobile devices in whatever language they like without having to jump through hoops like this? I should be able to write applications in Go (or C or whatever) and be able to use the official APIs in an officially supported way and without having to waste time screwing with shims and JNI.
And while I'm complaining about it, it sure would be nice if they would include POSIX support by default. It's not like the code to do it isn't largely already written and freely available.
- gw 13y agoYou already can use official Android APIs with alternative languages as long as they are JVM-hosted, such as Clojure or Scala. Asking for API support from external runtimes would be a tall order and a major undertaking, with probably little benefit. I fail to see what the "charade" is.
- deniska 13y agoActually Clojure and some other JVM hosted languages don't work on android as is because they rely on JVM while android uses bytecode converted from jvm to dalvik. Edit: clojure works on android now but it needed additional porting efforts
- RyanZAG 13y agoLooks to me like Clojure on Android works just fine. http://clojure-android.blogspot.com/2013/06/state-of-clojure-on-android-2013.html http://clojure-android.blogspot.com/2013/06/state-of-clojure...
- myko 13y agoYeah, they definitely require work but it is possible. I had just gotten my Android+Scala setup completed before IO and am now looking into integrating Gradle+Android+Scala, which is proving more difficult.
- pjmlp 13y agoBecause of those issues, I learned long time ago (in the early 90's) to just use official SDK supported languages. Too much time is spent on hacking an half working solution and in the end the vendor offers no support if the problem is to be found outside the SDK. Or even if it is in the SDK, non supported languages offer a nice excuse to avoid giving support.
- gw 13y agoThis is complete misinformation. Even Java apps on Android are first compiled to JVM bytecode, and then converted to Dalvik bytecode using the dx tool. Clojure and Scala go through the exact same process that Java does in order to make Android apps.
- drdaeman 13y agoAccording to http://stackoverflow.com/a/231284/116546 http://stackoverflow.com/a/231284/116546 Dalvik does not allow runtime bytecode generation, which may prevent some languages (Jython in particular) from running on Android without some (presumably heavy) efforts.
- Zigurd 13y agoAndroid apps are compiled to Java bytecode and then translated to Dalvik bytecode. Clojure should work. There are toolchain issues like interfacing Clojure and AIDL that I'm not aware of the state of development, but it should be very feasible to make Clojure a first class citizen in the Android software development world.
- rogerbinns 13y agoYou can write them in whatever language you like, but the problem is they have to interface to the system. With Linux ultimately you only need the system call interface, and the communication back from the kernel is signals. A mobile app has a far richer interface, and needs to interact with the system in more deep and meaningful ways. Memory is tight and application lifecycles can be hectic. Heck on Android there isn't such a thing as an Application in the traditional sense - ie there is no entry point/main function. Instead the "application" is actually a mashup of components such as Activities (screens/ui), services (processing), content providers (data) and broadcast receivers (async updates)[1]. The Android system itself is then a mashup of those. Again there is a lot of scaffolding to make the different parts of the different apps all work together with bidirectional communication. Using a different language means all that scaffolding has to be duplicated in each language. That is a heck of a lot of work and then requires ongoing maintenance. Dalvik essentially provides all that for Java like bytecode with JNI for calling out to native code. You'd need to duplicate what is in Dalvik to do a good language environment for Android. (Or generate Dalvik bytecode ahead of time.) [1] That is how a well written app is structured for Android. You can ignore all that and put everything into a single Activity (iOS ports often do this) but it won't interoperate well with the system, and users will notice. With the increasing RAM and CPU these days you are increasingly likely to get away with it. The first Android phone had 192MB of RAM.
- AnthonyMouse 13y ago>A mobile app has a far richer interface, and needs to interact with the system in more deep and meaningful ways. Memory is tight and application lifecycles can be hectic. I'm not clear how this is different than it is for the variety of embedded Linux devices that natively support multiple languages. You can run Debian (sans X-Windows) with under 64MB of RAM. >Using a different language means all that scaffolding has to be duplicated in each language. Not really. I would be plenty happy if they would just provide a native C API like GNU/Linux does, which manages to support most of the major languages because almost everything has near-seamless support for calling C API functions.
- rogerbinns 13y ago
- grey-area 13y agoI'd love to see Google reset their Android efforts and start again because of Java issues (legal, technical), and fragmentation issues (majority still on Android 2.x), and also as you mention because having one binary API for the UI is painful. My wishlist for a revamped mobile platform: A simple linux distribution as a base (as with Android), with posix. They could still lock-down app installation for normal users, have an app store, and all the other things that make current mobile platforms attractive to consumers. Hooks for any popular languages to control the UI via simple glue libraries, all implementing the same API, with the ability to add more easily because the UI API could be really quite simple (and should remain so) if built off the work already done for the web. They could add C, C++, Golang, Java, C#, even ObjC to the mix this way. There's no chance they'll do this for their current API, so they'd need to have a radical rethink of just what a mobile OS should provide. A web-based stack for the UI based on an improved webkit (a la webOS). Most apps have very simple needs (specify a UI, adjust the UI, listen for UI events) that could easily be dealt with by message passing between the view and app rather than binary interfaces. Webgl and css animations etc could be utilised for performance where required. Crucially this wouldn't tie developers into one complete stack from language to tools to UI - the UI should be separate and not tied intimately to the back-end language as it is currently on iOS and Android. A base OS that is non-negotiable and non-modifiable by carriers/manufacturers, and upgrades from a central point (a consortium led by Google), that are not phone-specific. Carriers can add apps etc but there's no reason they have to adjust the base OS, and both should negotiate with Google for inclusion of new drivers, not hold up upgrades because they want to sell newer hardware/contracts. Far stricter permissions for apps with far less access (more like web-apps), and individual prompts on first use of info like phone no, addresses etc. to discourage overuse. It's a shame that our mobile devices are typically tied to one platform, one language, one UI, when they have so much potential as portable computing devices.
- Zigurd 13y agoI don't want to justify lack of innovation or responsiveness to developers, but there are a few reasons why not, among them: Android has a large middleware layer written in Java and the Dalvik VM uses copy-on-write and fork to treat bytecode as if it were pure code - using only one copy. In practice this means that apps that do not make use of the Dalvik runtime are limited to special purpose apps such as games written mostly on top of OpenGL. Even those might end up being wrapped in a Dalvik VM runtime app to access things like accounts, sharing, etc. A realistic step would be to add one or more JVM languages as first class citizens of the toolchain. Clojure would be very welcome. Android really is an OS with a very intimate relationship with a VM that implements Java semantics, though not Java bytecodes.