22 November 2007

NZ$600 Asus Eee PC quick review

Breakfast tech review: November 21 (6:21)
Breakfast's tech test-driver Gary Steel reviewed the Asus Eee PC, a laptop designed primarily for Internet use.

20 November 2007

4RF on TV, as a success story

TVNZ, Breakfast Business


Download Video

Business Nov 20: Declining productivity (1:54)
New Zealanders may work some of the longest hours in the world
but latest statistics show that it is not translating into
increased productivity. In fact, workplace productivity is
declining.

19 November 2007

Open Inheritance versus Designed Inheritance

Final means different things depending on where it’s found. If you put it in front of variables, that means ‘constant’. Final variables can just be assigned a value once.

It’s different if it’s put in front of methods and classes. In that case it means that it closes them from being overridden through inheritance. A final class can’t be extended, and a final method can’t be overridden by methods with the same signature in derived classes.

I’ve just discovered that closing or not a class to inheritance is behind two different school of thoughts: Open Inheritance and Designed Inheritance.

Here’s a little introduction to these two different approaches:

http://martinfowler.com/bliki/DesignedInheritance.html

DSP... in Java

Interesting applications, entirely written in Java:

Sphinx-4 A speech recognizer
FreeTTS 1.2 - A speech synthesizer

And something else, that might come useful sometimes :-)
jMATLAB - an interpreter for the matlab language and a plugin for Eclipse

16 November 2007

java.util.zip

I've just discovered that this useful API has been present in Java since version 1.1.
That's good because I don't have to add any additional library to perform the task of zipping, that would steal some additional precious embedded storage room.
XML files are notoriously redundant so the idea of gzipping an XML file before saving it onto flash can lead to significant savings.

The only problem, I had to learn a bit more about the difference in Java between byte-based and character-based streams.
As you probably already know, these two types, byte and char, are different.
Byte is an 8 bit signed type, while char is a 16 bit unsigned byte. The reason for char is to allow support for internalization and localization by carrying character set information.
Some classes use byte based streams, some others char based ones.
The java.util.zip library uses byte based streams, so in order to interface it with character based classes (like an XML parser) I needed to use some sort of bridge classes.


Examples. To Gzip a String:

String str = ...;
ByteArrayOutputStream ba = new ByteArrayOutputStream();
GZIPOutputStream gz = new GZIPOutputStream( ba );
DataOutputStream os = new DataOutputStream( gz );

os.writeBytes( str );
os.close();

byte result[] = ba.toByteArray()



To UnGzip from an InputStream:

InputStream is = ...;
GZIPInputStream igz = new GZIPInputStream( is );
InputStreamReader isr = new InputStreamReader( igz, "ISO-8859-1" );
StringBuilder strb = new StringBuilder();
int c;
while(( c = isr.read() ) != -1 )
{
strb.append( (char)c );
}
String result = strb.toString();

12 November 2007

I'm loving unit tests!

Finally I get to appreciate Unit Tests. They greatly speed up development of network applications. Using Junit (4.4) I can easily set up any particular test condition in isolation. It has definitely advantages even on the powerful debugging capabilities of Eclipse for Java.

09 November 2007

Java Swing Survival Guide - Software Reality

Java Swing Survival Guide - Software Reality

This is an old but spot-on article that highlights the limitations of Java as a language for desktop applications. It also finds some qualities in it.
We'll see whether the latest development (SwingLabs, JavaFX) can give some hopes to Java as a language for desktop applications.

How to compare a Byte[] and a byte[] ?

I love collections in Java, they're so handy and I too think arrays should be deprecated.
But a lot of functions return just plain arrays.

So I happen to compare an array of objects Byte (returned by an ArrayList) and an array of plain bytes, returned by a ByteArrayOutputStream.
I know an array of Bytes is an array of p... ehm, references so its nature is totally different from the one of an array that contains primitive types.
But I wish there was a method to compare the two, so clever to do boxing/unboxing automatically.

Eclipse and Make projects on Linux

For some reasons, to build a project I have to run make with root privileges.
I love to run it from within Eclipse, so that the output from the console is piped nicely into the IDE. Before I thought I could safely run Eclipse as root for that purpose. That choice has caused though a lot of pain...
So I've looked for other ways like adding myself to 'sudoers' with no password, and adding 'sudo make' to the project compile settings
But Eclipse fails and returns an error like 'exec failed to run sudo make'.
A quick workaround I've found is to create an additional dummy makefile in another directory with the same targets as our make, and each targets just calls the real makefile, by prepending sudo to the make command, for example:

all:
cd .. ; sudo make all

The real solution to my problem would be not to have to run 'make' as root.
In order to do that I need to find a way to grant users privileges like running the 'chmod' command on files they don't own. There must be a way to do it...

07 November 2007

JavaScript To Fragment, The End Of The Reign Of The Browsers - Weiqi Gao's Observations

JavaScript To Fragment, The End Of The Reign Of The Browsers - Weiqi Gao's Observations

A very interesting point:

JavaScript has become an assembler of the web. And it needs to grow up. Or it risk being overtaken by other languages.

The browser platform is passé. The race for the next round of cross-platform (note: not cross-browser) internet applications (note: not web applications) has already started