## Archive for the ‘Scheme’ Category

### Android and Kawa

Thursday, January 17th, 2013

Anyone who enjoys functional programming is going to have a rough time on Android. You’re basically locked into Java because most of the functionality of the OS, the UI for example, isn’t exposed to C code. So it’s time to find a Scheme implementation that works on top of davlik. Turns out Kawa works pretty well and it’s blazing fast. Unfortunately there really isn’t enough information out there about how to use it, Kawa’s documentation leaves much to be desired and its error messages can be beyond cryptic.

I translated some examples from Java into Scheme and set up some scripts to help with setting up new projects, you can everything on github. At the bottom of the readme file I documented some of the more exciting error messages. Even though I tried to stay at close to the original Java as possible, even when it felt pretty disgusting, I couldn’t help myself in some cases. Take starting a new thread. In Java that takes several lines and a new class, and due to the lack of macros can’t really be shortened much. In scheme with a trivial macro this becomes simply (thread code ...). It doesn’t get more beautiful than that. I’ll be putting up a full Android application sometime in the near future.

### 240 eggs for the n900

Wednesday, April 14th, 2010

My laptop has been keeping my room nice and toasty for the past few hours and now 240 chicken eggs are available from the repository! That’s out of my list of 290 eggs. A caveat, these are all entirely unmodified with dependencies automatically migrated into the deb. This means that the eggs depend on each other correctly but eggs can’t record dependencies on external packages; so you can install an egg and not have the appropriate deb package from the standard repositories. I don’t particularly want to go through 240 eggs and record this, so we’ll have to live with this situation for now. It shouldn’t affect many packages anyway.

In the process I’ve built the most inefficient package manager that I could, it finds the fixpoint of a function which filters out working packages from a list. Oh well, at least it’s short.

OpenGL is one of the reasons why many of the packages fail to build. Unfortunately the n900 only provides OpenGL ES which eliminates a lot of the fixed pipeline and changes almost entirely to a programmable one. That means a lot of the old OpenGL API was removed. Until someone comes out with an OpenGL layer for the n900 this this won’t be available.

srfi-19 doesn’t build, which knocks out most of the remaining packages. setup-api looks in the wrong place for the srfi-29 bundles, I’ll have to look into it at some point.

You can find a list of all the eggs and their statuses here.

### n900 voice recognition

Tuesday, April 13th, 2010

The n900 really needs some sort of voice recognition. While the keyboard is nice, it’s sometimes a real pain and I really just want to be able to tell it ‘find all restaurants nearby’ or ‘call X”. There are a few options when it comes to voice recognition, I think the most likely to work well enough is CMU Sphinx especially now with the advent of pocketsphinx. pocketsphinx is specifically designed to be small and fast and it seems to deliver on both points. I build the pocketshpinx libraries for the n900 (patches to the upstream version of pocketsphinx are available here) and I’ve been playing around with them for the past two days. The accuracy is good enough and integration with the rest of the system so that you can give commands like switch task should be doable. To test things out and get my feet wet I’ve been using a quick python script called voximp, it’s simple to set up and it’ll let you issue commands immediately.

The new packages are available from the standard optified repository: gstreamer0.10-pocketsphinx, libpocketsphinx1, libpocketsphinx-dev, libsphinxbase1, libsphinxbase-dev, pocketsphinx-hmm-en-hub4wsj, pocketsphinx-hmm-en-tidigits, pocketsphinx-hmm-zh-tdt, pocketsphinx-lm-en-hub4, pocketsphinx-lm-zh-hans-gigatdt, pocketsphinx-lm-zh-hant-gigatdt, pocketsphinx-utils, python-pocketsphinx, python-pocketsphinx-dbg, python-sphinxbase, python-sphinxbase-dbg, sphinxbase-utils.

Hopefully I’ll get around to wrapping all of this in scheme bindings and a gui sometime soon, and now that I have MCE bindings I should even be able to implement placing calls by voice tags.

### Maemo split & MCE support

Monday, April 12th, 2010

The main holdout to submitting the qt egg back into chicken have been the Maemo bits that crept in. Now all of that code has been moved into its own, chicken-maemo, egg so hopefully I’ll get around to submitting diffs against svn to the list later today.

With Maemo having its own egg I don’t feel bad extending adding in support for more of the basic infrastructure anymore. Now we have a full set of bindings to MCE over DBus, aside from the stackable windows, notes, banners, and orientation control that we had before. This means accelerometer data, calling, vibrator support, locking various aspects of the device, using the leds, and more. Sadly I still haven’t figured out how you generate documentation for eggs.

I’ve also built my first app that will see real-world usage. My advisor is a session chair ICRA and he wanted an application to manage speaker time during it (they’ve got this 12 (talk) + 2 (questions) +1 (cleanup) minute format). This also brought up an interesting problem of how device rotation is going to work when the guy needs to change its layout, I’ll have to investigate further. Now that the MCE bindings exist, I should add things like vibration and manging the screen state. Still, it’s not a bad app for an hour of work and it’s a decent demo so it lives in the chicken-n900 repository as test4. Obligatory screenshots follow.

### New eggs & networking

Saturday, April 10th, 2010

I recently added a whole bunch of new eggs: check-errors, doctype, easyffi, eggdoc, filepath, fmt, foreigners, html-parser, htmlprag, input-parse, iset, json, matchable, message-digest, miscmacros, numbers, packrat, protobj, rss, setup-helper, sha2, silex, sql-null, sqlite3, ssax, sxml-transforms, sxpath, synch, test, utf8 and yelp. These are all unmodified and just running the debianize-egg script on them suffices so I didn’t need to import them into my code repository. Adding in this optified repository on your n900 and doing an apt-get chicken-eggname will fetch the egg and its dependencies. Hopefully all eggs will be available soon once I finish the autobuilder script.

chicken-qt got networking support recently, nothing fancy just HTTP Get for now. On the upside it integrates well with Qt so it’s asynchronous by connecting to something like the done() signal. Check out tests.scm for an example.

### Chicken on the Nokia n900

Wednesday, April 7th, 2010

For the past two weeks or so I’ve been working on getting Chicken scheme up and running on my brand new Nokia n900. The n900 is really lacking a lot of apps and it’s time to have an environment to quickly develop them. Python isn’t an option, try out gPodder and see your device slow to a crawl and your battery drain, so Scheme it is. Things are looking rather good and in the process I’ve expanded the qt egg, hopefully it can leave it’s tech-demo status now.

Some highlights:
– support for QObject attributes
– QVariantList and qvariant are supported so interfacing with qt is a
lot more natural
– removed the simple receiver and replaced it with an object that
crafts the correct slot on request
– arbitrary number of arguments to slots and support for some common
argument types (although notably pointers aren’t yet handled)
– invoking arbitrary qt methods/signals/slots
– support for qt-maemo (stackable windows and various information boxes)
– it now builds in C++ so that making bindings is faster
– qt-dbus is now supported so that polling isn’t required, it too
works with an arbitrary number of arguments and provides all of the
basic capabilities: receiving/sending dbus signals, method
invocation, and exposing methods over dbus
– 0% cpu usage when idle so it’s battery-friendly
– it’s debianized along with its dependencies so that it can be
deployed to the n900
– ported the dbus egg to version 4

The updated qt & dbus eggs along with debianized versions of their dependencies are here. There’s also a tiny script for quickly debianizing eggs with correct dependencies, perhaps someone is interested in reviving the debianization effort.

I’m new to low-level hacking with chicken, so hopefully I haven’t abused the ffi/gc in some horrendous/unsafe way.

I’ll try to keep http://0xab.com/n900 current with new progress.

Hopefully I’ll figure out how one documents eggs these days, split off maemo stuff into its own egg and get around to contributing these back to the main egg repository.