Subscribe: javanicus
http://javanicus.com/blog2/rss.xml
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
catch  exception  groovy  java groovy  java  jsr language  jsr  language  new  object  output  println  puzzles  ray  setoutput  string 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: javanicus

javanicus



Jeremy Rayner on java and other stuff.



 



Java SE 7 (preview)

2009-03-20T08:27:04+0100

I went to the Sun UK Developer Update on 19 Mar 2009 and this is what Simon Ritter had to say about... Java SE 7 Java SE 7 has been a long time coming, partly due to the distractions of open sourcing Java and engineering efforts on Java FX, but it is now due out beginning/early 2010. Fewer features are better as potential features have to be weighed up against the constraints of future expansion of the language and compatibility with the abstract model of Java. What will be in Java SE 7 (subject to change) JSR tbd - Small language changes (see below) JSR 294 - Language and VM changes to improved modularity support (see below) JSR 292 - Supporting Dynamically Typed Languages (can give up to 10 times speed increase for dynamic languages, but will now not include any new bytecode) JSR 203 - More New I/O APIs including native filesystem access java.nio.file package - FileSystem, FileRef, Path JSR 296 - a simple application framework for Swing applications SCTP - Stream Control Transport Protocol SDP - Session Description Protocol Changes to the class loader architecture Unicode 5.0 support new Date Picker in Swing JSR 166y - lightweight concurrent task framework known as ForkJoin java.util.concurrent.forkjoin package The main two features to write home about though appear to be... JSR 294 - Language and VM changes to improved modularity support The new module system will allow a way for the very old deprecated methods to go. JSR 277 Java Module System (JAM) - Sun will be discontinuing their input to this JSR JSR 294 Language extensions in support of information hiding and separate compilation - Sun looking to get this JSR going Simon Ritter also mentioned Project Jigsaw and OSGi, all of which is much better explained here JSR tbd - Small language changes If a caught exception is declared final, it is safe to rethrow any caught exception. Because the catch parameter is final, it can only hold exceptions that are thrown from the try block. try { ... } catch (final Throwable t) { throw t; } Multicatch - Support catch clauses that catch multiple exception types } catch (Exception1, Exception2 ex) { throw ex; } Null dereference operator (?.) if (a!=null) { a.b() } becomes a?.b() Syntax sugar for Generics Map = new HashMap(); becomes Map = new HashMap(); JSR 308 - type annotations List strongList; Concurrency and collections updates The following items are not going to be in Java SE 7 Closures Reified generic types First class properties Operator overloading BigDecimal syntax JSR 295 - Beans Binding [...]



London Puzzle Party

2007-10-04T08:27:04+0100

I went along to the London Puzzle Party at Camden Lock last night, which is an event run, once a month, by the wonderful little shop full of mechanical puzzles called Village Games.

I've never been along to these before, but I guessed I might like the community, after all I look with envy at the Gathering for Gardner and Burning Man events in the USA.

I arrived at the shop in Camden, to be greeted by Ray the owner, he very kindly showed me some of the most popular puzzles and took me on a tour of the books. Ray tells me that he cannot compete with the likes of ebay and amazon on the books, and therefore is not going to restock any of the shelves with books when these ones disappear.

(image)

Ray showed me where the evening event was taking place, and I took my place at the table.

Martin very kindly introduced me to all the people round the table, and he explained that his passion was the sliding block puzzles. Martin has some amazing pictures of his collection online.

John arrived soon afterwards, with his pockets full to bursting with little wooden blocks in odd configurations, his passions are the cube puzzles and number theory.

The owner of Grand Illusions shop arrived next, his name is Tim and he travels the world in search of interesting gadgets. This evening he had brought along

  • a yo-yo in the shape of a cone
  • a device that gives you the impression your eyes are over 10 inches apart
  • a smooth mirror, which when a light is shone upon it, reflects a picture onto the wall

Robert is the resident genius, he is a wonderful 81 year old chap who hasn't missed a single one of these events.

David Wells was there, author of some of my favourite books, I showed him a wonderful little thing on knot multiplication

Simon who is the resident Go expert talked to me about the London Open and a possible get together for kids who liked the game. When pressed, Simon recommended a book called In the Beginning which will have to be sought out.

I sat for most of the evening scratching my head over various interlocking 3-d puzzles that were thrust into my hand, I think I solved about 2/3 of them, but I wouldn't want to be in a competition against any of these chaps.

When time was finally called, I was accompanied back to the station by Frank, who explained to me that his passion was impossible objects. One of his favourites is the corkscrew opener (with cork) inside a bottle, as these objects go naturally together.

Suprisingly though, it isn't the puzzles themselves that seem to light up this room, it is the interest they all have in other people, how they solve the puzzles, what alternative solutions they might give, and any new ideas.

Thanks to Ray for organising this event, it was great fun, I recommend it highly to anyone who enjoys Recreational Mathematics and Puzzles.




Lightning Groovy

2007-02-01T09:46:15+0000

center>



Groovy 1.0 released!

2007-01-03T06:34:16+0000

Groovy 1.0 has finally been released. It has been a long road, lasting over three years, but at last I can recommend Groovy as a stable, production proven and well documented programming language for the Java platform. (not to mention a very helpful and large user community) This release coincides with the launch of the Manning book Groovy in Action, which gives an in depth reference to Groovy 1.0 [Full Disclosure: I'm a core committer for Groovy and I was a technical reviewer for this book] Groovy 1.0 Highlights: A formal syntax based closely on Java 1.5, with added Groovy bits. Groovy can easily run source from the command line, ant, embedded in code    (simply place groovy-all-1.0.jar in your classpath) Close ties with Spring, Lucene and other real world Java products. Fantastic for reducing the verbosity of common tasks in Java quick start: example installation to /usr/local $ cd /usr/local $ wget http://dist.codehaus.org/groovy/distributions/groovy-1.0.tar.gz $ tar xvfz groovy-1.0.tar.gz $ export GROOVY_HOME=/usr/local/groovy-1.0 $ export PATH=${GROOVY_HOME}/bin:$PATH $ groovy -e "println 'hello world'" To coincide with this release, I have also released version 0.0.2 of the JVM command line interpreter Grash. I'll be giving a Talk about the Groovy Compiler on 25 Jan 2007 in London, please come along to that, and the pub afterwards, to discuss all things Groovy. I will be at the Groovy Developers Conference in Paris (starts 29 Jan 2007) to discuss the future direction of Groovy, in particular enhanced IDE support. In May 2007 there will be a three day Groovy and Grails conference at the Barbican, which will be perfect for anyone interested in this language to meet the core developers, and discover the cutting edge progress in Groovy. But most of all, Groovy 1.0 would not be where it is today without the work of the open source community. I'd like to thank each person for their work in making Groovy a fantastic language: Committers: Guillaume Laforge (glaforge), Jochen Theodorou (blackdrag), Jeremy Rayner (jez), John Wilson (tug), Russel Winder (russel), James Strachan (jstrachan), Dierk Koenig (dierk), Christian Stein (cstein), Paul King (paulk), Joe Walnes (joe), Chris Stevenson (skizz), Jamie McCrindle (jamiemc), Matt Foemmel (mattf), Sam Pullara (spullara), Kasper Nielsen (kasper), Travis Kay (travis), Zohar Melamed (zohar), Bob McWhirter (bob), Chris Poirier (cpoirier), Christiaan ten Klooster (ckl), Steve Goetze (goetze), Bing Ran (bran), John Stump (jstump), Pilho Kim (phk), Mark Chu-Carroll (markcc), Alan Green (alang), Edward Povazan (emp), Franck Rasolo (fraz), John Rose (jrose), Graeme Rocher (graeme), Guillaume Alleon (galleon), Antti Karanta (akaranta), Dave Kerber (davekerber), Hein Meling (hmeling), Joachim Baumann (jbaumann), James E. Ervin (jervin), Scott Hickey (jshickey), Martin C. Martin (mcspanky), Marc Guillemot (mguillem), Aslak Hellesoy (rinkrank), Steven Devijver (sdevijver), Scott Stirling (sstirling), Yuri Schimke (yuri) Contributors: Joern Eyrich, Robert Kuzelj, Rod Cope, James Birchfield, Robert Fuller, Sergey Udovenko Hallvard Traetteberg, Peter Reilly, Brian McCallister Richard Monson-Haefel, Brian Larson, Artur Biesiadowski Ivan Z. Ganza, Arjun Nayyar, Mark Turansky, Jean-Louis Berliet, Graham Miller, Marc Palmer, Tugdual Grall, and many many many other contributors and organisations. Thankyou All (and apologies if I missed anyone, so many people...) :-) P.S. an improved java2groovy is now in the core distribution of groovy 1.0 :-)[...]



java2groovy

2006-12-29T19:23:24+0000

Having just finished the first full run through of a groovy pretty printer, I thought I'd flex it's muscles by creating a useful command line program...
 java2groovy [file ...]

Description:
    The java2groovy tool reads class and interface definitions, written in the
    Java programming language, and converts them into groovy source files.
to do this...
  • I took the original java.g grammar which groovy.g is based upon
  • amended it to remove Java features not implemented in groovy.g ("do" keyword, Array Initialisers etc)
  • Created a Java2GroovyMain which takes Java files and parses into a Java like source AST
  • Converted the Java like source AST into a one for one Groovy equivalant
  • Applied a Groovifier, which applies common simplification tasks to the AST (e.g. don't need public keyword if you have other modifiers)
  • Then the resultant groovy AST is output using the "pretty printer"
(not in subversion yet RC3? post 1.0?)

So... job done, what's next :-)

Seriously though...

  • java.g needs to be amended some more to use create() instead of #[], otherwise line/col nums are lost
  • Groovifier.java is an interesting step, lots of tiny refactorings, at the source AST level, very powerful...
    //----
    // (e.g. don't need public keyword if you have other modifiers)
    //
    if (t.getType() == MODIFIERS) {
       GroovySourceAST publicNode = t.childOfType(LITERAL_public);
           if (t.getNumberOfChildren() > 1 & publicNode != null) {
           // has more than one modifier, and one of them is public
               // delete 'public' node
               publicNode.setType(EXPR);
    }
    //----
    
  • some minor changes to things like string literals (get a double double-quote each time at mo...)
  • all pretty printer issues apply (no comments on AST etc)
java2groovy is now included in Groovy 1.0 (download here)
(very very beta) NO DOCS, NO WARRANTIES etc etc

Oh yes... a sample...

$ java2groovy src/test/groovy/lang/MockWriter.java

/*
 Automatically Converted from Java Source

 by java2groovy v0.0.1   Copyright Jeremy Rayner 2007

 !! NOT FIT FOR ANY PURPOSE !!
 'java2groovy' cannot be used to convert one working program into another
*/

package groovy.lang
class MockWriter

   {

   private String output

   String getOutput() {
       String answer = output
       output = null
       return answer
   }


   void setOutput(String
        output) {
   }


   void println() {
       setOutput(""println()"")
   }


   void println(Object
        object) {
       setOutput(""println("" + object + "")"")
   }


   void print(Object
        object) {
       setOutput(""print("" + object + "")"")
   }
}






Useful Java Stuff

2006-07-06T10:24:31+0100

Useful stuff



Second Groovy Conference

2005-11-28T09:03:58+0000

Starting out on a chilly November morning, with just a Burger King breakfast for company, I found myself checking in for the Eurostar to Paris. I boarded the train, and found I had two hours of my own time (a rare thing these days) and therefore decided to bring some of my projects up to speed with the latest Groovy release (JSR-04) First off was my pet wiki server called biscuit, which was a simple affair needing changes only to variables not initialized with a type or the 'def' keyword. As I finish this task before arriving at the channel tunnel I decided to sink my teeth into a meatier topic, and look into providing tab completion for my Groovy shell called grash. The excellent jline library hooks for completion, so I quickly hook this up to the 'ls' function in grash and feel great as I navigate my object tree using the same nifty functionality I know in my favourite unix shells. I then started bringing grash up to the latest Groovy release, but after the initial 'def' updates, I quickly realise that something else is afoot. It appears that providing user defined commands and attaching them to objects has broken. A quick debugging session shows that for some reason the GroovyClassLoader is being told to load two versions of the reflector for the same script. At this point I get a phone call from James Strachan, it appears that he caught the train by the skin of his teeth, and after fighting his way down the carriages we meetup, just as we pull into Paris. As we stand in the queue for the taxis, James and myself discuss the xbean project and how to best integrate Groovy closures into Springs template callback mechanisms. In order to prevent writing wrapper classes over the top of every spring template, James suggests adding functionality to groovy to allow single method interfaces to be automatically implemented by Closures, in much the same way as Listeners are implementable by Closures today. As James pulls out his laptop and starts showing me where these hooks would reside, I can tell that this is going to be a good JSR meeting, and one which would justify using two days of my own holiday and the excessive eurostar fares which I paid for. We arrive, after a hairy taxi ride around the 'Arc de Triumphe' at the Sun offices in Paris. Guillaume excitedly takes us up to the 'Jupiter' room on the third floor, where I finally get to meet blackdrag, our debugger extraordinaire, and Dierk who has been writing Groovy in Action. We are delighted to find that Sun have provided an internet connection, and Guillaume has already uploaded photos to flickr for the watching world to see. Having missed the morning session due to our travel, we are quickly brought up to speed. Finally we will get to talk about name resolution and scoping. The topic for the first day appears to be name resolution, with most of the discussion centring around how best to cope with vanilla names. After a lunch paid for, very kindly, by Dierk, the discussion soon turns into a heated debate over the treatment of vanilla names. class MyScript { String toString(){ return "foo" } void run() { myList.each{ // does this call MyScript.toString() or myList.toString() ? println(toString()) } } I believe that... Tug argues the enclosing object instance should listen for and consume names prior to the lexical scope. (i.e. above example would call myList.toString()) James argues that the default should be lexically bound to the current context (i.e. above example would call myScript.toString()), and if the object instance was needed to be referred to that some form of syntax could be constructed to allow this, e.g. $toString() would be a dynamic name that could be interpreted differently. At least, with my laptop pointing at the wiki, and up on the projector, I ensure that the examples and minutes are bei[...]



Nonograms

2005-09-14T13:09:27+0100

The object of the puzzle is to figure out which of the squares should be coloured in to make up a picture, which is the solution to the puzzle.
(image)
  here is a more difficult one
Rules:
  • Numbers by each row or column form a 'clue'
  • Each clue tells you how many solid blocks there are on that column or row, how big they are, and in what order they appear
  • There must be at least one gap between two blocks
For example: A clue of "3,1" tells you there is a block of 3 consecutive solid squares on this row, and to the right of it is a single block of 1 solid square.
[more info]
Nonograms (a.k.a. Griddlers) in their current form, have a history going back about 20 years.

The theory behind these puzzles can get quite involved, and provides an interesting exercise in programming. Steven Simpson has provided some interesting nonogram solvers

There are also some interesting variants on this puzzle too.

More nonograms to play with are here, here and here.

update: Here is a nice tutorial on how to solve these puzzles.


Comments (0) - Read and Add your own Comments