Showing posts with label Shoes. Show all posts
Showing posts with label Shoes. Show all posts

Monday, 29 December 2014

Raspberry Shoes Update

I haven't written anything about Raspberry Shoes in a while. The reason is that Raspberry Shoes still feels a long, long way away.

The route that was most attractive for me was Shoes 4 which is written for JRuby and the SWT cross-platform GUI toolkit. Last time I wrote I was quite optimistic, I had JRuby working on the Raspberry Pi. Shortly before then, the Shoes 4 team announced a pre-release Gem that would have made installing Shoes quite straightforward on Raspberry Pi. However, after installing the Gem I found that the Ruby SWT Gem upon which Shoes 4 relies only installs Intel versions of SWT. It seems there isn't an official ARM version of SWT. So, for the foreseeable future, it is unlikely that Shoes 4 will run on Raspberry Pi.

As an alternative, I installed the Green Shoes Gem. Green Shoes is a version of Shoes that uses the GTK2 GUI toolkit. It didn't work and so far I haven't spent anytime trying to figure out why. That's because Green Shoes is understandably no longer maintained in the light of Shoes 4.

One option that came to mind is that I could build Raspberry Shoes by forking Green Shoes and convert it to use GTK+3 (which, in the long term, I presume will be better supported on Raspberry Pi than GTK2). However, I very much doubt that I have the necessary skill to get it done in the time I have available. (I'm confident that I could do it if I put enough time into it.)

I even had a "if you can't beat them, join them" moment and thought that perhaps taking the easy choice, Python, would be better than trying to use Ruby. Then I saw a couple of Raspberry Pi Python code snippets. They were enough to convince me that Ruby will be much easier for a child to learn.

At the moment, I am undecided on what to do. Another language which can be even easier for beginners and in which I am more fluent than Ruby will be coming to Raspberry Pi soon. The language is Red. It is very highly influenced by Rebol. It is currently at the "alpha" stage and is expected to reach "beta" stage sometime next year. 

In the meantime, I'll try to spend a little time with Ruby and GTK+3 to see if I can come up with something for our seven year-old to follow on from Hello Ruby when it eventually arrives.

Friday, 5 September 2014

Installing JRuby on Raspberry Pi

I am persisting with my project to get Ruby Shoes 4 up and running on my Raspberry Pi. I really believe that Shoes will be a great medium for kids to learn programming. I've now completed the next step, getting JRuby up and running on Raspberry Pi.

I'm using rbenv to manage my Ruby installations on my Raspberry Pi as I explained in Installing Ruby on Raspberry Pi.

Of course, you need Java to install and run JRuby. I've found that there is a bug with the OpenJDK version of Java that stops JRuby working. So I installed the Oracle version:

sudo install oracle-java7-jdk

After installing Oracle's Java, like me, you'll probably end up with multiple versions of Java on your Raspberry Pi. Thanks to Bill Connelly for dropping a big hint on the Raspberry Pi forums, I was able to easily set Oracle's Java as the default by running the following commands and selecting the correct option:

sudo update-alternatives —config java
sudo update-alternatives —config javac

After that I simply had to use rbenv to install version 1.7.13 of JRuby:

rbenv install jruby-1.7.13

It takes quite a while and keeps the Raspberry Pi fully occupied during the installation but you can leave it running and come back later.

I installed JRuby 1.17.13 instead of the newer JRuby 1.7.14 as there was a warning on Shoes 4 GitHub that there is an issue with the newer version.

As I have Ruby 2.1.2 as the default Ruby on my Raspberry Pi, I set up a new directory, shoes, in which I set JRuby as the default. These are the commands that I used:

cd ~/raspberryruby
mkdir shoes
cd shoes
rbenv local jruby-1.17.13

Finally I launched JRuby:

~/raspberryruby/shoes$ ruby -v
jruby 1.7.13 (1.9.3p392) 2014-06-24 43f133c on Java HotSpot(TM) Client VM 1.7.0_40-b43 [linux-arm]

When you run JRuby, it takes a long time to load. I think this is not just because of the time to load the Java Virtual Machine in which JRuby runs but also due to a small bug that results in JRuby displaying the following warning:

pi@raspberrypi:~/raspberryruby/shoes$ irb
Java HotSpot(TM) Client VM warning: You have loaded library /home/pi/.rbenv/versions/jruby-1.7.13/lib/jni/x86_64 Linux/libjffi-1.2.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
irb(main):001:0> 

The warning doesn't have any adverse effect on JRuby, everything works as expected. This bug has already been reported to the JRuby team and hopefully will get fixed soon.

Now I can start on getting Shoes to run on my Raspberry Pi. 

Wednesday, 9 July 2014

Raspberry Shoes

As far as I can tell, one of the motivations behind the development of the Raspberry Pi was the experience of actually typing code into a computer before you could play a game. The computers of those days such as the Acorn/BBC computers, the Sinclair range and others had languages with built-in access to the computers screen. There was no need to import and make calls to massive external libraries as is the case with most languages today.

There are a few exceptions  around, Rebol for instance. The stable version, Rebol 2, is not available on ARM processors. It's modern replacement, Rebol 3, which can run on ARM is still being developed, though progress is very slow. By the time it reaches version 1.0, the Red Programming Language will include easy to use access to the computer's screen.

Another alternative is Ruby/Shoes, a version of Ruby with built-in graphics. It seems to have taken a lot of inspiration from Rebol's approach. The first three versions of Shoes were written in C with a specific version of Ruby builtin. The latest version of Shoes, unsurprisingly Shoes 4, has been re-written from the ground up in Ruby. Actually it has been developed for the Java-based JRuby and uses the graphics features made available through Java.

I think I'll try to install Shoes 4 on my Raspberry Pi and see were it leads. It would be really good to have a simple way of programming graphic applications on the Raspberry Pi.