A venture into 'new' technology
Lately I looked into a few new technologies. Namely Clojure - a very interesting and young language and MongoDB a also quite interesting database.
Clojure
Clojure is a new (it celebrated it's second birthday just this month) language. It is a functional programming language that is based in LISP and runs on the JVM. This is an interesting combination in itself, but to be honest it would not have cought my attention, while I always wanted to lern LISP just that it runs on the JVM isn't a reason to sit down and try it out, acutally since I'm not really fond of Java it is rahter something that makes me careful.
Saying that Clojure has a great way to deal with it's Java heritage, it claims to make Java suck hless (I think it's not their wording but it's the essence). It either hides the Java entirely from you or gives you a ver nice interop thtat indeed makes using java less painful. My cudos to that. I would like to show an example from the clojure.org website:
(. javax.swing.JOptionPane (showMessageDialog nil "Hello World"))
That is about what needs to be done for a Hello World in Java, no classes no crazy main functions, I find that quite impressive.
Okay but I wanted to get to the point what made me curiose enough about Clojure to touch it even so it has the smell of Java stuck to it. Concurrency, since I usually work with ruby and this is the one thing ruby really does horribly, it cought my attention that Clojure promised to be very good with concurrency. It achiefs that by being functional and keeping all datatypes imutabel, which makes sense, everything that can't change is thread safe. But it does not stop there Clojure implement STM (Software Transactional Memory) to deam with cases where you actually have to change state from more then one thread - a nice solution since you don't really have to deal with the details of why it works even in cases where you've a concurent environment.
So in short, I really love this languyge, it is great work and the community is very nice. Everyone who had pondered with the idea to learn LISP it's now a good mement to do so, Clojure provides a good reason to sit down and learn, and it's even quite easy to do so.
MongoDB
Another new software I stumbled upon, acutally in combination with clojure, is MongoDB. MongoDB as the name suggests is a Database. So it is not a traditional relational database but a Document Store. That means it does not store tables with rows and fields that follow a fixed structure but collections that have documents which again have key value combinations without a enforced structure.
MongoDB is fast, I was impressed, since you can add keys for about everything most queries can be performed in close to no time. Another thing that is really nice is that you can store complex data structures as nexted structures or arrays, which is very nice since you don't have to care about refferential integrety and all that annoying stuff.
So it is not hard to notice that MongoDB still is young there are things that just don't work well yet, updating is a pain at times or requires workarounds, the Java Driver is confusing and leaks features, fortunately there is a quite good Clojure driver that encapsulates most of the confusion into a clean interface. And the concurrency support is more or less non existant.
Non the less I think MongoDB is a very nice database and I found it way easyer to use then traditional databases as MySQL, also while I've not tried it yet, MongoDB promisses a good scalability on clusters and clouds which is a big plus in my eyes.
AmberVM 0.0.19
Good news everyone!
Murphy from murfy.de and me set together to work on the next release of AmberVM. It was quite an endeavor, he has worked parallel on a different approach on the ECMA interpreter and and we took the time to merge his work into AmberVM itself so combine the best of the two worlds. We worked through a whole night to get everything done but finally every spec is working perfectly again.
The result are a few cool new features in the ECMA interpreter and Amber itself. The main changes are that the whole parser is rewritten from scratch, or rather we decided to merge in Murphy’s parser for the AmberVM ECMA implementation, then another big move is that the namespace for functions and variables are now combined in AmberVM, this allows it to handle functions as variables or even parameters.
A more complete list of new features of AmberVM in version 0.0.19:
- ambervm now supports -s switch to show the source code it executes.
- ambervm now supports -p switch to show a pseudo code that describes the internal representation of the code it executes.
- The Namespace for Functions and Variables is now merged.
- The this keyword is working corectly!
- Objects scope correctly
- Now a big thing, Closures are working, even mostly correct. Only some odd cases brake the systems as using global variables in Closures. But that’s bad style in my eyes so just don’t do it ;).
- Some optimization.
So let’s see how this works. Have fun with it and if you happen to decide to use it, drop me a line ;)
Ruby on Rails on Solaris x86
The last few days I have fought with getting ruby and rails to run on a Solaris host, and let me tell you it isn’t easy!
The worst problems to tackle were:
- readline is not working properly
- libiconv is not working properly
- nothing is in the effing PATH
readline
Okay it is really nessessarry but to be frank irb without readline support sucks. So first of all the task is to get a up to date readline library, good news are Solaris is a Unix related OS so it is not much of a problem.
wget ftp://ftp.cwru.edu/pub/bash/readline-6.0.tar.gz gzcat readline-6.0 | tar xf - cd readline-6.0 configure: ./configure --prefix=/opt/readline make sudo make install
There we go you now have the latest readline library!
libiconv
This one is more tricky, at least to figure out it is actually messed up. The symptoms were that my rails told me:
method 'camelize' for 'app':String not found
Hey of cause that means the libiconv is missing … narf … to be honest I’d hat hoped that the rails libs, that are not loaded because libiconv isn’t there complain instead of silently dieying but well – I figured it out… So same procedure as libreadline:
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.1.tar.gz gzcat libiconv-1.9.1.tar.gz | tar xf - cd libiconv-1.9.1 configure: ./configure --prefix=/opt/readline make sudo make install
bringing it together
Now we have all the libs, next task is to compile ruby. But beware it is important to tell ruby where to find the libraries as it won’t go looking for them on it’s own.
export CFLAGS="-I/opt/iconv/include/ -L/opt/iconv/lib -L/opt/readline/lib -I/opt/readline/include/readline" export CPPFLAGS="-I/opt/iconv/include/ -L/opt/iconv/lib -L/opt/readline/lib -I/opt/readline/include/readline" export LDFLAGS="-L/opt/iconv/lib -R/opt/iconv/lib -L/opt/readline/lib -R/opt/readline/lib"
This takes care of the library locations next to compile ruby itself, which is quite easy:
./configure --prefix=/opt/ruby --enable-pthread make make install
Done, the --enable-pthread option is only needed for ruby 1.8.* ruby 1.9.1 seems to detect that on it's own. Now you can go and install rails via gems and it works like a charm :)