"Hi! I'm Tux The Linux Penguin"

Picked this up in December 1999 at the Linux/Open Source Bazaar, Jacob K. Javits Centre, New York.

It has a tag on its 'behind' saying "Hi! I'm Tux The Linux Penguin" The badge has the heading "Penguin Power."

The badge also uses the quaint spelling 'LinuX', which proves how old it is: who would spell it that way nowadays!

I was presenting a 2-day tutorial session on Linux (RedHat 5.2). I have mentioned another trophy before.

Tags: Retrospectives

…Must…Resist…JRuby…Scribble…

I am weak-willed, I admit it! A JRuby version of Scribble!

require 'java'

include_class 'java.awt.event.MouseAdapter'
include_class 'java.awt.event.MouseMotionAdapter'
include_class 'javax.swing.JPanel'
include_class 'javax.swing.JFrame'
include_class 'java.awt.Graphics'
include_class 'java.awt.Color'

$model = Array.new

$last_x = 0
$last_y = 0

class MouseAction < MouseAdapter
  def mousePressed(e)
    $last_x = e.x
    $last_y = e.y
  end
end

class DrawLine
  def initialize(x0, y0, x1, y1)
    @x0 = x0
    @y0 = y0
    @x1 = x1
    @y1 = y1
  end

  def paint(g)
    g.drawLine(@x0, @y0, @x1, @y1)
  end
end

class MouseMotionAction < MouseMotionAdapter
  def mouseDragged(e)
    g = e.component.graphics
    x = e.x
    y = e.y
    g.setColor(Color.black)
    d = DrawLine.new($last_x, $last_y, x, y)
    $model << d
    d.paint(g)
    $last_x = x
    $last_y = y
  end
end

class Scribble < JPanel
  def paint(g)
    $model.each {  | it | it.paint(g) }
  end
end

class MainWindow < JFrame
  def initialize
    super "JRuby Scribble"
    setDefaultCloseOperation JFrame::EXIT_ON_CLOSE
    setSize(600,400)
    setResizable(false)
    panel = Scribble.new
    panel.addMouseListener MouseAction.new
    panel.addMouseMotionListener MouseMotionAction.new
    add panel
  end
end

MainWindow.new.setVisible true

Surprisingly, I couldn't find one of these out there on the 'web, so this is All My Own Work :-)

I wrote it using the JRuby implementation shipped with Netbeans 6.7m3.

I have to say, I found the '@', '$' stuff pretty irritating, but I guess a Perl guy would feel at home (hmmm…is this a good thing….hmmmmm)

Welcome, World!

Nice to meet you :-)

Hope you enjoy your stay.

Significant Search Technology

This strikes me as being significant technology for the future of search.

http://facemining.pittpatt.com/.

Not to mention a trekkie's delight!

Tags: Tools

Java, Groovy, JavaFX

From late 1997 to late 2004, I developed and ran a very nice Java course. Took it all round the world, in fact.

It's still available…and still the best Java course out there, IMHO (and I have given quite a few from several other [major] vendors in addition to my own).

One of the exercises that that participants seemed to enjoy was to take an applet not to dissimilar from the Scribble applet published in David Flanagan's Java in a Nutshell and modify it so that the drawing persevered through screen redraws.

This helped the participants get their head around anonymous inner classes and the applet lifecycle callbacks and also gave them a chance to play with the List collection interface/classes.

Time moves on and we now have Groovy's SwingBuilder and the new JavaFX technology promoted by Sun.

Prompted by the negative press that JavaFX has received, postings such as this and the speed increases of the "consumer JRE", together with the fact that it is now bundled into Netbeans 6.5.1 (making it easy to get hold of and play with; not sure why it is currently missing in action for 6.7m3) I decided to see how the 'newcomers' stacked up.

The examples aren't completely identical (one is an applet, while the others are JFrames, for example) but this is still a nice 'feel' exercise.

I am reminded of the Evolution of a Programmer joke…

Here goes…

=== Java (in homage to Java in a Nutshell, Second Edition)

import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class PerseveringScribbleCollections extends java.applet.Applet
  {
  int last_x = 0;
  int last_y = 0;
  List model = new ArrayList ();

  public void init ()
    {
    addMouseListener
      (
      new MouseAdapter ()
        {
        public void mousePressed (MouseEvent e)
          {
          last_x = e.getX ();
          last_y = e.getY ();
          }
        }
      );

    addMouseMotionListener
      (
      new MouseMotionAdapter ()
        {
        public void mouseDragged (MouseEvent e)
          {
          Graphics g = getGraphics ();
          int x = e.getX ();
          int y = e.getY ();
          g.setColor (Color.black);
          DrawLine d = new DrawLine (last_x, last_y, x, y);
          model.add (d);
          d.paint (g);
          last_x = x; 
          last_y = y;
          }
        }
      );
    }

  public void paint (Graphics g)
    {
    ListIterator l = model.listIterator ();
    while (l.hasNext ())
      {
      ((DrawLine) l.next ()).paint (g);
      }
    }
  }

class DrawLine
  {
  private int x0;
  private int y0;
  private int x1;
  private int y1;

  public DrawLine (int x0, int y0, int x1, int y1)
    {
    this.x0 = x0;
    this.y0 = y0;
    this.x1 = x1;
    this.y1 = y1;
    }

  public void paint (Graphics g)
    {
    g.drawLine (x0, y0, x1, y1);
    }
  }

=== Groovy (based on the Java version, above. All my own work ;=))

import javax.swing.WindowConstants as WC

import groovy.swing.SwingBuilder
import java.awt.Color
import java.awt.Graphics
import javax.swing.JPanel

def list = []
def last_x = 0
def last_y = 0

SwingBuilder.build {
  frame(title: 'Groovy Scribble',
      size: [600, 400],
      show: true,
      pack: false,
      resizable: false,
      defaultCloseOperation: WC.EXIT_ON_CLOSE) {
    widget(new Scribble(list: list),
        mousePressed: {e ->
          (last_x, last_y) = [e.x, e.y]
        },
        mouseDragged: {e ->
          (x, y) = [e.x, e.y]
          def d = new DrawLine(x0: last_x, y0: last_y, x1: x, y1: y)
          d.paint(e.component.graphics)
          list << d
          (last_x, last_y) = [x, y]
        }
    )
  }
}

class Scribble extends JPanel {
  def list = []

  public void paint(Graphics g) {
    list.each { it.paint(g) }
  }
}

class DrawLine {
  def x0
  def y0
  def x1
  def y1

  public void paint(Graphics g) {
    g.setColor(Color.black);
    g.drawLine(x0, y0, x1, y1);
  }
}

=== JavaFX (adapted from Planet JFX)

package au.com.transentia.scribble.javafx;

import java.lang.System;
import javafx.scene.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.*;
import javafx.scene.shape.Polyline;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

def w = 600;
def h = 400;

class Scribble extends CustomNode {
    var polyline: Polyline;

    public override function create(): Node {
        var group: Group = Group{
            onMousePressed: function (e: MouseEvent) {
                polyline = Polyline{ points: [e.sceneX, e.sceneY] };
                insert polyline into group.content ;
            }
            onMouseDragged: function (e: MouseEvent) {
                insert [e.sceneX, e.sceneY] into polyline.points;
            }
            content: Rectangle {
                width: w
                height: h
                fill: Color {opacity: 0}
            }
        }

        return group;
    }
}

Stage {
    onClose: function(): Void {
        System.exit(0);
    }
    title: "JavaFX Scribble"
    width: w
    height: h
    visible: true
    resizable: false
    scene: Scene {
        content: [Scribble{}]
    }
}

I'm not going to draw any conclusion…not one. Nope, not one. "Left as an exercise for the reader", that sort of thing applies here…

I had fun and each example is interesting, in its own way.

Enjoy.

Tags: Groovy, Java, Programming

The State Of The Groovy World

An overview, at least. By Scott Davis: http://groovy.markma … age/7lsabbh2eldga4dm

I'll excerp the main bits:

Manning has Groovy in Action (and soon Grails in Action as well). Apress has quite a impressive cadre of titles, from DGG to Beginning Groovy and Grails, GORM, Grails + Flex, and more. The Prags have Venkat and I (Programming Groovy and Groovy Recipes, respectively), plus Dave Klein's upcoming Grails title. Morgan Kaufmann has the tragically underrated Groovy Programming.

In terms of online articles, I've been writing Mastering Grails for IBM developerWorks for a year and a half now.

I've rebooted Andy Glover's old Practically Groovy series. (BTW, I went back and rewrote every Groovy example dating back to 2004 so that they run under modern Groovy - not as hard a task as you might imagine…) That's effectively 50-ish new pages of new material each month. (And boy are my arms tired… wink) Those articles are regularly among the most popular at IBM devWorks, FWIW. There's also the monthly GroovyMag, JavaWorld, http://groovy.dzone.com/, SCADS of personal blogs, the Groovy/Grails podcast from Glen and Sven, and more…

I speak 30+ weekends a year on the NFJS tour talking about Groovy and Grails. That's in addition to JavaOne, TSSJS, QCON, JavaZone, and a host of others. When I'm not speaking publicly, I'm offering private Groovy/Grails training/mentoring/consulting through http://thirstyhead.com . There are many other folks, like Ken Kousen, smokejumper, SpringSource (natch), who do the same.

Andy Glover's BDD framework easyb - written in Groovy - just won a Jolt award. Both Groovy and Grails have won JAX awards. There's Griffon, Gant, Gradle, GMock and many other libraries/ frameworks that leverage the power of Groovy and Grails under the covers.

Companies from Wired to LinkedIn to IBM to SAP to SkyTV to Tropicana to Pepsi to Mutual of Omaha to the (US) National Cancer Institute to many many others without a public-facing website or case study have adopted Groovy and Grails.

The Groovy/Grails community has an embarrassment of riches to choose from. (Apologies if I missed an obvious addition to any of the informal lists I rattled off of the top of my head.) This mailing list alone should be an indication of how vibrant the community is.

A nice follow-up quote from Dierk König:

Unlike other languages, Groovy positions itself as "Java's dynamic friend" rather than trying to be a replacement.

And a bit more from Russel Winder:

"Groovy, the symbiotic partner to Java on the JVM". The words "partner" and "symbiotic" are crucial here!

Where you need static type checking and fastest execution performance use Java, as soon as you need any form of reflection or dynamism consider switching that bit of your system to Groovy. This is multi-language programming in a total system context.

(My italics)

Time for you, dear reader, to jump on the Groovy bandwagon. Don't be afraid, the horses won't bite!

Tags: Griffon, Groovy, Programming

A Big Thank-You

To Atlassian, for their special (limited time) offer of $5 each for Jira and Confluence: The Atlassian $timulus Package.

The world economy needs to get back on track and we want to help. Our products help teams communicate better, have more productive interactions and get stuff done. We want to help small entrepreneurial teams get the economy back into high gear.

It was all in a good cause, as well:

We want to raise $25,000 for Room to Read, who help improve education in the developing world by establishing libraries, schools and more. Help us hit our goal, and create the young entrepreneurs of tomorrow.

I helped them hit their goal…the offer was just too good to refuse!

Great products, great (aussie) company and a great idea…gotta love it!

A Guru, Eh!

This is too good to hide away on LinkedIn:

In the years that I worked with Bob, I watched him design, develop and deliver an impressive range of 'mission critical applications'. As testament to their quality and appropriate design, many presently service the ENERGEX community. Bob is a font of knowledge backed up by hard earned practical know how. He creates scalable Java enterprise solutions that leave a group free to focus on new project work. As team lead, that was the benefit to me. I have no hesitation in recommending Bob as a high caliber JAVA platform and technologies guru.

Thanks Alex!

Pretty Useful Pivot

Wish Pivot had been around a couple of years ago:

Pivot is a platform for building rich internet applications in Java. It combines the enhanced productivity and usability features of a modern RIA toolkit with the robustness of the industry-standard Java platform….Pivot applications are written using a combination of Java and XML and can be run either as an applet or as a standalone (optionally offline) desktop application.

Try the "Kitchen Sink" demo yourself. It's really impressive with Java 6u10 or above…could applets really be making a comeback? Hmm!

Tags: Tools

A Pair Of Useful Utilities

BareTail and BareGrep from Bare Metal Software

Pro versions are avilable, as well.