Thursday, December 30, 2010

Writing HUDs in Open Wonderland

One of the best things about the holidays is that you can spend more time than usual in what you really like. For the last couple of days I've been messing up a bit with the Gestures HUD in Wonderland, and it's given me the chance to deepen a bit on the whole HUD mechanism.

Although there is already a fantastic tutorial on HUDs in the main Wonderland documentation, I found it a bit complex at first, mainly because the HUD created in that tutorial is a big and complex one (a top map camera component ). For that reason, I decided to write a very basic HUD tutorial that displays just a simple JButton on screen.

I thought it would be better to write it directly in the community wiki, so here you can find it.
The code for the tutorial lives in my github account: sample hud tutorial.

Hope you guys enjoy it, and I would appreciate some feedback!


PS: Best wishes for the new year!!!

Tuesday, November 30, 2010

Java Puzzlers at Strange Loop

Just came across the latest Java Puzzlers presentation by Josh Bloch and Bob Lee at strange loop earlier this year.  7 new puzzlers to make your brain hurt, and your jaw drop a little bit when you see the solutions and morals.

Spoiler alert! If you like puzzlers stop reading now!

This is my take on it:

Do not use raw types, the compiler will resolve to the best match for the type and cast automatically, and this can get you into trouble with overloaded methods.

Choosing the right types might not be enough; look for quirky differences among constructors for those types, such as BigDecimal(double) and BigDecimal(String).

Avoid using Varargs and arrays together, and prefer collections to arrays, especially in APIs.

Be careful with catastrophic backtracking when using regular expressions (not only in Java!).

I do not know enough about map.entrySet() and HashSets, so I got lost in that puzzle. I will have to watch it again. But in any case:
Iterating over entry set should be done with care.

When in doubt, use a larger type to avoid overflow problems.

Leading 0s transform the number in octal literals. Use with care!

And lastly, Do not ignore compiler warnings; they can get you out of trouble before you hit it at runtime!

Josh Bloch mentioned that findbugs catches 5 of the 7 pitfalls, so if you were thinking about giving it a go, this is a good reason to get you started!

about frogs and programmers

I am reading Gerald M. Weinberg's classic book Psychology of Computer Programming, which I am finding really interesting, and it also has some funny bits:

"Looking back, it seems that forcing programmers to work in isolation is like trying to study the swimming behaviour of frogs by cutting off their legs and putting those legs in the water to watch them swim. After all, everyone knows that the frog swims with its legs, so why complicate the experiments with all the rest of the frog?"


Sadly, in many senses, things don't seem to have changed much in the last 40 years.

Monday, November 29, 2010

concise and expressive

This is the kind of stuff that amazes me about Ruby:

line = "/pop/mente_al_sol.mp3 | 3:45 | El niƱo gusano | Pon tu mente al Sol"
filename, length, artist, album = line.split(/\|/))

Isn't that just plain nice!?

Example adapted from the Programming Ruby, the pragmatic programmers guide.

Tuesday, November 16, 2010

Ruby and Regular Expressions

I have decided for the nth time to learn Ruby, mainly because I've been playing with ruby on rails apps for years now, but I do not have the language essentials to go beyond the typical functionality covered in tutorials or project documentation.

So for starters, I am reading the pragmatic book on ruby 1.9 which by the way, is on offer for only $10 this week (don't know for how long, so hurry up!). The book is very readable and to the point, as most of the titles in the pragmatic bookshelf.

And although the language is definitely different for me, coming from a Java background, I got immediately hooked by one aspect of it which till now had been, to say the least, a bit scary to me; the use of regular expressions.

As a Java developer I had used regexp before, but in a very limited and focused way, which happened to be the creation of validation expressions for fields in GUIs. I am not implying that this is the only use case for regexps in Java, no no no, but personally, I had only used them in that context before.

It is nice to see how in Ruby they are such a used technique, and the book encourages you to use them from very early. As I said, I had been scared of regexp in the past. I had even bought a couple of books about them that I never got to read.

So today I went looking for some easy resources in the shape or short videos that I can watch during lunch, ant I came across this one, which happens to explain the subject quite well, and it's accompanied by a long-ish post and even a few more videos. All very interesting if you are into this kind of thing!

Sunday, November 7, 2010

breakable toys

A couple of weeks ago I watched this talk in which Corey Haines tells us all about the software craftsmanship movement.

Although I haven't heard about the movement before (where have I been for the last couple of years???!!!) some of the things he talked about there felt very familiar.
A bit more digging out took me to the Apprenticeship Patterns book. And there again, a lot of familiar concepts, and even real physical situations clicked with me straight away.

One of the patterns that I enjoyed a lot is breakable toys. I have been doing this kind of small projects for years now, although I never called them toys but prototypes or spikes. Also the level at which I was getting involved with these projects was different from the one in the pattern. In my case they used to be pretty much a couple of hours work to get some framework installed and getting a hello-world kind of project out of it. The pattern goes much deeper than that. One of the examples they use is to create a wiki, and although it might seem a bit over-engineered at the beginning, they assure that it cat teach you about "HTTP, REST, parsing, web design, caching, full-text search, databases, and concurrency". That sounds a lot cooler than my 2 hours testing framework approach to toys.

I have also enjoyed the interconnection among patterns, and how some of them can lead to others. It is a great read and although the book is available online, I had to buy a copy. And of course, recommend it here; you should certainly go and buy it now!

Friday, October 8, 2010

Documentation about the git session

The git session held on October the 8th is being documented in the community wiki at this location.

The session focused on how to use git and github to collaborate in the development of open wonderland modules (or any other project that you fancy!).

Please feel free to add to the page if you want. The more info, the better!

Thursday, October 7, 2010

Introduction to Git for version control

Hi everybody!
We are organising a session on Git to keep track of your source code. The meeting will be in-world, in the Open Wonderland Community Server and we are still trying to finalise the times.

Possible dates are being tracked down here. Write your name down if you want to participate.

The session will be very simple, all from scratch, and will focus on how to use Git and github.

Hope to see you there!

UPDATE: The session happened on the 8th of October but it will be repeated soon, so get in touch if you want to participate!

Saturday, July 3, 2010

Cloning the Open Wonderland subversion repository

The question about cloning the wonderland repo was raised at a recent development meeting.
The main reason to clone is that you might not have permissions as a commiter to the main repo, but you still want to be able to commit your changes locally, whether or not they will eventually be propagated to the main repo.

I decided to give a go at using Git instead of Subversion. I have been using Git for a while now, and although it can be very tricky at the beginning, it is a great system.
I am not going to go into the differences between the systems, cause a simple google search will provide a lot more information that I could ever compile on here.

So let's cut to the chase and see what I got so far, and what problems I'm having:
First thing to do is a google search! These are a couple of interesting links that I've found, and the process I followed in here was taken from those links:

[2]: Automating the authors file.

Git manages authors in a different way to svn, so one of the steps needed for the migration is a text file with the authors' names and email addresses. Although in the first link they create this file manually, there is a script in the second link to automate its creation.

From [2]:

Create author mapping file

Create a svn.authors file, which maps the svn author names to git author names:

#!/bin/bash
authors=$(svn log -q | grep -e '^r' | awk 'BEGIN { FS = "|" } ; { print $2 }' | sort | uniq)
for author in ${authors}; do
echo "${author} = ${author} <${author}@dev.java.net>" >> svn.authors ;
done

I will not go into many details here because both links are very clear. What I did to clone, step by step, was:

1. run the authors script and modify the output if you have real information about the authors. To run the script as it stands, you will need a local svn copy of the original repo.

2. cd to the location where you want to have your git repo.

3. create a temporary location for the code: mkdir wonderland_temp

4. cd wonderland_temp

5. git svn init http://openwonderland.googlecode.com/svn/trunk --no-metadata

6. git config svn.authorsfile /location/to/your/svn.authors

7. git svn fetch (This step is going to take a good couple of hours!)

The last step will get rid of all the superfluous svn information and leave a clean git repo. The problem here is that it also gets rid of a bunch of empty directories that are needed to compile, so if you do 8, you will have to recreate those folders.
8. git clone wonderland _temp wonderland

Some Problems:
A weird thing happens when I try to compile wonderland core and wonderland-modules exists at the same level. For some reason the build tries to compile the audio-recorder module from the modules directory, and this fails when it tries to hit the ContentRepository class.
The failure in itself makes sense, or so I think, because it is trying to compile a module that depends on part of the core, when the core has not finished compiling. What puzzles me is that the core build triggers compilation in the modules tree??? this is very strange. Stranger is that if I get rid of the wonderland-modules directory, the build runs like a charm!

It might be me, or something in my system, but I guess the only way to know is to track down the build scripts, which I intend to do as soon as I have time for it.

Other than that, when I run the new server, I run out of memory, which does not happen in the svn tree. I will need to track this down too.



These instructions will provide you with a local copy of the repo that you can use for personal purposes. If you want to share this 'main' copy with other people, say at your company, you will have to check how to publish a git repo; some ideas here:

Have fun!


[UPDATE]: Just tried the process under Windows 7 + Cygwin and all goes really smooth. Server compiles and no out of memory errors (the ones noted above were on MacOS X).

[UPDATE 2]: The compilation problems were only in my machine, and due to the fact that the empty directories were not present. The main build checks for the wonderland-modules project, and in case of existing, it builds it too.

Sunday, May 2, 2010

Launching the Open Wonderland server through screen

Hello there! This is a short screencast about how to launch the wonderland server in a remote machine, and being able to detach the launch so that you can safely close the terminal session without halting the execution of the server. At a later stage, you can connect back to your server and retrieve your process again. Handy!


There is also a transcript in the wonderland community wiki. Enjoy!

Saturday, March 20, 2010

Open Wonderland, Marbleous module

This is me playing about with the physics simulation marbleous for open wonderland.



An extract from the description: "Marbleous simulates a ball rolling down a track. You can reconfigure the track and also play back the animation using a timeline slider to inspect the values for velocity, acceleration, potential and kinetic energy at any moment in time".

It took a couple of attempts to get it right but it is so much fun, you should give it a go!