Monday, February 28, 2005

Tapestry and Eclipse

So first Tapestry... It's an alternative Java web application framework that is now hosted on the Jakarta Apache website. I don't know if I'm reading anything into the fact that it's an Apache project right beside Struts. It just surprised me a bit.

It's certainly a lot different than Struts and maybe that's not a bad thing. I haven't seriously gotten into it yet but one of the things I like is that you don't replace HTML tags with some proprietary tags (unlike ASP, JSP, PHP, etc.). That means that you can use whatever HTML editor you want, including WYSIWYG editors. A lot of Java people I know dismiss WYSIWYG editors but I actually like them. Anything that allows me to design (in the graphical sense) without writing code can't be all bad. So far all I've done is the requisite "Hello World", but so far so good. BTW, the next version of Tapestry includes HiveMind, one of those Dependency Injection frameworks everyone loves.

As for Eclipse I borrowed a book from the library this weekend called Contributing to Eclipse: Principles, Patterns, and Plug-Ins. One of the interesting things is that the authors are Kent Beck and Erich Gamma. Yes that Kent Beck and Erich Gamma! Big names in the geeky programmer realm. The book starts off with some background of Eclipse. When you use the Java IDE project within Eclipse it's so easy to forget that it was intended as a programming language neutral environment and that everything in Eclipse is a plug-in. Everything! Very cool. I already have some ideas for plug-ins but we'll see how the rest of the book goes.

Wednesday, February 23, 2005

Owly About RSS

If you're not using a NewsFeed Reader to read this blog then you should get yourself over to SourceForge.net and download yourself a copy of RSSOwl. It's Java based, but before you go off bitching and moaning about a crappy Java user interface you should know that it uses the Eclipse.org's Standard Widget Toolkit (SWT) which means a native UI that is responsive and good looking too.

Tuesday, February 22, 2005

iPod bling bling

I found an iPod shuffle at Best Buy last Friday. I guess their online inventory numbers are pretty accurate afterall. So I immediately cancelled my online order with the Apple store and set about trying to make it work with my Windows XP computer at work (during lunch naturally). Well I couldn't for the life of me make it work. And it wasn't just the iPod either because a friend of mine's USB flash drive didn't work either. I don't know if it was some conflict with another Windows service or if the machine was explicitly configured not to work with these devices but all I got was flashing amber lights.

After a disappointing first crack at it, I was delighted to see it work flawlessly with my PowerMac at home. Within a minute I was copying songs from iTunes to my iPod. Then I became Mr. Antisocial for the evening as I tried out my new toy. I've never messed around with any other MP3 player in the past. Perhaps if I'd used an iPod with the clickwheel and screen I'd be dissatisified with the simple interface of the shuffle, but I think Apple has a good design here. It's idiot proof. Turn it on, press play, mess with volume, skip songs and that's it. If you want to listen to music then it doesn't get much easier than this. I rather like the shuffle mode too. I have an eclectic music collection so going from Eminem to Guns 'N' Roses to the Beatles is actually pretty cool with me.

Now the only problem I have with this thing (other than connecting it to Windows XP) is how to carry it around. I tried the lanyard and although wearing it like this was no big deal (the shuffle is itty bitty and weighs next to nothing), I didn't like all the cords once I attached the headphones. It just felt messy. So then if I don't wear it around my neck where do I put it? Well I'm trying various pockets but I'm a bit afraid of snapping it in two. They need to come up some kind of clip or a combined lanyard/headphone. I dunno.. but something needs to be done.

Finally, the one-two punch of the iPod shuffle and iTunes shows just why Apple products fit people so well. I've used Macs for a number of years and I've heard Apple say that their ability to control hardware and software ("the entire widget") is one of their biggest competitive advantages. But I never really understood that statement until I bought the iPod shuffle. Apple's competitors in this space are hardware manufacturers that can only control half of the equation while Microsoft controls the other. So while MS and Bill Gates try to beat the drum of choice (choice of different hardware manufacturers using their proprietary software, Windows Media Player) I think consumers will continue to choose the vendor who gives them the best experience. Now that I've experienced a bit of this iPod phenonenon I'll hazard a guess and say that it will continue to be Apple.

Thursday, February 17, 2005

Give it up for Gates

I read an ABC interview between Peter Jennings and Bill Gates last night and just loved some of the questions and answers. Bill Gates has lost none of his competitiveness and seems to want to rewrite history in his favor... I mean c'mon Bill. You didn't create the PC industry. Let's get real here. Microsoft had an important role to play, but you were just one part of it and in the beginning you were one of many. A lot of luck made you who you are today. I'm sure the boys over at Slashdot are ripping you to shreds right now. Anyway here are some of my favorite quotes:

Gates: We're responsible for the creation of the PC industry.

Jennings: But, it isn't hard for you is it to stand back and compliment somebody else?

Jennings: I've heard some people say that if they were graduating from science or technology today, they'd rather work for [Steve] Jobs than Microsoft. Why do you think that might be true?

Jennings:
When I said to somebody the other day that you at Microsoft had always said we will continue to be the innovators of technology this person who was young and a techie said "Oh they've never innovators they buy other people's material, they expropriate other people's knowledge and adapt it into their business." I don't understand that completely, but is there some truth in that?

Gates: Well the biggest thing we did was we invented the field.

Monday, February 14, 2005

Video Editing

All my video projects are strictly amateur, home video, garden variety, family stuff so my needs aren't great. I used the software that shipped with my Mac (iMovie) for quite a while. It's pretty good and worked remarkably well even on my old G3 iMac. But I started to run into the limits of the tool and decided I needed more control and flexibility. A couple of years ago I upgraded to Final Cut Express (FCE). Now I have to tell you that for the inexperienced video editor FCE is like stepping into a race car when you're used to driving a mini van. "What do you mean I have to shift gears!?"

As a result my ramp-up has been slow and arduous. If I spent every day for weeks at a time doing it, maybe things would have been different but when you're doing it in your spare time, things tend to take a bit longer. I bought a book and went through the tutorials, etc., but just found myself crawling instead of running. The terminology was very foreign (e.g., ripple, roll, slip, slide, keyframes, bin, canvas, viewer...) When it came time to doing a school project with my daughter last year I resorted to iMovie except for the voice over part where FCE came in. In fact, I have to admit that my video output was probably approaching zero. Sure I started lots of projects but I haven't finished very many.

So along came our trip to Maui and some new raw footage. Full of new energy I decided to tackle the project. Now I don't know when the lightbulb went on, but wow FCE rocks. Here's what I like:

  • I can organize all my clips with bins (a.k.a., folders)

  • Clips stay where I put them in the sequence (manual transmission instead of an automatic)

  • Color correction! It's amazing what you can bring out of a dark shot.

  • Mutliple sequences in one project.

  • Non destructive editing. (I think iMovie supports this now too). Great when you change your mind.

  • Better titling options

  • Many available video and audio tracks (99 of each).

  • Superimposing titles and other clips is a snap with multiple tracks.

  • Real-time effects. I still have to render the odd thing or two, but this is great.

  • Short cut keys everywhere. I hardly touch the mouse.

  • Multiple windows. iMovie has one simple window. With FCE I can reorganize things for the task at hand.

  • Much better audio management.



I don't know if my repertoire as a video editor has expanded yet with all this new found flexibility but I think I'm finally into an efficient editing mode again. I'm betting this video will be out the door before the end of the week. Then I can start looking into all the motion, animation, and compositing capabilities of the tool. And if things go well maybe I'll look into the new Final Cut Express DV.

Thursday, February 10, 2005

Happy Trails To You

Trails is a project hosted on java.net that leverages Spring, Tapestry and Hibernate to generate a functional web application using just the domain objects. Some of the docs say it does no code generation... Don't know how that works or how useful this project would be in the real world but it looks cool. You should check out the demo video. He creates a simple little app in Eclipse with some help from XDoclet and Ant to create the database in MySQL (an XDoclet task creates the hibernate mappings and then a Hibernate task creates the database tables. Done that before and it works reasonably well). You need Quicktime installed to view the video.

I've taken a brief look at Spring in the past. It seems to be the dominant implemenatation of the Inversion of Control pattern. I've only heard of Tapestry. It's a Struts competitor of some sort. Everyone who uses it seems to rave about it. And Hibernate, well it just rocks! ;-)

Monday, February 07, 2005

iPod Shuffle RAID

This guy took 4 of these things, striped them and made a 3.9GB RAID Array out of them! Neat bit of hackery.

I ordered an iPod shuffle about a week ago but unfortunately Canada is a third world country to Apple and I won't see it for at least a month yet. Ugh... Still it's nice to see somebody doing something creative with them.

Update: I found an interesting article on Ars Technica that compares the performance of various flash drives on both Mac OS X and Windows. They even did the RAID trick on Mac OS X. This was in June last year. So while the above article might be the first to do it with iPod shuffles, it's been done before... In summary: reading is way faster than writing, big files are better than small files and not all drives are created equal. Be interesting to see where the iPod shuffle fits in.

Sunday, February 06, 2005

My review of C#

I finally finished learning a thing or two about C#. My original intent was expanding my knowledge of the .NET world. I used Mono and was able to make my way through an entire book about C#. The book didn't delve too far into the frameworks and concentrated mostly on the language. Following are the notes I took while working my way through the book. They're written from a Java developer's perspective (with the odd smattering of Delphi and ObjC thrown in for good measure). Next I'll probably look into things like nant, nhibernaate, and nunit, the C# equivalents of tools I commonly use in the Java world...

Overall I was pretty happy with C# as a language. It's very much like Java and the comments below only reflect the things that are different. Generally, I would say C# is a legal J++ (Microsoft's slightly mutated Java that was taken off the market after Sun sued and won). I originally thought J++ was pretty good and I think the same about C#.

Namespaces and File structure
  • Many namespaces in one file.

  • No tie between public class names and name of file or name of namespaces (packages in Java) and the directories they live in. Simpler.

  • But by convention one class or a few highly related classes are grouped in individual files, so in practice it may not be much different

Ref and Out parameters
  • ref and out parameters must be marked in the method declaration and on the calling side. Good for readability.

  • vars to be used as a ref param must be assigned before calling method.

Misc
  • Main is the name of the entry point method (one per file). Note the capital M. C# uses PascalCase vs camelCase for most names. This is a bit unusual for Java developers but makes sense once you realize Anders Hejlsberg, the primary designer of C# and .NET, was the chief architect of Delphi at Borland which used Object Pascal.

  • string is an intrisic type in C# (see more about structs later)

  • Parameter substitution in Console.WriteLine() is useful. There is also an ability to format the parameters (e.g., Console.WriteLine( "Sum of 1,2,3 is {0:N0}.", Sum(1,2,3));) Presumably there'd be a way to generate stings using this formatting functionality. I haven't run into it yet.

  • "public sealed class Plane:Flyer" sealed stops any subclasses like final in Java

  • Use colon (:) for subclassing instead of extends

  • Use colon (:) for implementing an interface instead of implements

  • Visibility identifiers are nearly the same, public, protected, private, internal. Internal is like package scope in Java. Default is private in C# as opposed to protected in Java when it isn't explicitly defined.

  • Exception handling is the same as Java except there are no checked exceptions in C#

  • Use "is" instead of "instanceof"

  • Interfaces are available in C#, like the IComparable with the int CompareTo( object o) method. Naming convention starts interfaces with I.

Inheritance

  • In Java, every method is virtual and every method call is dispatched with a dynamic lookup. In C# you must explicitly label a method as being virtual. This has the potential to create some unexpected behavior:

    1. Create a subclass and override a method using syntax like "new public void MethodName()"

    2. Create a variable declared to be the supertype.

    3. Assign this variable an instance of the subclass.

    4. Now call the overridden method.

    5. The method that gets called will actually be that of the super class and NOT the subclass.

    6. If you were to typecast it to the subclass then the subclass's method gets called. Funky.

    7. This doesn't happen if the super's method is declared virtual and the subclass is declared with override

  • You must explicitly label an overriden method with the keywords override or new. Compiler will fail otherwise.

  • Multiple constructors are supported but in order to call other constructors in the same class you have to use a strange declaration. (e.g., public Employee(): this(null, 0){...}) So why is't "this(null,0)" between the braces?

  • To call a super class's constructor use something like "public Manager():base("Joe", 100){...}".

Properties
  • In Java an instance variable with get and set methods is oftern referred to as a property. This idiom is often used by IDE's.

  • C# defines a special syntax for properties that reduces some of the code that needs to be written. Basically it comes down to declaring a private instance variable usually named with camelCase (one of the few exceptions). Then you define a property with get and set blocks:


private string name;
public string Name{
get{ return name; }
set{ name = value; }
}

  • Now the property can be referenced just like an instance variable but behind the scenes the get and set blocks of the property is being called. I think this is a much more natural syntax than calling a method. e.g.,

person.Name = "Joe";

  • Delphi had all these features too (with a different and IMHO simpler syntax). I was also suprised that I didn't see any way to simply declare indexed properties. Delphi had that one too.

Compiler
  • Mono mimics the Microsoft C# command line compiler very well:

  • multiple files compiled at once to create the exe "mcs /out:Test.exe Ape.cs Human.cs"

  • to compile just this class and create a *.netmodule file: "mcs /target:module Ape.cs"

  • to compile the exe with the *.netmodule use: "mcs /out:Test.exe Human.cs /addmodule:Ape.netmodule"

Structs
  • Supposedly a struct differs from a class by the way the memory is allocated.

  • Structs are created more like intrinsic variables within the class

  • But they look just like classes! They can implement interfaces, their members have visibility specifiers, and they can even have methods and constructors!

  • boxing and unboxing happen automatically between intrinsics and their structure brethren. e,g, int and Int32 (a struct)

  • The is operator also works on structs

Delegates
  • They're similar to function pointers and similar to Objective-C's selector concept (although objc's selector is more dynamic in that it's a message that isn't tied to any particular object instance).

  • To use delegates:

    1. declare the delegate that describes a method signature

    2. instantiate a delegate that points to the method of an object instance that has a matching method (note that the method name doesn't matter just the return type and parameter types) e.g., MessageDelegate target = new MessageDelegate( myObject.PrintSomethingOut );

    3. now invoke the method e.g., target("Hello, World!");

  • This all avoids the mess in Swing where you must create a Listener Interface, often a Listener Adapter and then implement the interface or subclass the adater with an anonymous class. For example when wiring up gui object events to methods:


button.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent e ){
//do Something like delegating to another method
}
});

  • Five lines of code vs one plus all the overhead of a new class just to delegate a method call!! Now the Java version is closer to the typical Observer pattern and is pretty well understood and is still valid but I must admit that I like the brevity and readability of the delegate implementation.

Collections
  • Collection types are LinkedList, ArrayList, Queue, Stack, Dictionary which are similar to Java's List, Map, and Set interfaces and the various implementations.

  • I like names like Queue, Stack, and Dictionary

  • Index access to the collection

Console.WriteLine(((Address)emp.Addresses[1]).City);

  • this is actually calling the get method of the class with an index value, the index doesn't have to be an int. e.g.,


class MyArray{
public String this[index]{
get{ return array[index];}
set{array[index] = value;}
}
}

  • C# uses the term IEnumerator. Enumerator was deprecated in Java in favor of the Iterator interface. but basically the same thing

  • If the class implements IEnumerable then the foreach loop can be used instead which does the typecasting automatically on each loop iteration.

Friday, February 04, 2005

Squeaky Smalltalk

I'm nearly through the C# book I borrowed from the library (I'll blog about it soon) and this morning I was relating some of my thoughts to a co-worker about the language. But somehow we got onto the topic of Smalltalk.

She was explaining to me how weird the syntax was. We found a website that outlined the differences between Java and Smalltalk. And although things looked a little odd I recognized syntax similarities to Objective-C which didn't come as too much of a surprise and I recognized closure similarities to Ruby.

So during some free time at lunch I downloaded and tried out a free version of Smalltalk called Squeak. That environment threw me for a bit of a loop but through the help of the BankAccount tutorial I was able to write a little rinky dink class, instantiate it, interact with it and inspect it. Pretty cool.

My curiosity is piqued so I'll probably give Smalltalk a bit of a spin. Not that I expect to develop anything significant with it but since it was so instrumental in the design of other languages I figure it might be interesting...

Wednesday, February 02, 2005

All In The Family

What do Java, C#, Objective-C and Smalltalk all have in common? They're all in the same family!

Tuesday, February 01, 2005

LuntBuild

Having experienced (over a year ago now) the setup of Cruise Control (to do continuous integration of Java projects) and being thoroughly underwhelmed by the quality of that software I was quite happy to discover LuntBuild today. Bonnie, another developer at our site, set it up on one of our servers so that probably contributes to my positive experience, but setting up a scheduled build complete with the CVS extract, the call to my existing Ant script, an automatic labelling of successful builds and an e-mail to notify me of build success was a point and click affair and was done in about 20 minutes. Nice!