| Andrew Cooke | Contents | Latest | RSS | Twitter | Previous | Next


Welcome to my blog, which was once a mailing list of the same name and is still generated by mail. Please reply via the "comment" links.

Always interested in offers/projects/new ideas. Eclectic experience in fields like: numerical computing; Python web; Java enterprise; functional languages; GPGPU; SQL databases; etc. Based in Santiago, Chile; telecommute worldwide. CV; email.

Personal Projects

Lepl parser for Python.

Colorless Green.

Photography around Santiago.

SVG experiment.

Professional Portfolio

Calibration of seismometers.

Data access via web services.

Cache rewrite.

Extending OpenSSH.

C-ORM: docs, API.

Last 100 entries

Consciousness From Max Entropy; Democrats; Harvard Will Fix Black Poverty; Modelling Bicycle Wheels; Amusing Polling Outlier; If Labour keeps telling working class people...; Populism and Choice; Books on Defeat; Enrique Ferrari - Argentine Author; Transcript of German Scientists on Learning of Hiroshima; Calvert Journal; Telephone System Quotes for Cat Soft LLC; Owen Jones on Twitter; Telephone System Quotes for Cat Soft LLC; Possible Japanese Authors; Complex American Literature; Chutney v5; Weird Componentized Virus; Interesting Argentinian Author - Antonio Di Benedetto; Useful Thread on MetaPhysics; RAND on fighting online anarchy (2001); Now Is Cat Soft LLC's Chance To Save Up To 32% On Mail; NSA Hacked; Call Center Services for Cat Soft LLC; Very Good LRB Article on Brexit; Nussbaum on Anger; Credit Card Processing for Cat Soft LLC; Discover new movies on demand in our online cinema; Tasting; Credit Card Processing for Cat Soft LLC; Apple + Kiwi Jam; Hit Me; Increase Efficiency with GPS Vehicle Tracking for Cat Soft LLC; Sudoku - CSP + Chaos; Recycling Electronics In Santiago; Vector Displays in OpenGL; Call Center Services for Cat Soft LLC; And Anti-Aliased; OpenGL - Render via Intermediate Texture; And Garmin Connect; Using Garmin Forerunner 230 With Linux; Payroll Service Quotes for Cat Soft LLC; (Beating Dead Horse) StackOverflow; Current State of Justice in China; Now Is Cat Soft LLC's Chance To Save Up To 32% On Mail; Axiom of Determinacy; Ewww; Fee Chaos Book; Course on Differential Geometry; Increase Efficiency with GPS Vehicle Tracking for Cat Soft LLC; Okay, but...; Sparse Matrices, Deep Learning; Sounds Bad; Applebaum Rape; Tomato Chutney v4; Have to add...; Culturally Liberal and Nothing More; Weird Finite / Infinite Result; Your diamond is a beaten up mess; Maths Books; Good Bike Route from Providencia / Las Condes to Panul\; Iain Pears (Author of Complex Plots); Plum Jam; Excellent; More Recently; For a moment I forgot StackOverflow sucked; A Few Weeks On...; Chilean Book Recommendations; How To Write Shared Libraries; Jenny Erpenbeck (Author); Dijkstra, Coins, Tables; Python libraries error on OpenSuse; Deserving Trump; And Smugness; McCloskey Economics Trilogy; cmocka - Mocks for C; Concept Creep (Americans); Futhark - OpenCL Language; Moved / Gone; Fan and USB issues; Burgers in Santiago; The Origin of Icosahedral Symmetry in Viruses; autoenum on PyPI; Jars Explains; Tomato Chutney v3; REST; US Elections and Gender: 24 Point Swing; PPPoE on OpenSuse Leap 42.1; SuperMicro X10SDV-TLN4F/F with Opensuse Leap 42.1; Big Data AI Could Be Very Bad Indeed....; Cornering; Postcapitalism (Paul Mason); Black Science Fiction; Git is not a CDN; Mining of Massive Data Sets; Rachel Kaadzi Ghansah; How great republics meet their end; Raspberry, Strawberry and Banana Jam; Interesting Dead Areas of Math; Later Taste; For Sale

© 2006-2015 Andrew Cooke (site) / post authors (content).

Starting a Scala Project

From: andrew cooke <andrew@...>

Date: Sun, 27 Sep 2009 15:35:39 -0400

I just decided to do a quick + dirty project - I want to run through
my mp3s, read the tags, store everything in a database, and then pull
tags from the last.fm API so that I can automatically construct
playlists of related music.

I also decided the time has come to learn Scala.  I could do this
easily in Python, but I've been postponing Scala for too long.

I looked at Scala yesterday and downloaded the port of processing,
which used sbt (Simple Build Tool).  I was thinking about looking at
ant+ivy (something else I need to learn), but I *think* sbt uses ivy
under the hood (or uses Maven, or all share the same basic
infrastructure).  So for now I am going with sbt.
http://code.google.com/p/simple-build-tool/ (which I had installed

So, first step was to create a new directory and run sbt.  It asked if
I wanted to create a new project and I said yes, and gave it a name.
Now it seems to be downloading stuff.

OK, so that left me with some basic directories:

spu63 uykfd: ls
lib  project  src  target

OK, now how do I make that work with Eclipse?  No idea.
suggests using IvyDE (note - I have already installed the Scala plugin
in Eclipse).  So I install this via

reload + deliver-local in sbt (following instructions at
IntegrationSupport link above).

I still don't get this.  I think I need to create the Scala project
first in Eclipse, so move the directories generated with sbt above out
of the way, create the Scala project from within Eclipse, and then
move the sub-directories back.

But Eclipse is using Scala 2.7.6 and sbt is using 2.7.5

So delete those and in the project directory created by Eclipse run
sbt again, giving the correct Scala version.

That gives an error "unknown resolver sbt-chain" which I am going to
ignore, and otherwise seems to have worked.

F5 to refresh Eclipse and we seem to be cool.

Run reload and deliver-local again in sbt.  F5 again in Eclipse and
add library as described in link above.  Looks good.

Next I create a HelloWorld class in the main.scala package, based on
http://www.scala-lang.org/node/166 but when I try to run it in Eclipse
it is treated as "HelloWorl" (no final "d") and so fails!

If I fix that in the run configurations I then get
Exception in thread "main" java.lang.NoSuchMethodError: main
which sucks somewhat.

This is not looking good.

Running via sbt gives something similar.  Does the "main" have to have
a special name?

I checked with the example and had "class" rather than "object";
fixing that doesn't seem to change anything in Eclipse, but now sbt

> run main.scala.HelloWorld
[info] == copy-resources ==
[info] == copy-resources ==
[info] == compile ==
[info]   Source analysis: 1 new/modified, 0 indirectly invalidated, 0 removed.
[info] Compiling main sources...
[info] Compilation successful.
[info]   Post-analysis: 2 classes.
[info] == compile ==
[info] == run ==
[info] Running main.scala.HelloWorld ...
hello world
[info] == run ==
[success] Successful.
[info] Total time: 2 s

Trying with the syntax at http://www.scala-lang.org/node/94 also works
with sbt, but not with Eclipse.

Looking at the comments for Application (via Eclipse F3) it seems it's
not recommended.  So revert to earlier syntax:

package main.scala

object HelloWorld {
  def main(args: Array[String]) {
    println("hello world")

Which seems identical to the example.


Scala Bug Report

From: andrew cooke <andrew@...>

Date: Sun, 27 Sep 2009 16:01:55 -0400



Trying Again (New Instructions)

From: andrew cooke <andrew@...>

Date: Sun, 27 Sep 2009 18:35:59 -0400

OK, as you can see via the bug report, it's not clear what went wrong,
but the following appears to work:

- First, install all software (sbt, Eclipse plugins for Scala and Ivy)
- Next, start Eclipse with a new workspace
- Create the project from inside Eclipse using the "new Scala project" wizard
- In the project directory, run sbt and create a new project with a
matching name (so that you end up with the "src" directory Eclipse
created matching the "src" directory sbt would also create)
- F5 in Eclipse to pick up new files
- At this point I created a HelloWorld object in main.scala, which
worked just fine
- run main.scala.HelloWorld in sbt also runs the hello world
- inside sbt, "reload" and "deliver-local" to generate the ivy file
- F5 again in Eclipse, then projects settings, Java build path,
libraries, and add the Ivy file (in the target directory)

The above creates a project that works both in Eclipse and sbt.

To add a dependency you need to open the ivy xml file using the
dedicated editor.  For example, right click on the ivy xml file in the
build part of the project explorer (NOT the file in target) and select

The edit the dependency (the values seem to be as for Maven).  So, for
example, to include Empire DB -
http://incubator.apache.org/empire-db/downloads/latest.htm - I added:
  <dependency org="org.apache.empire-db" name="empire-db"
and when I saved the file, it went off and downloaded that and a pile
of supporting libraries (not very quickly - I am in S America and the
net is not that fast, so perhaps that's the reason - but it did work).


Scala in More Detail

From: andrew cooke <andrew@...>

Date: Sun, 27 Sep 2009 19:35:30 -0400

So now I'm at the point where I need to understand Scala more.  This
is a good overview of the main language features:
(as I read it, I realised that some examples assume familiarity with
ideas from functional programming, so it may not be for everyone).

There's also more specific details (scroll down to the "table of
contents") on individual features here -

One thing that has already puzzled me is the use of "object", which is
illuminated by the first link: "In fact, every Java class is seen in
Scala as two entities, a class containing all dynamic members and a
singleton object, containing all static members."

There's a nice clear separation between Value and Reference types
(which in Python would help clarify things for newbies and in Java
helps unify equality).  And explicit Nothing and Null (reference)

Oh and operators are methods (and vice versa!) with fixed precedence
(right associative if they end in a colon, which just happens to give
a sweet syntax for list consing!).  Parameterless methods are
possible.  And "override" is a modifier, not an annotation (ie it's

Whoa.  Pass by name exists (lazy evaluation).  The syntax is a little
odd (a "=>" precedes the type).  Ah, because it's a think that "goes
to" a value, I guess.  Evaluated each time they are used (implemented
as parameterless function).

Mixins!  called traits.

I need to go cook dinner, but this is awesome :o)


More on Scala

From: andrew cooke <andrew@...>

Date: Sun, 27 Sep 2009 21:06:34 -0400

Continuing with notes from

Anonymous (using => again), curried and generally first class
functions.  And closures.  And partial evaluation:
  forall(row, 0 ==)
page 6

Functions implemented via generic FunctionN classes.

Wow - arrays are treated as functions over integers (special handling
of assignment to functions via "update").

Sequences and list comprehensions.

Good discussion of co + contra variance.  Helps clarify some problems
I have had with generic types in Java.

Surprisingly, "new" still seems to exist.  I thought it was
unnecessary, so why keep it?

Enough type discussion to make my head explode.

Aha.  Traits must have empty constructor arguments.  That's a very
nice way to keep mixins clean.

The "case" modifier gives you constructor-like matching.

Native XML support including queries.

Hmmm.  Seem to have stalled at views.  Try again tomorrow.


Revised Instructions for Adding Dependencies

From: andrew cooke <andrew@...>

Date: Mon, 28 Sep 2009 09:09:43 -0400

The notes above on adding dependencies are incorrect.  The problem is
that the ivy file is generated by sbt.  So extending it is not
permanent.  It exists only as a mechanism to communicate from sbt to
Eclipse.  The actual configuration of dependencies is done in sbt.

It turns out that sbt is configured by writing a scala class:

- Under the project directory add a "build" directory
- In the build directory create a class named after your project (in
my case uykfd):

import sbt._

class uykfdProject(info: ProjectInfo) extends DefaultProject(info)
  lazy val hi = task { println("Hello World"); None }
  val empire_db = "org.apache.empire-db" % "empire-db" % "2.0.5-incubating"

- The "hi" above defines an action, so inside sbt you can type "hi"
and it will print "Hello World" (pointless, but a good test that
things are working)
- The "empire_db" defines a dependency.  The name of the value doesn't
matter and the various strings are as above (ie as Maven).
- If sbt is still running you need to "reload" to pick this up
- You then MUST do "update" to download
- After that "compile" should work.  For example, I altered my test class to be:

package main.scala

import org.apache.empire.db.DBDatabase

object HelloWorld extends Application {
    object db extends DBDatabase {

- To get this working in Eclipse you then use the ivy xml file, so
"deliver-local" and then click around in Eclipse to get the ivy.xml
file to be added to the build path
- It's not at all clear, but you can also delete the ivy build path
thing via the Eclipse build path dialog (under libraries).
- Once that is done, the libraries downloaded by sbt/ivy appear in the
Eclipse project too.


Switched to Emacs

From: andrew cooke <andrew@...>

Date: Tue, 6 Oct 2009 09:02:43 -0400

This page is getting a few hits, so I should add that I have given up
on Eclipse and switched to emacs (for Scala - I still use Eclipse for
Python and Java). So much was broken that emacs does the same and uses
much less memory on my laptop.

To set up emacs follow the instructions at http://scala.sygneca.com/tools/emacs

Despite that having an sbt window, I use sbt in a separate console
(the emacs window shows some strange control characaters and I need to
exit sbt regularly to kill the in-memory database I am using).

In short, Scala tooling is not that great, still.  The language itself
appears to be fine, however.


Comment on this post