I was inspired to try to get a version of Forth running on my cell phone. I've had quite a bit of success developing small Scheme programs on my Galaxy S5 and was curious if I could manage the same thing with Forth.
I installed gforth from Google Play hoping that it would be a solid implementation. Unfortunately, I was met with a non-functional mess:
Besides spitting out the debugging statement log: setComposingRegion, the app didn't do much more. That is, until I switched keyboards. I changed from Swift Key to the keyboard that comes with Terminal IDE. Ahhhh, much better:
Now we were talking!
Poking around, I learned that there's quite a few Forth files to be had in: /sdcard/gforth/site-forth. Between browsing those files, and looking at the gforth manual, I came up with the command:
Running that pops up this graphic:
I don't know what to make of this, other than the fact that gforth isn't just some half-baked toy. This is a real forth implementation, with some impressive features (assuming of course that I can unlock them).
All of this was optimistic, but I was still not sure I could turn this into a mobile friendly dev environment. Taking a cue from my Scheme workflow I setup the following:
First, I created a keyboard shortcut that allows me to type Alt-o and be dropped into Forth. With the existing keyboard shortcuts in place, I can type Alt-M to switch to an editor Alt-o to switch me back to gforth.
Next, I created a file named .gforthrc in:
and put the following contents in it:
." BAS init " cr : lex ( - ) s" /sdcard/Documents/ex1.fs" included ;
That code doesn't do a whole lot other than announce that the file was executed setup the word lex for me to use. .gforthrc is a magic file, in that it gets loaded anytime gforth is started up.
The lex word, like the scheme equivalent (lex), loads a specific exercise file. In this case, /sdcard/Documents/ex1.fs. This allows me to open this file up in the editor, make changes, switch to gforth and type lex to reload in this file.
I've got a nice edit-eval loop, and when I'm done I can copy ex1.fs into a local git repository for archiving.
I've got to say, the setup truly works!
For now, I've been refreshing my Forth basics by going through the gforth tutorials. Though, I'm eager to tackle the Christmas Programming Praxis challenge, which involves solving 6 'ancient' algorithms. Should be the perfect way to freshen up my Forth skills.
At a minimum I can say this: gforth on Android rocks.