Inside SWT

Thursday, November 29, 2007

Insights and insults from GTK ...

Got this the other day while running Eclipse on Linux:

** (SWT:5087): WARNING **: Some clown returned undeclared exception 'IDL:Bonobo/BadArg:1.0'

That's it, I'm upgrading SWT's error messages to be more helpful and informative. How about, "You turd, you can't access a widget from outside the display thread"?


Tuesday, November 20, 2007


I'd like to coin a new technical term: Assmetrics. As you might imagine, an assmetric is exactly what you think it is. Programs are full of them but my favourite these days is from the slash and burn Mac cocoa port. If you don't resize a combo box to be exactly 26 pixels high, you get this message at runtime:

2007-11-20 10:17:26.452 java[4523:10b] This application is trying to draw a very large combo box, 100 points tall. Vertically resizable combo boxes are not supported, but it happens that 10.4 and previous drew something that looked kind of sort of okay. The art in 10.5 does not break up in a way that supports that drawing. To avoid breaking existing apps, NSComboBox in 10.5 will use the 10.4 art for large combo boxes, but it won't exactly match the rest of the system. This application should be revised to stop using large combo boxes. This warning will appear once per app launch.

By the time the guy who implemented NSComboBox typed all this in, he could have just centered the thing.


Saturday, November 17, 2007

Ok community, blow your brains out

As many of you know, a ton of Mac cocoa work was taking place over the last two weeks. We have now folded the lot from the cocoa_work stream into HEAD. At this point, despite the astounding progress that was made (including porting the browser), there is no more time to work on it.

Right now, by commenting out NSObject.release() and using dark magic to get around the fact that there is no launcher, Eclipse comes up. Obviously, we are freeing something we shouldn't and crashing because of it. As you can imagine in a prototype that was developed so rapidly, there are many bugs and unimplemented features but ... holy shit, Eclipse starts.

Please contact us on platform-dev-swt to find out how you can help.


Friday, November 09, 2007


Here is the ControlExample running under cocoa:

We started on Monday with nothing. Along the way, we hit an Objective-C compiler bug involving struct return types that caused a series of Apple trolls to visit us, each one expressing increasing disbelief. No problem though, I love these low level compiler guys. They are smart and fun.

But crashing didn't stopped us. We just typed in custom natives each time we hit the problem and kept going. Eclipse allowed us to develop rapidly, almost as fast as the old Smalltalk days. Objective-C has lots of good stuff from Smalltalk like real meta-classes (Java static methods are crap) and dynamic dispatch.

The week was an almost perfect example of prototyping. The code we have is utter crap and we have cut every corner, however, we have learned the technology and explored the area. Prototyping is about reducing risk using a short term, high energy, low quality approach to prove that a solution is possible and scope the time frame.


Wednesday, November 07, 2007

Hacking at Apple

Silenio and I are at Apple this week. We were invited to take a course which turned out to be a cocoa hack-a-thon. It's a good deal for me because I get to code and get away from distractions at IBM.

As many of you know, cocoa is Objective-C and SWT is programmed from top to bottom in Java (otherwise, we couldn't possibly develop or maintain the toolkit). So the first order of business was to figure out how to call Objective-C from Java. We needed to convert this:

[object message: 12];

into Java.

Obviously, we could have a billion natives, one for each message, but this would be too crazy, even for us. So we got the compiler to dump the assembler to see what was going on. It turns out that everything is a call to objc_msgSend() so we typed these guys in and were on our way.

On Monday, Scott Kovatch (my friend at Apple) said, "Hey, we've got a description of all this stuff in XML". He showed us where it was and by the start of the next day, Silenio had all of the selectors and classes that we needed. So instead of typing:

OS.objc_msgSend(id, OS.sel_message, 12);

we were typing:


Everyone else in the room thinks we're insane.