Archive

Archive for March, 2011

ACCU 2011 Introduction to Scala Talk

March 28th, 2011 Comments off

Hey All

I will giving a presentation at ACCU 2011 Conference in Oxford on 13th April: Introduction to Scala. The conference takes place in Oxford at the Barceló Hotel on the outskirts of the town. Registration is still open last time I check, so if you want to go then do it now.

I examined the full schedule and I see my talk is first one on Wednesday morning at 11am in Cherwell.

I plan to give a fair robust overview of programming in Scala. It will cover Beyond Java the landscape that we all face, some the ideas on the adoption, where the JVM platform is going. It will be technical and the syntax and concepts of Scala will definitely covered. There will be guide to the functional side of the Scala. Above all I will be stressing the Yoda line: “with great powers, comes great responsibility”.

The ACCU has a long history with C/C++ in the past and the over decades this has been distilled with object orientation, agile development, patterns, and generally best practice for programmers. I was originally a member of ACCU for its C/C++ years and years ago. I moved on as we all do. I moved to Java in 1998 and left C++ behind.

It is good to represent the Java platform again in Oxford and I am looking forward to it.

PS: James Gosling has joined Google: Bang Goes The Drum!

Functional Exchange 2011 Lost and Refound?!

March 25th, 2011 Comments off

Somehow my machine lost a blog entry on the Functional Exchange.  Anyway, better late than never ever.

Audioboos

Listen!

Listen!

Listen!

 

Pics

Functional Exchange 2011

Simon Peyton Jones

 

 

Sorry. My time is limited to recover the rest of this blog entry.

Categories: Uncategorized Tags:

Cuke-Up 2011 Amazing Specifications By Example

March 25th, 2011 Comments off

Wow! I was really amazed by today’s Coke-Up conference at Skills Matter. It was a worthwhile experience and it was great to meet some of the members.

  • First, let me say it was a complete different crowd of Londoners and software developers than I was used to. Most of the folk in my network are Java, Groovy and Scala software engineers, designers and developers
  • Second, it was great to see ScalaTest’s inspiration in its raw form or it’s cousin. Cumber’s step definitions and feature files. The Ruby world has some great tools RSpec and friends.
  • There lots of polyglot interest here from many Ruby developers to Groovy to F# developers
  • I learnt a new term today “Specification By Example”
  • I learnt another relatively new term “Agile Test Driven Development”
  • Elizabeth Keogh’s and Dan North were absolute fantastic with their 30 minute presentation of Deliberate Discovery
  • Matt Wynne was a hot with his hilarious Mortgage Driven Development
  • Aslak Hellesoy was very helpful with the Kanban inspired Push and Pull request and response cards exercise in the late afternoon

Finally the Cuke.Up conference taught me to treat business analyst and quality assurance with much more respect. My goodness we are all in this software development business together. The goal is to produce better quality and business value to our clients with our software applications.

Other notable presenters and sorry I cannot name you all were Richard Paul (Cuke4Duke and Groovy DSL) and Joseph Wilks (Songkick) and  Antony Marcanos (CukeSalad).

You find the videos of the session here e.g. Refunctoring your Cukes  and the Jason Gorman’s spoof article on Waterfall 2006 development, which referenced by Matt Wynne’s MDD talk. I also recommend Deliberate Discovery.

 

Audioboos

Listen!

Listen!

Listen!

 

 

Cuke.Up 2011

Alsak Hellosoy

 

Cuke.Up 2011

Elizabeth Keogh [L], Dan North [R]

 

Cuke.Up 2011

Matt Wynne

 

Cuke.Up 2011

Anthony Marcanos

 

Cuke.Up 2011

Joseph Wilks

 

Thank you Wendy and the entire Skills Matter team for a great day out.

It was absolutely fantastic to bump into my CSM teacher yesterday too: a very big shout to Martine Devos.

Cuke-Up Some Cucumbers

March 23rd, 2011 Comments off

You have probably guessed correctly. That’s right! I will be making a personal appearance at Skills Matter tomorrow for Cuke-Up, which is the one day conference about Cucumber BDD (Behaviour Driven Development) tool.

Why am I investing time learning about Ruby testing tool?

  • Well the answer is that many of Ruby’s goodness including RSpec have made their way into Scala world. Bill Venner’s ScalaTest in one framework influenced by RSpec.
  • In the Groovy land they reports of people invoke the WebDriver to execute step definitions. Also the Cucumber website looks awesome, man!
  • Something tells me that learning some ideas of Ruby might be useful later when I look and play around Mirah.
  • Finally, I am at liberty, justice and peace.

Learning Behaviour Driven Development from the horse’s mouth, or a very leading edge person, like Aslak Hellesøy is a no-brainer. There might be still tickets available so hurry. See you there.

Thanks to Wendy / Skills Matter

Meanwhile, let’s enjoy some photos from last Friday’s Functional Exchange:

 

Functional Exchange 2011

 

Functional Exchange 2011

 

Functional Exchange 2011

 

Allie oop!

Scala Swing REPL: Resolved

March 23rd, 2011 Comments off

Well after a night’s sleep and a good rest, which always sorts out the best engineers among us, I realised that the issue is my lack of brain cells on Scala’s Uniform Access Principle. If you noticed in yesterday’s program, the editor panes were created like this:-

    def outputPane = new EditorPane { text="?" }
    def inputPane = new EditorPane { text="List(1,2,3,4,5)" }
    def splitPane = new SplitPane( 
         Orientation.Horizontal, inputPane, outputPane ) 

So I am sorry to say, there is no pint of beer for you, because I resolved my own issue. However the definitions are actual method declarations. That is every time I referenced outputPane or inputPane in the older program I was calling a method that instantiated a EditorPane wrapper and for good measure a real JEditorPane. Of course in a real program that could disasterous if the underlying peer was a expensive resource to create. The solution is to change the def to a val declaration and therefore the Swing wrapper is created only once in the program.

    val outputPane = new EditorPane { text="?" }
    val inputPane = new EditorPane { text="List(1,2,3,4,5)" }
    def splitPane = new SplitPane( 
            Orientation.Horizontal, inputPane, outputPane ) 

In the end, there was no problem with Swing Scala or asynchronous concurrency threading in Java Swing bar the usual caveat emptor on the Event Dispatch Thread. The correct behaviour is shown in the program towards the end of this blog entry. Suffice to say, I would strongly recommend investing in the e-Book edition of Programming in Scala 2nd Edition, 2010 of Martin Odersky, Lex Spoon and Bill Venners from Artima press. I can particularly that the Kindle edition of book is worthwhile, it really formats well and it works out well. There are two chapter in the book that discuss the Scala Swing library in depth and, indeed, more than complement the free PDF in the Scala docs.

Now here is the working program. You need to add the program’s classpath the scala-compiler-2.8.1.jar and jline-0.9.91.jar from the Maven and Scala-Tools repos. I also changed EditorPane to TextArea from yesterday’s code extract:

package swingrepl

import java.io._
import scala.swing._
import scala.swing.event._

import javax.swing.SwingUtilities

import scala.tools.nsc._
import scala.tools.nsc.interpreter._

/**
 * Swing version of the REPL
 * User: Peter
 * Date: 22/03/11
 * Time: 14:34
 */
 class SwingRepl {
   def create(): MainFrame = {
      new MainFrame {
        title = "Swing REPL (cc) XeNoNiQUe Peter Pilgrim - Very Basic Console"
        preferredSize = new Dimension(900, 900 )
        contents = splitPane
     }
   }

   def debug( x: AnyRef ): String = {
    x match {
      case Nil => "nil"
      case null => "null"
      case _ => x.getClass().getName() +"@"+Integer.toHexString( java.lang.System.identityHashCode(x) )
    }
   }

   val outputPane  = new TextArea {
     editable = false
     text = "Text output"
   }
   System.out.println("outputPane="+debug( outputPane) )
   System.out.println("outputPane.peer="+debug( outputPane.peer) )


   val inputPane: TextArea = new TextArea {
     text = "List(1,2,3,4,5) map ( n => n * n )"
     editable = true
     listenTo(keys)

     reactions += {
       case e: KeyPressed => {
         // println("keyCode =" +e.peer.getKeyCode+", keyChar = "+e.peer.getKeyChar)
         if ( e.peer.isControlDown && e.key == Key.Enter ) {
           interpret( text )
         }
       }

       case _ =>
     }
   }
   System.out.println("inputPane="+debug( inputPane) )


   def scrollInputPane = new ScrollPane( inputPane )
   def scrollOutputPane = new ScrollPane( outputPane )

   def splitPane = new SplitPane( Orientation.Horizontal, scrollInputPane, scrollOutputPane )  {
     dividerLocation =  100
   }

   protected val swriter = new StringWriter()
   protected val pwriter = new PrintWriter( swriter ) {
     override def print( line: String ) {
       super.print( line )
       System.out.println("print line=``"+line+"''")
       System.out.println("swriter.toString=<<"+swriter.toString+">>" )

       SwingUtilities.invokeLater( new Runnable() {
         override def run(): Unit = {
           // outputPane.text = outputPane.text +"\n"+ line +"\n"
           System.out.println("3) outputPane="+debug( outputPane) )
           System.out.println("4) outputPane.peer="+debug( outputPane.peer) )
           System.out.println("BEFORE outputPane.text = "+outputPane.text)
           outputPane.text = swriter.toString
           System.out.println(" AFTER outputPane.text = "+outputPane.text)
           outputPane.peer.revalidate
           outputPane.peer.repaint()
         }
       })
     }
   }

   protected val cmd = new InterpreterCommand(Nil, println )
   System.out.println("cmd="+cmd)
   protected val settings = cmd.settings
   System.out.println("settings="+settings)

   settings.usejavacp.value = true

   protected val interpreter = new Interpreter(settings, pwriter ) {
     override def reset() = { super.reset; unleash() }
     override def unleash() = { super.unleash;  }
   }
   System.out.println("interpreter="+interpreter)
   protected val completion = new Completion(interpreter)
   System.out.println("completion="+completion)


   def interpret(cmd: String): Unit = {
     System.out.println("replInvoker.interpret cmd="+cmd )
     System.out.println("interpreter="+interpreter)
     interpreter.interpret(cmd)
   }
 }

object SwingRepl extends SimpleSwingApplication {
  def top = new SwingRepl().create()
}

No free beer ;-)

PS: You will notice that I put in a simple debug() method to dump out the object reference. It helped me track down the issue and then eureka. As they say: everything appears obvious after the invention.

PS PS: I would love to repeat the exercise for JavaFX 2.0 Beta and all I need is the multi-line TextInput and the equivalent JTextArea output components.

Categories: Java, programming, Scala, Swing, technology Tags:

Swing Scala REPL: What Is Wrong Here?

March 22nd, 2011 3 comments

 

I just spent the best part of two hours attempting figure out an interactive REPL for Scala, a la the Groovy Console, but a very basic version. My progress has not been lightning fast. Why?

package swingrepl

import java.io._
import scala.swing._
import scala.swing.event._

import javax.swing.SwingUtilities
import scala.tools.nsc._
import scala.tools.nsc.interpreter._

/**
 * Swing version of the REPL
 * User: Peter
 * Date: 22/03/11
 * Time: 14:34
 */
object SwingRepl extends SimpleSwingApplication {

  def outputPane  = new TextArea {
    editable = false
    text = "Text output"
  }

  def replInvoker = new ReplInvoker( outputPane )
  replInvoker.start()

  def inputPane: TextArea = new TextArea {
    text = "List(1,2,3,4,5) map ( n => n * n )"
    editable = true
    listenTo(keys)

    reactions += {
      case e: KeyPressed => {
        // println("keyCode =" +e.peer.getKeyCode+", keyChar = "+e.peer.getKeyChar)
        if ( e.peer.isControlDown && e.key == Key.Enter ) {
          replInvoker.interpret( text )
        }
      }

      case _ =>
    }
  }


  def scrollInputPane = new ScrollPane( inputPane )
  def scrollOutputPane = new ScrollPane( outputPane )

  def splitPane = new SplitPane( Orientation.Horizontal, scrollInputPane, scrollOutputPane )  {
    dividerLocation =  100
  }

  def top = new MainFrame {
    title = "Swing REPL"
    preferredSize = new Dimension(900, 900 )
    contents = splitPane
  }


  /**
   * Programmatically launching the Scala REPL
   */
  class ReplInvoker( val outputPane: TextComponent ) {
    private val swriter = new StringWriter()
    private val pwriter = new PrintWriter( swriter ) {
      override def println( line: String ) {
        super.println( line )
        System.out.println("println line="+line)
        outputPane.text = swriter.toString()
      }
      override def print( line: String ) {
        super.print( line )
        System.out.println("print line="+line)
        System.out.println("swriter.toString="+swriter.toString )

        SwingUtilities.invokeLater( new Runnable() {
          override def run(): Unit = {
            outputPane.text = outputPane.text +"\n"+ line +"\n"
            outputPane.peer.validate()
          }
        })
      }
    }

    private val cmd = new InterpreterCommand(Nil, println )
    println("cmd="+cmd)
    private val settings = cmd.settings
    println("settings="+settings)

    settings.usejavacp.value = true

    private val interpreter = new Interpreter(settings, pwriter ) {
      override def reset() = { super.reset; unleash() }
      override def unleash() = { super.unleash;  }
    }
    println("interpreter="+interpreter)
    private val completion = new Completion(interpreter)

    def start() {
       println("ReplInvoker.start")
    }

    def interpret(cmd: String): Unit = {
      println("replInvoker.interpret "+cmd )
      interpreter.interpret(cmd)
    }
  }
}

I really do not understand why this code is not working at all. It is a Swing application to programmatically invokes Scala NSC REPL. I have two JEditorPanes in set horizontally in a JSplitPane. The upper editor pane is a reserved for text entry. The lower editor pane is not editable is reserved for capturing the output of the Scala.

To fire the REPL interactively in the upper pane, hold the CTRL key and pressed the RETURN/ENTER key. Invoking the REPL works fine. However it is the update to the lower pane that causes concern. I can see the interactive REPL returning a result, yet the JEditorPane is not being updated. Is this a Swing Scala bug? Or does Java Swing bug?

I suspected the cause was a Swing multithreading problem hence I used SwingUtilites.invokeLater to make sure the update was on the Event Dispatch Thread, however to no avail. JComponent.repaint() nada, JComponent.validate() nada. What gives?

Oh yes in case you are wondering, JavaFX 2.0 early access does not yet have a multi-line equivalent of JTextComponent.

I will be very interested in finding out what is wrong with this picture? If you know the answer, then a pint of Staropramen is on me. Thanks

Categories: Rich User Interface, Scala, Swing Tags:

Dead Market, Minds Full of Hate

March 22nd, 2011 1 comment

The market is dead. The brief flurry of activity in January and February is at an end. There is truly not a lot going on out there.

I seem to have attracted some haters out there. Because I have been pushing Beyond Java, looking at innovation beyond Java the programming language, many folk seem to be upset about this. The next time you see me, please feel free, if you want to cross the street and walk on the other side of the road. I see you though. Of course I can see you creeping and scurrying in the dark alleys of tech town. I simply do not have time for minds full of hate. However you have a right to choose hate for your heart. It is sad, but true.

Here is the news: Innovation will be happening whether you like it or not. You may not be agreeable to it, or it might actually believe that Beyond Java is too risky for you or you cannot afford it now. This moving feast is happening and it is on the road. Tough.

You Talk For Long Times: Tale of Two Agilities

March 22nd, 2011 Comments off

Today, I know for a fact, that the market is dead. It is easy to see why it is, and why everyone involved agile or agility or so bloody confused.

 

The Tale of Two Agilities by Barry Hawkins, XtraNormals. 

 

Explicit material over 16′s only: adult, swearing, alcohol

  • We do Agile at my job
  • We have the Scrums, there is one everyday
  • They are called compound statements. Books have lots of them. They are typically mastered from the age of three or four.
  • Do you teach Rails?
  • I have been to RailsConf, it was awesome, there were flags and chicks. Rad!
  • I have told my Agile boss that we need maintenance programmers
  • It is waste for me to do maintenance programming
  • Maintenance programmers are cheaper, hardware is cheaper too
  • We are agile we can change what we are doing every time, we don’t plan, timelines are useless
  • You talk for long times

PS: Barry Hawkins played this amusing YouTube video at the JavaPosse Round Up 2011 lightning talks.

Functional Exchange At Skills Matter 18 March

March 17th, 2011 Comments off

After the my usual downbeats posts on Beyond Java on the JVM, I stumbled across Charles Nutter’s blog article [The Future Part One] again and reread it. The date on this article states April 2009 predates my own thinking on the Java platform, at that time, I was more interested in JavaFX Script version 1.1. So the amazing thing is that his conclusions are still valid today and there is still a risk of the entire Java platform not evolving. Headius never did get around to writing the second part of his entry, did he?

I have been brewing some ideas on Beyond Java:

  • Start a campaign – Twitter , Facebook online – some graphics, create web site – we would campaigning to business leader, stake leaders
  • Start lobbying – create a beyond Java manifesto, create some beyond Java web site – we would be lobbying other developers, architects
  • Go viral – I thought about gathering a set web cam or flip HD or Kodak videos that go strung together by from 25-30 well known developers. We can edit them together and upload to YouTube or Vimeo or both – we will be building our self estem, empowering ourselves, putting we others on notice, that we refuse to be held to ransom to ancient tech on the Java platform
  • Down tools and act up –  leading developers could refuse ancient JDK 1.4.2 work or WebSphere 6/7 leave that to laggard developers. It could be a sort of deliberate practice, a tech talent starvation if you will – may be a  couple of institutional business models will fail after the technology model fails.

Anyway, I digress, I am heading to Skills Matter Functional Exchange tomorrow (18 March 2011) in central London [Tickets Might Be Still Available]. My next personal appearance over there, I will be progressing my continual learning, enhancing more core professional competency, and meeting and greeting other developers. (Notice that sick scrawl matches the current human resource invective). Dave Pollak is going to be around for Lift framework talk, Jonas Boner and Victor Klang. Having met Chris Marinos MVP F# Dude from the JPR11, then F# is definitely of interest and the distant cousin of Scala on dotNet platform. This is going be a day out in town, so come along say hello. Ask me about the Future of the JCP, JavaFX 2.0 and Scala when you want.

PS: Thanks to Wendy / Skills Matter

PS PS: How about this as a strap-line? “I am Peter Pilgrim, a top-tier developer in UK and I am Beyond Java on the JVM. There is no going back now. ”

Deeply Worried Q1 – Q2

March 16th, 2011 2 comments

I have just had massive blow out. I seem to be fighting and arguing all the time now with close people near me. I feel ratty even talking to acquaintances. A turning point has been reach, and I honestly do not what on earth to do next about it.

It would appear that investment banks are extremely confused on what their long strategy is to do with Java and even Beyond Java:

  1. The sheer unpredictably of interviewer requirements, unpredictably of technical, social, team make up, and process whether it is agile or non-agile
  2. All interviewers are different because all client are different; this is understood and they all have different personalities; however common rapport is increasingly hard to achieve in the mix there
  3. Difficulty of getting to the conclusion of a potential engagement; the perfect match is proving harder to achieve 
  4. Lack of foresight in clients in that they really want. It seems that they only interested ever in a fix for the pain right here right now – they are unwilling to look at changing the application architecture; infrastructure; underlying algorithms behind the scene
  5. Expect wizards to turn up and perform a spell of magic – and clear all ills. We still do not if there is a special technical skill that is out there (a silver bullet) if there is such a thing.
  6. The state of the job market software engineering in financial services / investment bank in City of London is unknown. Is it good or bad? Everyone seems to have a conflicting view.

With case (5) I could have said several years ago. “Ah! The missing skillset of knowledge is Java Servlets or Struts or JSF or EJB or even Spring Framework”, then I could have done something about it. In 2011 the answer is “Well, Hellfire, save matches, fuck a duck and see what hatches!” and my own little addendum to Steven Tyler’s [American Idol Judge] surprised vocal curse-rhyme is, “Hail Jesus and Mary! Spread your legs, buttocks and latches. Give me good sex, herpes and whatever catches”. In other words if there is a magic inspired Java technology X that one needs to get an engagement in 2011, then it is news to me.

The deep worry of (5) is, I believe that it is further evidence of Java ecosystem fragmentation and disparate wealth and spread of technologies. On the one hand I would be over joyed if the clients now let start looking Beyond Java on the JVM, but they are unanimously sticking with Java the programming language, sticking purely to it, becoming the late majority and progressing to a laggard category.

These dogs [bitches] are holding back the innovation and early adopter categories (including me, myself and I; and also add you, yourself and you). We know that the backward compatibility guarantees is the constraint on the Java programming language. You and I can see that this rubber band stretching between laggards and early adopters has to break at some time soon as the client themselves are demand more of the applications that run on the Java software platform. We can no longer be held to ransom for application strongly tied up to legacy WebSphere application server 4/5, WebLogic Server 8 or steadfast only runs on a JDK 1.4.2. The clients must know that they have to upgrade their application, give up these legacy environments, reinvest for future ROI, refactor for sustainable architecture, in order to ultimately be competitive in their technology model, which is by now proportional to the performance their business model.

In case (4) I see a lot of job specifications for things like Java performance and multiple thread programing / concurrency expertise.

The candidate must have extensive Java knowledge and must be experienced in writing streamlined (memory and CPU efficient) code. Additionally, they must have a very good understanding of Java multi-threading and Java performance tuning.

This suggests to my mind, client are facing a lot of issues about pain now, fire-fighting and fixing the problem short-term. It just does not suggest fixing performance in a long-term strategic way through innovation and changing the architecture or searching for a better algorithm or collapsing layers appears to be non-thought here. Not up for discussing. Nada.

It seem all to soon to be like a Hollywood action movie scene: Just load the fucker and fix it so the actor can keeping shooting bullets from my rifle, whilst not thinking of day when rifles are replaced with ray-guns. (One can therefore forget talking to prospective client about Scala adoption or looking at radically different solution á la Clojure)

With case (2) this is human interaction sociological issue, the quality of interviewers seems to less than desirable IMHO. If the other side of the fence has different fixed ideas about software development rather you appear to do, then we are sunk in a face-to-face. And low and below if the organisation has dysfunctional view of Agility, then the wheels will come off …

With case (5) asking the candidate or the contract for wider flexibility suggest that the client has a lack of clarity in the first place. It is this idea of, in a British way, or wanting to dot the I-s and crossed the T-s, ticking all the boxes from A to K, in order to get SIGN OFF from the manager’s manager that is a deeply flawed and ultimately troubling. Yes one can say the job market behaves in the Keynesian model of economy, it is a seller’s markets now, but who the fuck is a ultimate master of Java, C# and C++, Perl, Python, Swing, Spring Framework, ASP, Hibernate, Core Java, JPA,Scripting Languages, Web and programming language and framework simultaneously and not already working for the software deity G.0.D? I would like to know who these mythical people are and meet them today; and I suspect so would you.

With case (6) it is hard to get the real truth of the information of engagements these days, when one is involved fighting in a war. The war is the talent search game and recruitment of good programmers. The amount of misinformation is as dangerous as finding right information. The trouble is discerning if your information is valid and good, the signal-to-noise ratio is not good today.

I am deeply worried about the future prospects. Currently my own money and budget have limits, but there are not infinite. I can postulate, blog and express my enthusiast about a Beyond Java (on the JVM platform) universe as much as humanly possible, I can talk a good game (á la Paul Gascoigne) on Java technology and the platform, as I have done it before. I am human and have limits though, and I am beginning wonder genuinely what those are at the moment …

My tech lead rant is over … Stupid, silly and uninspired … unsure what value there is there … software pride weak … we don’t reach … we don’t join arms … ah we as software developers take it up the ass as per usual …

Categories: alternative, banks, beyond, future, Java, jvm, language, London Tags: