Monday, November 19, 2012

Monads, shmonads and functional programming

Post consolidated and moved to

Saturday, September 29, 2012

OMG, scala is a complex language!

Blog post consolidated to

Quick scala – step 1: setup

This was originally posted in Oct 2011, on the which I'm removing.

If you just want to play with scala quickly – you can use one of the few online interpreters, like - these let you run small bits of code interactively. Otherwise, continue reading, to complete a local setup for scala development. You need these:
2.Scala (command line)
3.Eclipse with the scala plugin
Installing Java:
1.Download and install a 1.6 JDK from . Do not use a 1.7 for this exercise and make sure you install the JDK not just the JRE. The exact link I use is:
a.I recommend you use a 64 bit version, so you can allocate more memory to it
2.Run and install somewhere, let’s say C:\bin\jdk1.6.0_27\
a.I found it a good practice to keep my development tools in c:/bin
b.Make sure to check the “change destination folder” checkbox before letting the installer run…
3.Make sure the path to java.exe is in the PATH
a.Add C:\bin\jdk1.6.0_27\bin to the PATH system variable
b.Define a variable called JAVA_HOME with the value “C:\bin\jdk1.6.0_27\”.
4.Test it by opening a command line window and typing “java”.
Installing scala command line:
1.Download a distribution from
2.Unpack it in a folder, let’s say C:/bin/scala
3.Make sure the path to scala.bat is in your PATH
a.Add C:/bin/scala/bin to the PATH system variable
4.Test it by opening a command line window and typing “scala”. You should get the scala interpreter prompt and then type“exit” to exit the interpreter.
Installing Eclipse:
1.Download Eclipse Classic from the download site:
2.Install it (unzip it) in C:/bin/eclipsescala
3.To make sure it uses the JDK you just installed (if you went that route) modify your eclipsescala/eclipse.ini and add this line:
4.Start it up (eclipsescala/bin/eclipse.exe)
5.Install the scala plugin
a.Go to Help/Install new software
b.Click on Add
c.Type in name “scala291” and the url:
d.You can see if there is a newer version at
e.Select this source in the drop-down
f.Click “Select All” to select the three features
g.Go ahead with the installation
6.Restart Eclipse
7.Read the detailed setups at is a good idea to allocate Eclipse at least 1G – I use 2G.
8.If you changed any settings, restart Eclipse
To test your eclipse installation, select File/New/Project and see if “Scala Project” is in the list. You’ll use it for the “Hello World”exercise.
Check that the sources for the scala library are setup properly:
1.Open your project
2.CTRL+SHIFT+T to find types and type ‘List’
3.Scroll down the list to find the List from scala.collection.immutable
4.Click enter – you should now see the nicely formatted source code for List
5.You can take a quick look but don’t despair if that code looks foreign – we’ll get there soon enough.
Spruce up your Eclipse – my favorite plugins include:
-The GOTO plugin from,
-The Color themes plugin, from
-The VI plugin, from
Cheers – you are now setup to play with scala.

Friday, August 24, 2012

Racer kidz and wiki clubs - update

My little R&D into wiki domains at seems to work fine - I add a feature evry now and then.

You can register a club, describe a racing schedule, then racers can add it to their profile and automatically, via the magic of wiki xpath, see the racing calendar and the map...

You can give it a try without an account from the home page.

I also experimentally used it to create simple blogs, like this enduro school. A blog has posts and that's that, see its domain definition.


Sunday, March 28, 2010

Killing an annoying warning

The most annoying warning ever has been haunting me for a while.

[javac] /home/razvanc/workspace7u6/razxml/src/razie/base/data/ warning: is Sun proprietary API and may be removed in a future release

I refuse to include and move around large unnecessary libraries to deal with XML and XPATH just because Sun considers themselves the center of the universe and their internal libraries somehow more important then mine. In short, they figured there should be no way to remove this warning, although, in this case, they copied code from apache into their own libraries.

Well, the solution is rather simple. Most likely everyone has specific XML wrappers. Just put them in their own project, disable the java/scala builders. Then, build it manually, create a jar file and check it in.

Then, in all the other projects, use this jar directly. Since the jar is already compiled, the annoying warning is no more.

See for instance my xml utilities, at

What's more, I don't actually use the XML stuff directly. I wrapped it all in pretty much one single class, using XPATH for access. It's simple, fast enough and makes for very simple code:

"/config/storage/host[@name='" + + "']/media/@localdir"

For all xml data access, you should limit yourself to the xpe/xpl/xpa methods described in an earlier post ( So, use something like this instead:


Saturday, March 13, 2010

The Option monad pattern thing

This informative post is consolidated in the new blog, at:

... where we take a closer look at the Option type of Scala, the monadic aspect of it and see how we can use it to inspire new patterns and new ways of looking at the code we write.

(Sorry - original content was removed from here, to avoid duplicates).

Monday, March 1, 2010

Scripster - interactive scala REPL using telnet, http etc

As mentioned before, I think that all apps must alllow scripted/programatic access to their objects.

I created a simple interactive gate to acces the scala REPL in any scala process. It only uses one port and supports telnet, http and swing:

The graphics are based on my 20widgets project, with the addition of a ScriptPad widget.

Content assist is only available in the telnet version (sic!). I will work to find some nice syntax-colored controls for the web version. Switch to character mode ("mode character" on ubuntu or default on windows) and use TAB to see a list of options. Right now it's a demo only, I need to find the parser's APIs to get the real content assist options ;)

You can download the single scripster-dist.jar file from my razpub project download, at and run the example with this command line (replace /host/bin/scala with your $SCALA_HOME) :

java -classpath ./scripster-dist.jar:/host/bin/scala/lib/scala-library.jar:/host/bin/scala/lib/scala-compiler.jar:/host/bin/scala/lib/scala-swing.jar razie.scripster.JScalapSwing

To use it in your process, put these jars in your classpath and use this:
where 4445 is the port you want to use, see the razie.scripster.MainScripster for an example. To enable the swing version, use the swing jars as well and see the razie.scripster.MainSwingScripster class for an example.

For further tweaking, look at the code yourself, at

If you want to keep in touch with the evolution of scripster or my other related endeavours, subscribe to the RSS feed or twitter/razie.

Scripster's main page, kept up-to-date, is at There's also an online live demo at