Psellos
Contemporary Development With Functional Programming

Gamut Redivivus: OCaml App in iOS Simulator

April 29, 2015

I recently revitalized an OCaml app from a few years ago, one that runs in the iOS simulator. Instructions for downloading, building, and running the app are here:

Gamut: Explore Colors in iOS Simulator

You can download the sources directly here:

Gamut 2.0.3, OCaml app for iOS Simulator 8.2 (32 KB)

Although the app doesn’t do anything particularly impressive, I still find it mesmerizing and fun. But mostly it just shows how to get an OCaml app running in the iOS Simulator.

Here are some insights I had while revitalizing the app:

  • When calling OCaml from the Objective C world, don’t pass expressions as parameters if they cause allocation in OCaml. I wrote about this in Further OCaml GC Disharmony.

  • The geometry of an iOS app needs to be a lot more fluid than it used to be. Statically, there are many different device sizes. But also the shape of the screen changes dynamically at times. Believe it or not, I recoded Gamut so the display continues to look good when you receive a simulated incoming call. (A small change in such a simple app.)

  • It would be frightening to receive a simulated incoming call and find that it was a simulated version of your mother calling from your childhood to say that dinner is ready.

  • You can re-use the drawing code of your app to draw an icon with a more squarish shape.

Now, reader, I have to rush off to my desk in an arcane underground DNA lab to learn about general-purpose GPU-based processing. It would be a blast to see it work in an iOS app someday. If you have any trouble (or success) getting Gamut to work for you, leave a comment below or email me at jeffsco@psellos.com.

Posted by: Jeffrey

Comments

blog comments powered by Disqus