Saturday 30 January 2010

Easing compatibility with Grease

Photo by DarkSide, sxc.hu

In December, I gave a presentation on portability to the NYC Smalltalk group. Seaside now runs on at least seven different Smalltalk distributions. Given the lack of standardization, this is no minor feat; for Seaside’s developers, the need to keep code portable is always on our mind. As a result, we have gradually accumulated a set of tools, patterns, and conventions to help keep our code as portable as possible and to factor out code that needs to be implemented differently on each platform.

In our work on other projects, we found the same portability challenges came up over and over and we wanted to use the tools we had developed for Seaside to address them. So we began to split out the Seaside-specific functionality, allowing us to leverage the generic parts it in our other work. And thus Grease was born.

So what exactly is Grease?

  • Grease enhances the ANSI Smalltalk standard. With only a few exceptions, we assume platforms are fully ANSI-compliant. Platforms want to support Seaside and standardization makes this easier for the project’s developers and its porters.
  • Grease defines expected APIs with unit tests. Platforms can quickly determine if they are compatible and users can examine the tests to determine exactly which behaviours they can count on.
  • Grease takes a pragmatic approach to compatibility. Sometimes a method behaves so differently on two platforms, for example, that we are forced to avoid it or to standardize on a new selector. To get standard exception signaling on all platforms, Grease is forced to provide special exception classes that can be subclassed. Sometimes we need to put “right” aside and settle, instead, on a solution that can be implemented everywhere.
  • Grease tries to be concise and consistent. Despite its pragmatic approach, we still want to be “right” as much as possible. Because it’s hard to remove functionality once it has been added, we need to carefully consider each addition before proceeding. We’re moving slowly and looking for methods that are commonly used and that have clear names and semantics.
  • Grease does not try to solve all problems. We are not testing Sockets or HTTP clients. We don’t expect platforms to have standard SSL or graphics libraries. Its scope may grow over time, but for now we’re focusing on extending the functionality of the core classes defined in the ANSI standard (collections, exceptions, streams, blocks, etc.) and on other pieces of functionality that are critical to the Seaside project (e.g. random number generation and secure hashing).
  • Grease is widely adopted. Implementations exist already for all platforms that support Seaside 3.0. As well as Seaside, new versions of Magritte, Pier, and Monticello are already being implemented on top of Grease.

If you’re developing on Squeak or Pharo, you can also benefit from Slime, which uses the Refactoring Browser to find and, in some cases, rewrite common compatibility problems. Think of Grease as defining what you can write and Slime as defining what you can’t. It would be nice if Slime could be extended to other platforms, but their RB implementations are currently not compatible enough (a perfect target for Grease!).

Grease will continue to be part of the Seaside project and to be driven, for now, primarily by Seaside’s requirements. But we hope other projects will find it increasingly useful over time. Since each platform has already ported it, you may already be able to leverage it to provide increased consistency and portability for your applications. For the moment, consider Grease a prerelease and subject to major change; it will track Seaside releases for now, though I’m thinking of assigning independent version numbers to Grease releases to make things clearer.

The Grease packages can be found in the Seaside 3.0 repository or through your vendor's standard code distribution mechanism.

Monday 25 January 2010

Happy Australia Day!

Sure it seems like January 25th to the rest of us, but in that upside-down land across the Pacific, it's already the 26th, the anniversary of the First Fleet's arrival in Sydney Cove in 1788. And that means barbecues, more beer than usual, and "back yard cricket" (don't ask—I never even got the rules of normal cricket).
While in Australia, I developed a soft spot for their national holiday and their stereotypically easy-going form of celebration (also for the Southern Cross, but that's another story). On top of that, several close friends have recently moved down under, so in honour of their first Australia Day, I thought I'd post a couple of "iconic" images from my collection (click the image above).
To all of you in Australia or with a bit of it in you, Happy Australia Day!

Sunday 24 January 2010

Facebook time

I was poking through some of Seth Godin's eBook What Matters Now this afternoon (apparently, in my case, it didn't matter until 6 weeks later). I like this message from Howard Mann:
There are tens of thousands of businesses making many millions a year in profits that still haven’t ever heard of twitter, blogs or facebook. Are they all wrong? Have they missed out or is the joke really on us? They do business through personal relationships, by delivering great customer service and it’s working for them.
How much time are you spending with your customers?

Sunday 17 January 2010

Chinese Feast


Last weekend, inspired I guess by a fancy gas stove and now long-glorified reminiscences of China, I decided to attempt a four-dish Chinese dinner. I have previously tried hand-pulled noodles and boiled dumplings, but this meal was all about the wok. Altogether, it took about three hours of washing, chopping, dicing, kneading, marinating, deep frying, boiling, and stir frying. Given that this is the sort of meal people eat in China on a regular basis, I can only hope that the process gets faster once you have the recipes internalized.

My companion through most of this was Yan-kit's Classic Chinese Cookbook by Yan-kit So, which I once read is the best overall Chinese cookbook out there. It has a very helpful section at the beginning that illustrates all the ingredients, the different ways to chop them, how to stir fry them, and so on.

I decided to try out my new f/1.8 50mm prime lens to capture the results but, as the depth of field was even shallower than I expected, the focus in many of the images just didn't work out. The images here are the few that were passable.

The menu was as follows:

Scallion Cakes (蔥油餅, cōngyóubǐng "scallion oil biscuits") are apparently a common street food across China, though I don't specifically recall seeing them. A simple dough is rolled flat then topped with salt, scallions (green onion), and lard or margarine. The whole thing is rolled up, twisted, and then flattened to form a thick, filled pancake which gets fried in a skillet. The end result was pretty satisfactory, though I would have liked a bit more salt, and they tasted even better out of the fridge the next day. Page 178.

Dry-fried Four-season Beans (干煸四季豆, gānbiān sìjìdòu) is a typical Sichuan dish that really lets the crispy green beans shine. The beans were first deep-fried before being stir-fried with the rest of the ingredients. I left the preserved vegetable out because I didn't have it and the dried shrimp because I was feeding a vegetarian. Still, it was delicious. Most people have a fear of deep-frying, but it's actually pretty straightforward and not too greasy if the oil is hot enough. Page 220.

Kung Pao Tofu (宫爆豆腐, gōngbào dòufu) is a variation on the well-known Sichuan spicy chicken and peanut dish, simply replacing the meat with deep-fried cubes of tofu. We ate this quite often in Beijing and, although I've made it a couple of times, I find the result tastes too strongly of soy sauce. I'm not sure yet if I just don't like the particular recipe, if it's a result of not having quite the right ingredients, or if the tofu simply soaks up a lot more of the marinade than the chicken would. You can buy packaged deep-fried tofu in some stores to save deep-frying it yourself. Page 102.

Di San Xian (地三鲜, dìsānxiān "Earth three fresh")—a mixture of twice-fried potato, eggplant, and green pepper—was one of our favourite dishes in China. The cookbook doesn't have a recipe so I used this one and the result was delicious and very authentic.

For those in Vancouver looking for an easier alternative, I ate last night at the Golden Sichuan Restaurant on No. 3 Road in Richmond. This place was recommended to me years ago by Chinese colleagues but I never made it out there until now. We had the dry-fried beans, a mushroom and pork dish, and some pork and green onion dumplings. All were delicious. The restaurant's Chinese name, 老四川, and its translation are interesting. The last two characters 四 (, four) and 川 (chuān, river) form the name of the Sichuan (or Szechuan) province. The first character 老 (lǎo), means literally "old" or "revered" but can also be used as a prefix to indicate affection, much like you could use "my old man" to refer to your father in English. It's also the first character in, e.g. 老家 (lǎojiā, place of origin), 老师 (lǎoshī, teacher), and 老外 (lǎowài, foreigner). You overhear that last one a lot as you walk around China.

Wednesday 13 January 2010

Google re-evaluating its position in China

Google made an interesting announcement today about their approach to doing business in China. Apparently they intend to take a stand again and stop censoring the results on google.cn, even if this means they are prevented from conducting business in the country. I think the unstated message is that Google believes the "attacks and the surveillance they have uncovered" were conducted from within the Chinese government and this has prompted their change in stance (or at least, I can't follow the logic of the article any other way).

Somehow I don't see the Chinese government doing anything more than shrugging its figurative shoulders, but it will be interesting to see what, if anything, is the fallout.