Scheming on the Pocket PC
I've temporarily adopted a Pocket PC -- and wanted to do something fun on it. Some people suggested I download some games... but there are better things than games. Code! Code is where the fun is. So I tried to find some tools for Programming on the Pocket PC. Not programming for the Pocket PC mind you -- I mean I want to sit on the bus or train and write programs on the tiny screen. There was very little available, or very little I could find. (Got any suggestions?) One thing I found was very intriguing though -- so I downloaded it immediately:
Pocket Scheme -- a
scheme interpreter for the pocket PC.
Scheme is a variant of Lisp (yes... that.) and i've been keen to get further into
lisp (or to escape the nonsense ravings of lisp-nut-jobs and the like ;-)) for a while.
Lately this introduction
to lisp has been my friend.
Within 24 hours of downloading pocket scheme:
As part of dabbling with Scheme while on the train (and without internet access) I decided i needed some Scheme documentation on the Pocket PC. A bit of research told me that 'Teach
Yourself Scheme in FixNum days' would suit my needs nicely.
But screen real-estate is expensive on the Pocket PC. And even scrolling is a pain. I worked out that what I really wanted was just the code samples from the book all in one
page.
This is where it got fun. I decided to write a powershell script to extract all the code
samples and put them into a html file. Any excuse for a bit of powershell ;-)
Here's the basic script:
PS C:\> $webclient = new-object system.net.webclient
PS C:\> 3..23 | %{$page=$webclient.DownloadString("http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-$_.html");"<h2><a
href='http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-$_.html'>Chapter
$_</a></h2>" >> c:\matches.html;get-matches $page "(<pre
.*?/pre>)" >> c:\matches.html }
Oh -- and that also relies on this function, get-matches, which is based on a snippet of Lee Holmes --
Get-Matches
function get-matches (
[string] $content = "",
[string] $regex = ""
)
{
$returnMatches = new-object
System.Collections.ArrayList
$resultingMatches = [Regex]::Matches($content,
$regex, "IgnoreCase,Singleline")
foreach($match in $resultingMatches)
{
[void]
$returnMatches.Add($match.Groups[1].Value.Trim())
}
$returnMatches
}
The result is almost half a megabyte of lisp examples, in neatly
formatted html (zips down to just 23K).
I've written to the author (Dorai Sitaram) to request permission to share the resulting file. I haven't heard back yet -- but if i do, I'll make it available as a download.
Now, about those Games. To increase the WAF, I'll need to find some good games for the pocket PC. Suggestions?
'Peter' on Sat, 14 Apr 2007 05:06:53 GMT, sez: This powershell thingy looks horrible. I myself have switched from Bash to Ruby and never looked back. And both can be used on windows.
'Peter' on Sat, 14 Apr 2007 05:20:40 GMT, sez: I found this on Google Groups. I haven't tried it out (so busy ... job ... baby ... sleep when I can) but I'd be interested to hear if you try it.
Here's the response from http://groups.google.com/group/comp.lang.scheme/browse_thread/thread/4ee6ec93e0aefbad/0cde2c56416b9773?#0cde2c56416b9773
I run Emacs/ispell/ILisp, LaTeX/BibTeX, GNU Common Lisp/Macsyma, SCM/
SLIB/JACAL, gnuplot, and ssh on my cell phone. (I'm probably the only
person in the world to do so.) But I don't diserve the credit. Rainer
Keuchel ported all these (and many more, including OCaml) to WinCE.
His original packaging was for devices with small amounts of memory
and thus had paired down Emacs and LaTeX distributions. Since these
days a 1G sdmmc card is commonplace and inexpensive, my minor
contribution is that I packaged up versions that have a full Emacs 20
distro and a full teTeX distro.
http://www.ece.purdue.edu/~qobi/software/sdmmc.tgz
Enjoy,
'Peter (the 2nd)' on Sat, 14 Apr 2007 05:23:03 GMT, sez: How funny - two different Peters answering an EXTREMELY geeky blog entry at 2am.
'Jonathan' on Sat, 14 Apr 2007 06:36:11 GMT, sez: For the real language geek there is always APL for the pocketPC!
visit here for details & here to buy it.
For when scheme & lisp are just too mainstream.
'Peter {faa780ce-0f0a-4c28-81d2-3667b71287fd}' on Sat, 14 Apr 2007 15:24:15 GMT, sez: And this, my fellow Peters, is why I append a GUID to the end of my name.
As for the PowerShell being ugly and useless, let me address these complaints separately:
1. Leon's highly compressed code above could be extracted into something far more readable. PowerShell was designed to be both a quick-to-write language (like Perl) but also support readability (no comment).
Anyway, what I'm saying is he could have stretched that out to about 15 lines in a text file, and replaced the "%" with a "foreach". At that point it would look almost like C#.
2. Not useless - though it seems to be "just probably as good as Python/Perl/Ruby" for Windows right now, PowerShell v2 will be getting a great deal of cmdlets for interacting with Windows (e.g. replacing the stuff you're currently doing with ipconfig.exe). This is going to be a major thing in the coming years that will be PowerShell-only.
I'd also like to point out that one of my favorite features is that you can type
"cd \\servername\dir\dir\dir" and it will treat the UNC path like a drive!
'Peter that find powershell ugly' on Sat, 14 Apr 2007 17:44:55 GMT, sez: Sorry, I did not want to imply that powershell is useless. I just find that the code either too obfuscated (first snippet) or too verbose (the second one). On the other hand a language like Ruby is not just for writing scripts; and it's also portable.
I don't negate the fact that powershell has more windows specific functionality, but I do not find it being an advantage. I my opinion this stuff should not be language specific anyway and ipconfig.exe approach might be actually better from this point of view. Stuff like this can be added as a library to any scripting language as far as I see.
In conclusion I don't want to bash powershell, but in my opinion your time could be invested better by learning something else.
'lb' on Sun, 15 Apr 2007 04:30:42 GMT, sez: i've noticed the peter who appends a guid to his name... i confess i even googled the guid once, and found that you do this often.
@'Peter that find powershell ugly':
Comeon -- how can you say you find it either too obfuscated OR too verbose. Surely all that means is you find it too versatile?
And re this:
"Ruby is not just for writing scripts"
Like Ruby, powershell can be used for scripts, as a shell, or for applications. The intent of the language is to focus on scripts and shell. The learning curve is very greatly eased by the language.
I recommend learning Powershell, AND Ruby, AND scheme, AND C, AND javascript, AND a whole lot more.
Someone asked me recently: "which is really better, VB.net or C#?" and i realised then just how narrow-minded you have to be to get hung up on a question like that.
also Pete:
re: "I don't want to bash powershell" --
I hope the pun was intentional!
lb
'mike' on Sun, 15 Apr 2007 17:56:14 GMT, sez: Why not use Visual Studio 2005 Enterprise Edition for Pocket PC(tm)?
':)' on Sun, 15 Apr 2007 19:50:47 GMT, sez: Pocket J is cool too:)
J is the successor language to APL
Similiar to Pocket APL, but free:
http://www.jsoftware.com/download/j601c_pocketpc.zip
'William Luu' on Sun, 15 Apr 2007 21:36:08 GMT, sez: Have a look at Pocket C# - http://pocketgcc.sourceforge.net/pcsharp/
Hasn't been updated for awhile, but there is source code available :)
'lb' on Mon, 16 Apr 2007 21:43:14 GMT, sez: i've received my copy of 'the little schemer' now and it's a very enjoyable book.
unlike most lisp writing (and most functional programming writing and most mathematical writing), it's very accessible. it tries to make sure you really understand everything they're saying.
the technique they use for teaching programming could be used for learning other languages. might be worth adopting the technique for a 3 minute to something.
'Peter {faa780ce-0f0a-4c28-81d2-3667b71287fd}' on Wed, 18 Apr 2007 04:55:06 GMT, sez: I'm actually NOT the original Peter who uses a GUID but I've copied and pasted his tag just to spitefully demonstrate the fatal flaw in his scheme: his GUID is not exclusive to him!!!
'lb' on Wed, 18 Apr 2007 05:01:03 GMT, sez: @John, i mean 'wrong peter'
comeon it's not a 'fatal-flaw' -- i mean impersonating his guid like that isn't actually going to kill him.
'game chaos ' on Tue, 15 May 2007 15:03:10 GMT, sez: Cool , I wanted to give it a try too. So someone has managed to get it working, good to know.
Unfortunatly the day has only 24h and I have at least 2 programmer jobs already. I think Lisp / Scheme etc. are cool. They have something zenlike for somebody, who does her programming in the imperative sphere of cpp (this is not my choice) and please do not recommend java or c# as alternative. They are not very much better, they are worse. I want to be free. I hate it, when programming languages constantly tell me, that I am not competent enough to do something, I need to do. Sure fire is dangerous, still everbody loves barbecues in summer and candles in winter. I like Practical Common Lisp, really hands on stuff. And there is a free version on the net http://www.gigamonkeys.com/book/. Yes I know it is not Scheme, but I do mostly Lisp at the moment. With Lisp in a Box it is easy to set up and I really like the book.
There are no good games on the PocketPC. They have the bad of the PC (lots of different hardware versions) combined with the bad of consoles like Nintendo DS (no computing power). And there is practically no market to sell (or give away) your game. Oh and most of them do not have control keys one can use in games. So if people (geeks) want to dev small they try Nintendo DS, GBA, PSP or one of the open consoles like Gp2X. If they like to torture themselves, they try to make games for mobiles. Small, lots of different hardware, but at least there is a market and big companies, who like to finance you. And lots and lots of young users, not like the PocketPC, where the user base is adult and business.
'Nick' on Sun, 11 May 2008 15:44:08 GMT, sez: I use Rebol on my phone, and love it. Rebol can be applied to so many different problem domains, and it's incredibly easy to learn. I wrote a tutorial to help average computer users do useful things with it:
http://musiclessonz.com/rebol_tutorial.html
The Rebol interpreter is tiny, the language is elegant, and it's so easy for even average computer users to learn. It's got native network connectivity and many useful data types built in, CGI interface, database connectivity, unique data parsing features, a consistent and easy learning curve. Sripts run unchanged on 40+ platforms. It's a shame so few people even know it exists...
|