chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Chicken Scheme for mobile devices?


From: Stephen Eilert
Subject: Re: [Chicken-users] Chicken Scheme for mobile devices?
Date: Thu, 15 Nov 2012 01:05:49 -0300

I have added the code I created last year to my github repository. It can be found at https://github.com/outworlder/beamrider

This is just to give an idea of how I've made it work. It has since succumbed to bit rot and is segfaulting for some reason I haven't tracked down yet - something to do with the initial_trampoline. It is also a nice example of what NOT to do (copying files from Chicken's distribution, for instance).

The nice thing is that the rendering loop just calls the Scheme code, which in turn does the drawing with OpenGLES. Last time I tested it, it worked beautifully. The remote-repl is temporarily disabled, but I could mess around and change the rendering in the device by connecting to it remotely.

The OpenGL ES code was poached (without attribution, yet) from jlongster, I think - I didn't intend to release it at first - and I've added some horrible macro trickery in order not to modify the source file (much, I've changed pointer to c-pointer in some places) in order to use Gambit's FFI directly.

I think it is an ugly hack, but we can definitely improve on it. 


-- Stephen

"Kids these days.
Whatever happened to hard work?"

       -- Joel Spolsky, The perils of javaschools



On Wed, Nov 14, 2012 at 3:49 PM, Kevin Wortman <address@hidden> wrote:
I am interested in this as well. I've only investigated Android and iOS and can't speak to other mobile platforms. There are two obstacles, 1) getting Scheme code to run on target platforms, and 2) exposing the APIs for UI, GPS, etc. to the Scheme world.

One solution to (1), as Stephen described, is to use csc to compile Scheme to C then compile that C according to the vendor-sanctioned process. C plays nicely with Xcode Objective C projects, and Android provides the NDK environment. So you can get Scheme compiled to good native code. However (2) is a  problem since the iOS APIs are Objective C and AFAIK Chicken code cannot currently call into that. On paper the Android NDK looks like it should work, but the docs are quite clear that it's not intended to wrap the entire Android API and so may not be complete or future proof.

These problems could be overcome by creating a general purpose Scheme-to-Java FFI and giving the Scheme-to-ObjC FFI some love. But those are big undertakings and may be overgeneralization.

Both Android and iOS support OpenGL ES and libsdl, and we already have SDL and OpenGL (non-ES) binding eggs. So the path of least resistance for game-like apps that only need OpenGL and SDL functionality may be to use only those. We could create a build tool that automates the process of building those eggs, their dependencies, and client Scheme code, writes ObjC/Java shims, and integrates everything into the target build environments.

A very different approach is to build web apps. We can use Spock to compile Scheme to _javascript_. There are well documented processes for bundling HTML5 pages into redistributable apps. Scheme can call into the HTML5 API, which others have already designed as a thorough and cross-platform API for this sort of thing. This approach seems to be aligned with the interests and wishes of Apple and Google and so may be cleaner and more future proof. However there is a performance penalty from running interpreted JS. And IIRC Spock supports a limited subset of bigchicken and cannot load eggs. So the Scheme environment would be limited.

I am most interested in games and game-like apps, so I am willing to make some simplifying assumptions. Is that true for others, or do people want to support cross platform native apps in their full generality?

Regards,
Kevin Wortman




On Wed, Nov 14, 2012 at 6:37 AM, Stephen Eilert <address@hidden> wrote:
 Yes, please. I've been toying with this idea for quite a while now.

Chicken already works without modification on iOS. However, since you cannot link to third party libraries dynamically, you'd have to compile two versions (x86 one for the simulator, ARM version for the device) and statically link to the correct version.

What I have done previously (successfully), was to grab the generated C Chicken (runtime.c, srfi-1.c, ports.c, etc) and added to the XCode project. Then, I compiled my program and asked csc to just dump the .c files. I then added it to the project as well. Also added a Makefile so that they would get recompiled as necessary.

That worked, I was even able to open a remote REPL and make changes and have them displayed in the device (the OpenGLES drawing code was written in Scheme). The advantage of this approach was that one doesn't need to care what the target device is. However, it is too 'hackish' for my tastes. Not to mention that it would be a pain to add eggs. But it proved that Chicken works fine on iOS. 

Since one can call Scheme functions from C, it is trivial to do so using Objective-C. The other way around should be possible too, but I haven't poked too much into Objective-C's internals yet. If all else fails, we could always write 'foreign code'.

Building a cross compiler (and using the correct one in the iOS build system) is rather tedious, as is statically linking the correct eggs. If we had a tool to generate a 'template' project and maintain it, we'd have a winner. Actually building it could be accomplished by xcodebuild, as long as we add a build step that calls csc.

I'm talking about iOS since that's what I am used to, but this could be even better under, say, Android. Anyone knows what the state of the NDK nowadays? Would we be able to create apps in mostly Scheme?


-- Stephen

"Kids these days.
Whatever happened to hard work?"

       -- Joel Spolsky, The perils of javaschools



On Tue, Nov 13, 2012 at 4:09 PM, Andrew Pennebaker <address@hidden> wrote:
I see the beginnings of a Chicken Scheme port for Android:

https://github.com/kristianlm/chicken-android

I'd like to see ports for other mobile platforms (iOS, Windows Phone, Windows Surface). I'd prefer to write my mobile apps all in one FPL, and Chicken Scheme would be a fantastic choice.

I'd also like to see more effort put into simplifying the build-to-mobile-app process. csi/csc are incredibly easy and intuitive, and I'd like to see a similar tool for one-step building runnable mobile apps from Chicken Scheme code. Maybe call it csm (Chicken Scheme Mobile)?

Anyone interested?

--
Cheers,

Andrew Pennebaker

_______________________________________________
Chicken-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/chicken-users



_______________________________________________
Chicken-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/chicken-users




reply via email to

[Prev in Thread] Current Thread [Next in Thread]