Sunday, January 31, 2010

“Hello Glade#” from F#

Another bit of spiking, a rather tardy follow up from raw GTK#, starting from the C# example at the Mono Project site, but incorporating the earlier example, so as to build in a clean application exit, for one thing.

In the .glade file, I changed the label size from 38, as in

<widget class="GtkLabel" id="label1">
       <property name="width_request">38</property>

to 88, so as to allow the displayed text to be longer.

In VS2008 I added the .glade file by including a new F# script file, but renaming it to, pasting in the XML, and setting its properties to have a Build Action of Embedded Resource. The code looks like:

Here the widgets are surfaced via a plain data object, Handler, and their events are wired up much as before via F#'s first class reactive events, which are much more natural (especially when combining events to one handler is required). The project needs a reference to the glade-sharp assembly, above and beyond the ones already required for pure GTK#

Unfortunately, the need for CLR attributes on members is problematic for IronPython -- the least nasty way to achieve the equivalent of the Handler class would be to compile some C# on the fly.

Unchanged by version, February 2010 CTP.

Unchanged by version 3.1.1, January 2014 (except that Add Existing Item works better for the .glade file in VS2010 and up).

Monday, January 18, 2010

Hello, Functional World! -- A gap in the market

Reading my newly arrived copy of Real World Functional Programming, I couldn't help but feel that its very gentle introduction to the style so nearly makes it suited to being a pure introduction to programming via the functional style, if only it were not for the compare/contrast with an assumed fluency in C#; in the same way that Scala texts do with Java.

If functional programming is the up and coming thing as it is seeming to be, wouldn't it be nice to have a book at the level of, say, Hello World! or Python Programming for the Absolute Beginner? Something which really does start teaching programming in a functional way from the ground up, and, moreover, try to make it fun for youngsters by bringing in some eye-candy in the form of games. That rules out SICP, or even the Little Schemer, which is very abstruse for all its wry humour.

So what has a games platform? With F#, we can use either the old managed DirectX, or XNA, but those are very tied to Windows; Scala or Clojure could tie into the MIDP with phone emulators; at a pinch, you can write games in wxWidgets and might be able to do something with wxErlang. Masochists have even tried writing GUI games in Haskell. So it's not as if there is a dearth of possible languages to work with, even if they may not approach having something like PyGame to do a lot of the heavy lifting.

Possibly the main limit is in tooling -- no integrated chroma-coded REPL like IDLE offers for Python. There are chroma-coded editors with some shell integration -- Scite has Erlang mode, Scala comes with in Scala\misc\scala-tool-support\scite (though you may need to edit the command lines in it to have an explicit .bat on the scripts -- but pretty much every instruction I see for anything on MacOS X starts with "Download Xcode ... its little over 1 GB." -- well, I exaggerate; not all the instructions mention the sheer size of the bundle. Even instructions for setting environment variables reach for Xcode, which puts a big burden on top of setting up Scala-on-NetBeans, which would otherwise be comparatively lightweight.

But wouldn't it be great to start beginners off without mutability and iteration?

Sunday, January 17, 2010

Review catch-up — Anime

Asura Cryin' second season

For the first half at least, it carried on as before, throwing ever more stuff into the pot every episode; before suddenly deciding to pick one of the multiplicity of minor characters, nominate them as Final Boss, and go for the sort of ending which clearly wanted to be Gurren Lagann when it grew up, with our hero doing a "Man up and save the world! Twice!" before reverting to schoolboy with harem end.

Overall: showy trash.

Mouryou no Hako

Despite my worst fears, this best series of 2008 finally got subbed in dribs and drabs over the year, with the concluding episode available only a year after the fact.

And, suprisingly, the conclusion was a remarkably satisfying one.

In all, this series felt more like cinema; but with the length -- and the seamless SFX -- that the 13 episode animated format afforded being used to advantage.

One of the very best of the decade, and probably the best of 2008.

My top 20 of the Noughties

In alphabetical order:

Blue Drop ~Tenshi-tachi no Gikyoku~
Chi's Sweet Home
Dennou Coil 
Ghost in the Shell: Stand Alone Complex
Hataraki Man
Kino's Journey
Mahou Shoujo Lyrical Nanoha
Maria-sama ga Miteru
Mouryou no Hako
Nijuu Mensou no Musume
Princess Tutu
Ristorante Paradiso
Seirei no Moribito

2009 -- the rest

A thin year -- total number of new series I watched was about the number I picked up for Q2 '08 alone -- but one where Crunchyroll expanded its operation enough that, love them or loathe them, I was able to watch a good number of series in a context other than "try before buy" (even if some of the advertising was terribly, terribly bad and repeated 3+ times per episode).

I'll get to Kemono no souja Erin and Miracle Train as and when I finish; but they aren't exactly burn through to marathon types of series. Tried and dropped were Sasameki Koto -- the other yuri series of the year started with so many school clichés, the sort of things that Aoi Hana avoided, that I gave up after a few minutes. Falling into the "who are these people and why should I care about them?" and the "Oh, my eyes, the CGI!" traps was the Book of Bantorra -- I just have better things to do than the second episode.

Although I raved about the novel adaptation of Mouryou no Hako, the material in Aoi Bungaku led off with the sort of self-indulgent self loathing material that too often passes for literary merit for my tastes, so I gave that a miss; and it took only a couple of episodes of Kūchū Buranko to decide that, literary provenance and associations with Mononoke be damned, under the psychedelia, this was boring and repetitive.

Also belatedly tried, and dropped like a brick:


I bought this a while back, after watching Serial Experiments Lain and Haibane Renmei, but had never found a gap to watch it in. Such a gap arose about a year ago; and I wish I had not wasted the money, but had instead done a "try before buy". Had I done so, after a first episode with essentially no dialogue or narrative structure, that just spent its 25 minutes waving its art in my face, I would have stopped. As it was I went "Next Episode", expecting perhaps more of the same and instead suffered through effective animation used for malign ends. Each time I thought things had bottomed out, the clinically sadistic depiction of some person suffering massive and essentially self-inflicted (by interfering where self-preservation would have held up a massive "KEEP AWAY" sign) injuries went on and got worse.

It is perhaps a tribute to the skill involved that I ended up queasy, with cold sweat, but having massively failed on the "who are these people and why should I care about them?" test -- mainly because there has been no time spent on such persiflage as who they are because "it's, like, Art, man!"; and depicting them as it does as undeserving of sympathy, it had not only failed to intrigue, but had completely discouraged me from wondering what happened next. So while I dropped Baccano! after a similar amount for just being nasty, this I dropped for being actively evil. Definitely the worst of the decade of those things I watched.

An interlude of thaw

Finally a few mild days, and the heap of snow shovelled from the drive has finally melted, leaving the garden snow free after a whole month. The milder weather and the sun was enough that the greenhouse windows even started to open a little, very comfortable when harvesting the chillies. Having layered bubble-wrap over them and the other tender plants that live on the patio in the summer, and just keeping that little tent frost-free, seems to be preserving them in generally good shape, except those branches closest to the glass.

Of course, with the thaw, it's back to raking up dead leaves, and piling them on the part of the garden where I need to dig in some more organic matter; and to look at the lawn and think that it's a couple of months at least yet before I can sensibly apply a much needed moss treatment.