Dale's Anti-Language Lawyer Rule
I missed today's OCI internal C++ lunch meeting. However I caught the email thread that ensued about a piece of C++ code, the meaning of which was not agreed upon in the meeting. Kevin, the good C++ language lawyer he is, checked the standard and send out the email. Dale followed up on the email:
Kevin wrote: > > So, in short, I was wrong again. As was I, but I still think the code is bad. :-( Dale's anti-language-lawyer rule: If you have to consult the standard to see if the code is correct, then the code is incorrect. > > KevinH
I just thought the world would be a better place if more people followed Dale's rule.
Impressed by Groovyblogs.org
Graeme Rocher: That Grails site building phenomenon Glen Smith, the man who brought us Grails+Lucene powered search engine Groogle, has completed his Grails 20 hour challenge to build a feature rich blog aggregator.
The result, although still requiring some minor tweaks, is impressive. Well done Glen! Grails-powered Groovyblogs.org has (almost) arrived!
Although not officially launched, the site looks impressive. I signed up. (It's a good thing that my Pebble blog engine [Update: not mine, but Simon Brown's Pebble blog engine that I'm using to power this blog] has tag specific feeds in Navigate->Tags.)
Microsoft Evangelist Interviews Corba God
Not really. It's just an interview of Steve Vinoski, formerly of IONA and now at a stealth mode startup, by Jon Udell, formerly of Byte and InfoWorld and now at Microsoft, from an undisclosed location.
Here's a few points that I find interesting:
- Steve's story about his transition from "IIOP is going to be built into the Netscape browser and we can do distributed objects across the web" to "the web is distributed objects"
- Jon's musing about "freeze-dried" VM machine instances being the new unit of distribution
- Their agreement that tools support for WS-* and REST are important and there are no industry leadership for REST tools
Bloglines And Google Reader Side By Side
I'm not known to be a quick switcher. The reason is usually because switching means learning anew, and I'm a slow learner. And I usually am not motivated to learn new ways of doing things that I already know how to do the old way.
This put me on the backside of the adoption curve. And sometimes I become the last ones leaving a tool. And that's fine with me. That's why I haven't switched to Macs (although being surrounded by a bunch of MacBook Pros does have its effect. (id o = [[NSObject alloc] init])). That's why I haven't switched to Ubuntu from Fedora Core (although the inevitable is fast approaching). That's why I'm still watching over-the-air television on a low-def set, etc.
So in the Bloglines vs. Google Reader race, I've stuck with Bloglines.com, for no other reason than that I already know how Bloglines.com works. However I've had some issues with Bloglines.com lately, one I already mentioned 49 days ago (which, come to think of it, might have been fixed already because I haven't experienced the problem recently), and another that I haven't mentioned here, but reported to Bloglines.com. This other problem causes Firefox to spin to 100% CPU (50% on my hyperthreading box) on Windows and not to exit even when the close button is clicked (the Firefox window will go away, but the process remain running at 100% CPU).
Being the conservative that I am, I will try running both Bloglines.com and Google Readers at the same time. Actually Dean's comment the other day prompted me to add Google Reader to my Firefox home pages.
So I'll be using Bloglines.com and Google Reader in parallel for the next few weeks. And I'll decide whether to switch at the end.
A few questions I have right away are:
- Is there a Google Reader subscription bookmarklet?
- Can Google Reader give me a list of my subscriptions so that I can include them in my blogroll?
- How do you "mark all as read" in Google Reader?
Re: Google Reader vs. Bloglines Market Share
Bob Lee: Apparently I'm not alone in my switch to Google Reader. Now that it started reporting subscriber counts, I see 34% of my subscribers use Google Reader while only 25% use Bloglines. Good news travels fast.
I took a look at my log files and found out that Bloglines and Google Reader are not the only service that reports subscriber counts. Here's a breakdown:
| RSS | Atom | Total | |
|---|---|---|---|
| Feadfetcher-Google | 64 | 16 | 80 |
| Bloglines/3.1 | 58 | 15 | 73 |
| NewsGatorOnline/2.0 | 12 | 4 | 16 |
| Zhuaxia.com | 3 | 3 | 6 |
| Rojo | 5 | 5 | |
| Newshutch/1.0 | 3 | 3 | |
| AlestiFeedBot/0.7 | 2 | 2 | |
| NewsAlloy/1.1 | 1 | 1 | |
| kb.Rmail | 1 | 1 |
So the number of people who use Google Reader to read my blog has indeed surpassed the the number of people who use Bloglines.
Considering that my Bloglines subscriber count hasn't increased that much in the last couple of years, it indeed looks like Google Reader is rolling over everybody else on its way to becoming the number one RSS aggregator.
I'm somewhat surprised by the relative popularity of RSS against Atom. This simply doesn't jive with all the talkings about Atom on the various high volume blogs.
Happy Chinese New Year
Today, Sunday February 18, 2007, is Chinese New Year. The Year of the Dog ends and The Year of the Pig begins.
恭喜发财! 过年好!
In keeping with my tradition of explaining something Chinese to my non-Chinese readers (2006, 2005), I'll tell you something about the Chinese language.
But first, a quiz:
- In traditional Chinese age counting, a baby born on Chinese New Year Eve will be how many years old after the Chinese New Year?
- 0 year old
- 1 year old
- 2 years old
- The Chinese New Year is always on
- The second new moon after the winter solstice
- Falls between January 23rd and February 22nd
- 354 days or 383 days from the previous one
- All of the above
Traditional Chinese, Simplified Chinese
For thousands of years, the written Chinese has used a consistent set of characters. They were written in different styles, but structurally little has changed. These are the traditional Chinese characters. It was used in China, Japan, Korea and Vietnam.
Here is my last name in traditional Chinese:
One thing about these traditional Chinese characters is that they contain many strokes. The above Gao character contains 11 strokes.
Then people start to get clever. They said, "Hmm, these characters are so hard to learn. Let's simplify it." And they did. The first batch was announced in 1956. The second batch in 1964. They did a third batch in 1978. But it was so ridiculous that people can't stop laughing at them. That batch was withdrawn quickly.
The idea of the simplification is to keep the rough structure of each character, and reduce the number of strokes required to write each character.
Here is my last name in simplified Chinese:
This is the mildest kind of simplification. The two characters look very similar. You probably can't tell, but the simplified version contains only 10 strokes.
As you can guess, the simplification drive did not make written Chinese easier to learn. It still takes about five years to learn basic reading and writing. And people who learned the simplified characters still have to learn all the traditional characters, or they won't be able to read books written before the simplification drive, and books published in Taiwan, who do not recognize the simplified characters. As a matter of fact, they even refuse to call the traditional characters Traditional. They call them Canonical.
The Pinyin
The Pinyin, or the Chinese Phonetic Alphabet, began its life as an attempt at a whole sale romanization of the Chinese language. It didn't work. There were simply too many Chinese characters that have the same pronunciation. And you simply cannot make out the meaning of a sentence from its sound. Someone even composed a 92 character story all of whose characters are of the "shi" sound.
It evolved into a system that helps the pupil learn the pronunciation of characters. It is standardized in the 1950's. When I went to school, the teaching of Pinyin was optional. The school wanted to teach it, but there just were not enough teachers who knew it well to teach it.
The standard is very simple as the Mandarin Chinese has very regular phonetic characteristics. It uses the 26 Latin alphabets, with the letter 'v' being marked as for use only for foreign words and dialects. That leaves us with 18 single letter consonants and 5 single letter vowels. There are three double letter consonants: zh, ch, sh, and a whole bunch of compound vowels or vowel-nasal combinations. There is also the ü (u umlaut). Each Chinese syllable begins with a consonant and ends with a vowel, a compound vowel, or a vowel-nasal combination. There are only two nasal sounds in Chinese: n and ng.
Since the Pinyin was envisioned as a teaching aid for the Chinese pupil at the time of adoption, some of the consonants were assigned phonetic values that's quite different from English or other Latin languages. This was not a problem until in the late 1970's when Pinyin was also adopted as the standard romanization mechanism for transliterating Chinese names into Western languages. That was when in Peking was changed to Beijing, and Chou En-lai became Zhou Enlai.
The problem with forcing the Pinyin onto English and other Western languages is that certain consonants were not easily and faithfully pronounced. For English speakers, x, q, c, zh, and z poses particular challenges since their Pinyin value is totally different from their English value.
The following is typical of my first encounters with a new colleague:
Me: Hello, Tom. It's nice to meet you.
Tom: Hello. Excuse me, but how do you pronounce your name?
Me: It's pronounced Wei-Chee. The q has a ch sound.
Tom: Hi, Wei-Chee. Nice to meet you.
I'm lucky in that the typical English speaker don't know how to pronounce qi (so they just ask). The story is different for all the Caos, the Xings, the Hes and the Es. They don't stand a chance of ever hearing their name pronounced correctly while in an English speaking country. (Except when they make an appearance in the Olympics, where I understand all the broadcasters are trained to pronounce the athlete' name correctly.) These names were translated as Ts'ao, Hsing, Ho, and Ê in the older Wade-Giles convention superseded by the Pinyin.
Like the situation for simplified characters, Taiwan disagrees with China. They still use the older convention.
Pinyin As Input Method
One use of Pinyin in the computer age is as an input method for Simplified Chinese on a computer with a regular English keyboard. Since more than half of the Chinese population (almost all of the young people) know Pinyin, it is naturally the most popular input method.
There are some inefficiencies in Pinyin as an input method when compared with other "professional" input methods because Pinyin was not designed for the economy of keystrokes. The learning curve for other methods are very high.
Another shortcoming of Pinyin is that it is useless when you don't know for sure how a character is pronounced.
But for the casual user, Pinyin gets the job done. Here is a little screencast of me self-googling (It's in Ogg Theora format, and you need Linux or Video Lan Client (VLC) to watch it):
He's Been Thinking In Java, Now He's Thinking In Flex
I read Bruce Eckel's books and blogs. I usually agree with what he says. So naturally I read Bruce's latest blog article Hybridizing Java seriously.
What I didn't realize was that Bruce was also working as a spokesman for Adobe in its Flex 2 advertising campaign until I spotted the Flash advertisement on some technology website. I didn't remember which site I spotted the ad on, however I did save a link to the actual swf file.
I don't know how many people have read the article without seeing the ad, or how many people have seen the ad without reading the article. For me, reading the article first without any knowledge of his role in the ad campaign, and then seeing the ad popping up, gave me somewhat of a surprise. And, maybe I'm being a little bit of oversensitive, it works to completely negate whatever impact Bruce's article had on me. For example, after reading the article, especially the following assessment of Flex:
Bruce Eckel: Of course, if my dream is to be able to learn a single GUI system in depth, is Flex the right tool, since it was originally designed for web RIAs?
A Flex UI can initiate communication with its server, or any other server it chooses. A server cannot initiate communication with a Flex UI, which makes sense because of security (it would be effectively the same as having an open port on your machine).
However, a Flex UI is not limited to communicating with a server. It can also communicate with a local application. Thus, you can create an application in any language you prefer, even a dynamic language like Python or Ruby, and use Flex to build a beautiful UI.
Adobe is developing a new tool called Apollo, a cross-OS runtime that allows you to use Flex to create desktop RIAs. This means that your Flex skills can be further employed for creating smooth desktop applications, but it also means that you can more easily build applications that will work on both web and desktop (I’ve seen expensive and difficult-to-use tools that allow other languages to do this).
I went as far as to have registered with Adobe's website and downloaded the Flex 2 SDK. I was about to give it a whirl this weekend to see if I like it. Then I saw the ad, and my mind went, "Wait a minute! If Bruce is doing a celebrity product endorsement gig for Adobe Flex 2, how objective could his assessment be? Especially since he did not disclose his connection with Adobe in the article."
They almost had me.
(Since I haven't played with Flex 2 yet, I don't know enough about it to say whether it's good or bad. But judging from the amount of Flash content on the web, I'd imagine it to be pretty good. Bruce's assessment may still be accurate. His criticism of Java is certainly on the mark. I wish the Java community take Bruce's criticism as motivation to improve the platform.)
Ah, Hudson
Was: RE: [Tech-discuss] Hudson Continuous Integration System Now Even Easier
(From an internal OCI mailing list, posted with author's permission.)
Tom Wheeler: I wrote a JNB in December about Hudson, a Web-based continuous integration system that's really easy to set up:
All you need to do is download the WAR file, drop it in your servlet engine and view the app in your browser. How could they make it any easier? As of version 1.8.1, the WAR file is self-executable and starts an embedded servlet engine when you do this:
java -jar hudson.warThe embedded container only adds 320KB to the download, and you can still deploy to the servlet engine of your choice. More info here
tw
I've neglected to mention Tom's Java News Brief (JNB) article when it came out last December. But I've heard from at least one user of Hudson who's very happy with it. "This blows CruiseControl away," was very close to the word he used.
I just now downloaded and deployed hudson.war in my Tomcat 5 container. And I have to say that this is way better than CruiseControl, at least the CruiseControl that I tried several years ago.
Is Your JDK US-DST-Change-Ready?
(Via someone from London)
Simon Brown: The US are changing the dates when daylight savings come into effect and, since the logic for calculating these dates is built-in to the Java runtime, your applications might be affected. Basically, you need to upgrade your Java runtime environment and further details about this can be found at U.S. Daylight Saving Time Changes in 2007.
The link Simon provided gives a lot of information about the implementation details of how time zones are handled. I spent about 15 minutes just reading and following internal links to find the information relevant to me (JDK 1.5.0_10). Here's what I found:
- When were the US-DST 2007 Changes announced?
- They were announced under the title U.S. Energy Policy Act of 2005.
- The US-DST changes for 2007 were codified in Olson dataset 2005n.
- The 2005n changes were incorporated into the Java SE platform updates 1.3.1_18, 1.4.2_11, 5.0u7.
and
- Which versions of the Java SE platform are already USA 2007 DST ready?
- Java SE 6 FCS is USA 2007 DST "ready"
- Java SE 5.0 u6 and above are USA 2007 DST "ready"
- Java SE update release v1.4.2_11 and above are USA 2007 DST "ready"
- Java SE update release v1.3.1_18 and above are USA 2007 DST "ready"
It looks like I'm OK.
Ah, NLink!
(Via Cafe au Lait)
Kohsuke Kawaguchi: Historically, JNI has been the only option to invoke native libraries. The problem with calling native libraries with JNI is that, for every method, you need to write a java method declaration, and then a bit of native code to do the parameter conversion. This makes it difficult to casually call into native libraries, because you'd have to write another native library just for JNI handling.
NLink overcomes this problem by providing a general-purpose method invocation converter driven by annotation. With NLink, calling a native library is as easy as [...]:
This is just what I asked for 104 days ago. And it works too!
[weiqi@gao]$ cat User32.java
import nlink.win32.*;
@DllClass
interface User32 {
@DllMethod
int MessageBox(int hWnd, String text, String caption, int type);
}
[weiqi@gao]$ cat Main.java
import nlink.win32.*;
public class Main {
public static void main(String[] args) {
User32 proxy = NLink.create(User32.class);
int result = proxy.MessageBox(0/*NULL*/, "Hello, World!", "Hello", 0);
}
}
[weiqi@gao]$ javac Main.java
[weiqi@gao]$ java Main
Jython 2.2 Beta 1 Released
Frank Wierzbicki's Weblog: The Jython development team is proud to announce the release of Jython 2.2's first beta!
Get it here:
I'm really happy to see Jython coming back to life. Here's wishing the Jython team the best of luck in carrying out their roadmap.
Groovy In Action: I Picked It Up, I Can't Put It Down!
Tim Bray: In the mail from O’Reilly this week, Groovy in Action [...]
[...] and of course, watching Groovy at work. I have to say the source code is real easy to read; oddly, what it makes me wish for is regex literals in Java. Hmm, it’s not obvious to the casual eye when you declare variables and when you don’t; I’m sympathetic to the optional-declaration idea though. I guess I’ll have to have a look at the book; it was cracking the Pickaxe book’s covers that dropped me onto the slippery Ruby slope.
Hmmm, Groovy In Action is a Manning title, I wonder what O'Reilly is doing sending it out to people. I guess that "Manning Is The New O'Reilly" memo hasn't reached everybody yet.
I received my copy of Groovy In Action 8 days ago. No, it was not O'Reilly who sent it. It was Amazon.com. And it's not a free copy either. I pre-paid for it, months ago.
And I haven't put it down since I received it. Sure, Java Generics and Collections is deep and fascinating, Groovy in Action is simply magnetic. The last time I read a book through like this, the book was Hibernate In Action.
I have been an advocate for dynamic languages for the Java platform for a long time now. See for example, my Scripting Languages for Java article from 2168 days ago. (That's six years ago, folks.) While my favorite scripting languages for Java remain to be Rhino and Jython, I keep and open mind for the newer entries to the field like Groovy and JRuby.
Without passing judgement on the language itself, here's my (re)view of the book:
- The figure on the cover of the book is pretty and beautifully dressed (you can't say this for some of the other Manning titles)
- The text is written in a conversational voice, reading it is like sitting in a classroom listening to an instructor
- Part 1 (The Groovy Language, pp. 1–225) covers the language in a non-hurried pace, with each feature thoroughly treated, and similarities and contrasts with Java pointed out along the way
- The authors are not shy about pointing out potential problem spots in the language (for example that switch statements may have overlapping cases so the order of the case clauses matter in Groovy, just like the order of the catch clauses matter in Java)
- The authors are not avert to explaining in excrutiating detail how some of the more magical features work under the covers. When they are done, you say, "Well of course, that's how closures work."
- Part 2 (Around The Groovy Library, pp. 227–449) covers builders, the GDK, database programming, integration, and working with XML
- Part 3 (Everyday Groovy, pp. 451–605) covers tips and tricks, unit testing, Groovy on Windows, and Grails
- Four appendices rounds out the book: Installation and documentation, language info, GDK API quick reference, and cheat sheets
All-in-all, I think Groovy in Action is among the top five Manning books. For me personally, it's also a perception changing and influential book. The $49.99US price tag is a little bit too expensive for a "scripting" language. But I bet the Manning folks and the Groovy people have better designs for the Groovy language.
I highly recommend Groovy in Action for Java developers who want to learn Groovy in a systematic way and who are starting Groovy projects.
And if I can get the attention of the Manning folks and Groovy people, for just a second, I would whisper the following into their ears: "Make this book freely available, à la The Java Lanuage Specification. Groovy deserve it!"