Archive for June, 2007

How not to spill coffee on your laptop

Saturday, June 30th, 2007

Is it really that hard not to spill your morning coffee on your laptop? I have never done it myself, but some of my users have a really hard time with this concept. In the last 3 years, I had 3 or 4 cases of “Oh shit, I spilled _____ on my laptop”. Usually the spilled liquid is initially water – but later it usually changes into coffee. Go figure.

Usually, spilling anything on your laptop is more or less fatal. Spilling shit on a regular desktop keyboard can be harmless – your keys may get sticky, and in worst case, you will need to spend maybe $20 on a new keyboard. But laptop keyboard is directly over the mobo – so when you spill something on it, the liquid will most likely hit all the crucial components of your system – the CPU, the onboard graphics card, the sound card, the network card, and etc…

Most people should have enough common sense not to spill shit on their portable machines. But then again, common sense is anything but common. So I decided to write this little tutorial. I will be talking about coffee, but please note that this can apply to any drinkable liquid. Here is a hint: positioning of the coffee cup is crucial. Let me show you a visual example:

Coffee Cup Positioning

This is the usual setup most people use when working on a laptop. We have papers on the right, papers on the left, and the computer in the middle. Note that in most cases, there will be a lot of shuffling between the piles of paper – you will be moving papers from one pile to another.

The points labeled A and B are theoretical coffee cup locations. The location A is a very common choice among the sill-prone laptop users. Notice however, that this position is just asking for trouble. A force applied to the cup from the left will invariably make it tip over, and deposit it’s liquid contents all over the keyboard. Furthermore note that it is relatively easy to accidentally apply such a force to the cup while moving papers from the left pile to the right pile, or even by moving your hand from the pile of papers back to the keyboard.

Spilling any liquid directly on the keyboard is likely to cause instant, irreversible damage to the hardware. Also, if the liquid is a light and sweet latte, chances are that the spill will leave sugar deposits on the hardware, and intense smell. This will prevent hardware repairs under warranty unless you bought the expensive accidental damage protection plan.

Now consider the position B. When the cup at that position is tipped over in any direction, it will likely spill the contents on the table. If the force is applied to the cup from the direction of the right uppermost corner, then the liquid might spill on the back of the laptop, but:

  1. There is a chance that the cup wont tip all the way, but it will be held upright by the laptop display positioned at a 90 degree angle to the table surface
  2. The spill will affect only the laptop casing and the exposed ports in the back
  3. Picking up the laptop will prevent the liquid from penetrating inside the casing, and reaching the mobo
  4. The motherboard and CPU will be shielded from the spill by the raised display
  5. If any of the liquid gets underneath the laptop, the force of gravity will prevent it from traveling upwards where it could damage the motherboard and the CPU

From the above it obviously follows that position B is far superior to position A. Remember about this next time you are enjoying a nice cup of coffee while working on your laptop.

Java: Swing or SWT – which one is better?

Saturday, June 30th, 2007

I’m actually to lazy to write a full argument here, so I will just post my bullshit filler crap from a recent research paper:

5.3 Designing a Graphical User Interface

The discussion of GUI design should start by choosing appropriate widget toolkit. Java offers developers several attractive graphical environments. We will first take a closer look on each of them. Visualization details will then be explained in terms of that chosen toolkit.

5.3.1 Choosing a Widget Toolkit

There are three competing major widget toolkits that can be used for building graphical user interfaces in Java: AWT, Swing and SWT. Both AWT and Swing are currently included in Java Standard Edition, while SWT is an external set of libraries that needs to be downloaded and deployed separately.

The AWT toolkit was the first widget system implemented for Java. It is composed from fairly simple wrapper classes which in turn make calls to the native windowing environment to display GUI elements. Since each platform has a different set of native widgets, Sun only included the most basic ones in AWT [37].

Swing toolkit was developed in 1998 as a replacement of AWT. It abandoned the idea of using the systems native windowing environment, and designed a complete, feature rich widget toolkit entirely in Java. Swing is still in active development, and offers an impressing number of different graphical tools and GUI elements to the developers. For example, the package included in Java 1.4 includes 85 public interfaces, and 451 public classes [40].

The pure Java implementation however has proved to be both a blessing and a curse for this toolkit. Since Swing elements are really Java objects, they can only communicate with the underlying operating system through the JVM. In some cases this can create significant overhead, and thus Java based interfaces will often appear
to be less responsive, or slower than their native counterparts [37].

The Standard Widget Toolkit (SWT) [41] developed by IBM is a hybrid between Swing and AWT. It combines both approaches by including both calls to native widget elements, as well as implementing pure Java based ones. This helps to significantly improve the performance without sacrificing any of the advanced features one may
look for in an enterprise grade product [37].

The difference in performance, and responsiveness between Swing and SWT however is widely disputed and highly controversial. For example some benchmarks claim that Swing can outperform it’s competitor with respect to speed of rendering and re drawing windows on non-windows platforms [42]. Thus is is not very clear if SWT is really faster than Swing, or if overhead of the native calls and communication between Java and non-Java elements diminishes any performance gains stemming from using a native widget implementation.

Benchmarking the two toolkits is out of scope for this paper, and thus we chose Swing as our GUI toolkit because it is a Java standard, and it reduces the complexity of our code by eliminating dependency on a third party library.

Bibliography

[37] S. Holzner, Eclipse: Programming Java Applications. O’Reilly, 2004.
[40] R. Eckstein, J. Elliott, B. Cole, D. Wood, and M. Loy, Java Swing. O’Reilly, 2002.
[41] “The standard widget toolkit,” IBM. [Online]. Available: http://eclipse.org/swt
[42] I. Kriznar, “Swt vs. swing performance comparison,” Cosylab D.O.O, 2005. [Online]. Available Here

© 2007 Lukasz Grzegorz Maciak

I pulled the above from a draft version because it’s late, and I don’t feel like locating the finalized reviewed document. So there might be typos and grammar errors in there – which is of course nothing new around ere.

I ended up using Swing, and perhaps it was not the best choice. Not for an image processing application perhaps. So you tell me. Which one is better in your experience. Is SWK really that much faster than Swing? Is the added speed worth the hassle of bundling it with correct SWK packages for correct systems?

I would love to hear from bit SWK supporters – what are the best selling points of this widget kit over Swing, other than the speed? Anyone knows any good benchmark tests that were done to compare these?

I will have to make this same decision for another project soon, and as usual I’m not entirely convinced which one to choose. I’m leaning towards Swing because I worked with it before, and I know at least some of it’s quirks and pitfalls to be avoided. SWK would be a completely new ballgame.

What do you think?

Top Commentators and Top Posts

Friday, June 29th, 2007

If you hit up the front page you will see two new little things in the sidebar. One is a list of the 10 most popular posts on this blog. All of my posts that got dugg at one point or another will be there, along with some of the big discussion threads that had interesting back-and-forward going on in the comments.

The second addition is a list of Top Commentators – which is you guys. This is my way of sending some love and some Google juice towards my regulars. You guys are awesome!

At the moment my top 10 looks like this:

    * Luke (1151)
    * Matt` (194)
    * ZeWrestler (148)
    * Craig Betts (128)
    * Travis McCrea (97)
    * Wikke (74)
    * Fr3d (65)
    * StarHawk (58)
    * Miloš (52)
    * Ara Pehlivanian (51)

It turns out that I’m the most vocal commentator on my own blog. But it’s not because I like talking to myself all the time – it’s because I always try to respond to comments posted by others.

Btw, Matt` – any luck with the email notifications? I mucked around with various things, but I’m not sure why you’re not getting them. I’m at a loss here. You wanna try a different email address, just for shits and giggles?

Anyway, you guys are awesome!