C# vs. Clojure vs. Ruby & Scala

Short preface: at a job interview, Zach Cox was told to aggregate words and word counts from a bunch of files into two files, sorted alphabetically and by word count respectively, which he did in Ruby and Scala. This led Lau Bjørn Jensen to do the same thing in Clojure, which apparantly sparked other people to do it in Java, Python etc.

Inspired by the afore mentioned problem, and an extended train ride home (thank you, Danish National Railways!!), I decided to see what a C# (v. 3) version could look like:

Weighing in at 36 lines and executing in 10.2 seconds (on my Intel Core 2 laptop with 4 GB RAM), I think this is a pretty clear and performant alternative to the other languages mentioned.

Task and issue tracking with Redmine on a Windows server

If you are in need of nifty and free task and issue tracking system, you could check out Redmine! It’s really cool, and it is easy to install (especially if your Windows box already has a Ruby development environment installed).

This post will show how Redmine can be installed as a Windows service on your Windows server. You will need to go through the following steps if you have a clean Windows machine, and you have not yet fiddled with Ruby on it:

  1. Install MySql
  2. Create a Redmine database + user
  3. Install Ruby 1.8.6
  4. Include the Ruby bin directory in your PATH environment variable
  5. Install Rubygems
  6. Install Rails
  7. Install Mongrel
  8. Install Mongrel Service
  9. Check out Redmine’s source code
  10. Configure Redmine
  11. Create the database schema
  12. Start Mongrel and verify that the installation works
  13. Install Mongrel/Redmine as a Windows Service
  14. Make the service run automatically when Windows boots

So… let’s do this!

1. Install MySql

Redmine needs a database. I use MySql for this. Go to http://dev.mysql.com/downloads/ and download and install the community server edition.

2. Create a Redmine database + user

Fire up a command prompt and enter (assuming that MySql is installed locally, running on the default port):

where USER might be root and PASSWORD is probably some secret cool password you made up during the installation of MySql.

Then, type

to create a new database for Redmine. Verify that it’s there by doing this:

Then, to create a new user for Redmine to use, and to grant full access to the database, do this:

3. Install Ruby 1.8.6

In Ruby land, 1.8.6 is still being used in many production environments around the world, even though Ruby 1.9 is well on its way. To install it, go to http://www.ruby-lang.org/en/downloads/ and choose the One-Click installer.

If you download the binaries instead, you will manually need to download a few missing dlls: zlib.dll, ssleay32.dll, iconv.dll and possibly more. Not too hard, but it’s definitely easier to use the One-Click installer.

4. Include the Ruby bin directory in your PATH environment variable

Not too hard – just do it! Mine says blablabla;c:\ruby-1.8.6\bin (not literally, though).

5. Install Rubygems

If you are unfamiliar with Ruby, I can inform you that Rubygems is the de facto standard package manager. Grab it from the downloads section of http://rubygems.org/, and put it somewhere on your computer. Then, open a command prompt in that directory and issue a

which will install gem.bat in your Ruby bin directory.

6. Install Rails

Redmine is built on the Rails frame work, so Rails must be installed for Redmine to work. Easy! Do it like this:

The -v 2.1.2 stuff is because my current version of Redmine required Rails 2.1.2. If your Redmine installation refuses to start up because it requires another version if Rails, it should be easy to install that version inspired by the command above.

7. Install Mongrel

Mongrel is a fast web server made in Ruby. Install it like this:

8. Install Mongrel Service

Mongrel Service is a Win32-specific thing, that allows Mongrel to be started via a Windows Service. Install it like this:

UPDATE April 4th 2010: When re-installing Redmine on a Windows 7 server today, I got this cryptic error message:

I Googled for a while before I thought about what Rubygems was trying to accomplish… It seemed like it was trying to run make on my Windows box, which is usually pretty hard… so I tried adding the platform parameter like so:

– which worked 🙂 I have no idea why the platform parameter is suddenly required to install successfully on a Windows box.
</update>

9. Check out Redmine’s source code

Look for instructions on how to obtain Redmine here. I have checked out the trunk on my computer – that makes it very easy to upgrade Remine whenever I feel like it.

10. Configure Redmine

Rails apps are easily configured by editing the files contained within the config folder of the Rails application. To configure Redmine to use your database when started in production mode, copy the database.yml.example file and call it database.yml. Edit the production section and supply the database name and user credentials you created in your MySql database.

11. Create the database schema

Rails applications have built-in database migration scripts. You can issue a full up to the current version by going to Redmine’s base directory in the command prompt and issue a

12. Start Mongrel and verify that the installation works

Open a command prompt in your Redmine app’s base directory and issue a:

to start Redmine on port 4000 in the production configuration.

Now you should be able to navigate to http://localhost:4000 and see Redmine running.

13. Install Mongrel/Redmine as a Windows Service

Open a command prompt as administrator (right click the command prompt shortcut and select “Run as administrator”) and navigate to your Redmine app’s base directory and issue a:

14. Make the service run automatically when Windows boots

Go to the service manager in Windows ( services.msc) and double-click your service to change the startup type to “Automatic”.

Ruby Fools conference

ruby-fools-logo.jpg

I have just returned from a week’s worth of Ruby Fools 2008 which by some may also be known as “The Traveling Ruby Circus”. The conference was set to span the 1st and 2nd of April in Copenhagen and the 3rd and 4th of April in Oslo. It was kicked off early with a Hobo tutorial on the 31st of March.

The conference has been great! There’s no other way to describe it. I could go on and on about all the technical stuff I’ve seen, but instead I’ll just show some pictures – because the best thing about the conference has been the really really amazing atmosphere in both our venues (ITU, Copenhagen and Chateau Neuf, Oslo).

matz-talking.jpg

Here’s Matz himself talking about “Ruby – past, present, and future” as the opening keynote on the second day in Copenhagen.

Really great to watch this amazing personality talk about a programming language that is so dear to him. Half way through the talk he started telling about the new features of Ruby 1.9, and he got so carried away by the file and string encoding support that it took almost the rest of the talk to get back on track. You can really feel that this man cares about his language.

look-at-my-vm.jpg

Here’s Trifork‘s Kresten Krab Thorup on the first day in Oslo in a break, showing off some of his HotRuby* VM method invocation magic to Matz, Michael Fellinger (of Ramaze) and Evan Phoenix (of Rubinius).

Kresten’s HotRuby is an experimental Ruby VM with incredibly fast method invocations. Method invocations seems to be the weak point of this type of dynamic language, but apparently all sorts of tricks can be applied to make invocations faster.

learning-at-the-library.jpg

Bekk Consulting‘s Aslak Hellesøy telling people about a few “underdog web frameworks” on the second day in Oslo.

This room was by far the coolest place to watch presentations! It was really nice to hang out in purple velour sofas, listening to all sorts of interesting stuff. This was also the place for my track on alternative web frameworks.

couch-hacking.jpg

Here’s Evan Phoenix (to the left, back facing the camera), talking to Wayne Kelly (of the Ruby.NET project, now with IronRuby), along with James Cox (laughing, from Smokeclouds), Dr. Nic (in awe, from various projects, who is by the way a real doctor), Glenn Vanderburg (equally awed, from Relevance), Sam Aaron (seemingly puzzled, from Innovation Factory), and – sitting with his back facing the camera – James Adam (from Reevoo).

This picture really sums up the atmosphere of Chateau Neuf in Oslo, as people were casually sitting around with their laptops. I have to give credit to the entire Ruby community as well, as it seems everybody were just instantly friends with a common interest.

I am really looking forward to next year where we will hopefully arrange another Ruby Fools conference.

(*) Accidental name clash with this – such a shame!

Thoughts on metaprogramming

I’m not too much into long philosophical blog posts, but this is a great post by Raganwald about metaprogramming… Basically, he argues that tools that are powerful are also dangerous – but that should not keep you from using them. As an example he uses metaprogramming, because it is an extremely powerful feature of Ruby which can potentially be used in so many equally beneficial and/ or harmful ways.