First experiments with Heroku
Heroku is an excellent cloud application platform. Because the Java platform has so much impact, I’ve never tried to write plain ruby applications. Now they have introduced Java, Node.js, Python, Scala and Clojure support. Cause I wanted to try Clojure anyway, this seems to be a nice place to run examples and prototypes. What I really like is the deep integration of Git into the project structure. Git commands are used to create / publish data on Heroku. Also the concept of omitting filesystem storage for scalability seems to be a big win.
I had problems installing the Heroku CLI on Debian (lenny) because of SSL Certificate problems. Heroku CLI developers commented out the “error” line with the important message, explaining what caused the error.
~> export RESTCLIENT_LOG=stdout ~> heroku create --stack cedar Enter your Heroku credentials. Email: xxx Password: RestClient.post "https://api.heroku.com/login", "password=hidden&username=kremers%40act-online.de", "Accept"=>"application/json", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"50", "Content-Type"=>"application/x-www-form-urlencoded", "User-Agent"=>"heroku-gem/2.15.1", "X-Heroku-API-Version"=>"2", "X-Ruby-Platform"=>"i486-linux", "X-Ruby-Version"=>"1.8.7" /usr/lib/ruby/gems/1.8/gems/heroku-2.15.1/lib/heroku/auth.rb:96:in `ask_for_credentials': undefined method `[]' for nil:NilClass (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/heroku-2.15.1/lib/heroku/auth.rb:133:in `ask_for_and_save_credentials' from /usr/lib/ruby/gems/1.8/gems/heroku-2.15.1/lib/heroku/auth.rb:71:in `get_credentials' from /usr/lib/ruby/gems/1.8/gems/heroku-2.15.1/lib/heroku/auth.rb:51:in `user' from /usr/lib/ruby/gems/1.8/gems/heroku-2.15.1/lib/heroku/auth.rb:11:in `client' from /usr/lib/ruby/gems/1.8/gems/heroku-2.15.1/lib/heroku/command/base.rb:22:in `heroku' from /usr/lib/ruby/gems/1.8/gems/heroku-2.15.1/lib/heroku/command/apps.rb:122:in `create' from /usr/lib/ruby/gems/1.8/gems/heroku-2.15.1/lib/heroku/command.rb:114:in `send' from /usr/lib/ruby/gems/1.8/gems/heroku-2.15.1/lib/heroku/command.rb:114:in `run' from /usr/lib/ruby/gems/1.8/gems/heroku-2.15.1/bin/heroku:14 from /usr/bin/heroku:19:in `load' from /usr/bin/heroku:19
After uncommenting the following Line (564 in /usr/lib/ruby/gems/1.8/gems/heroku-2.15.3/lib/heroku/client.rb):
error "WARNING: Unable to verify SSL certificate for #{host}\nTo disable SSL verification, run with HEROKU_SSL_VERIFY=disable"
After executing “export HEROKU_SSL_VERIFY=disable” everything worked.
Give Clojure a try
The first time I had contact with Clojure was in 2009, while writing my final piece of coursework for my degree on dynamic programming languages in big projects, focusing on Groovy. It was a bit hard for me to get to grips with Clojure, because the learning curve is quiet different to that of Groovy (which is very shallow if you come from a Java background). One of Groovy’s painful aspects appeared during performance tests. Possibly because the language hasn’t got the same academic background as LISP, Haskell or C++.
Why I have not choosen Scala
I tried Scala because I excepted it to be more academic and exact. A major reason was that I have been impressed by Martin Odersky working on Scala. My first functional attempts at Scala were unsuccessful, due to the lack of JVM TCO. It may be due to my lack of experience that the Scala code seemed to look like “write only” Perl code. Programming Scala felt more like writing in Java, but with a lot more capabilities and primarily more complexity. The language is really hard to understand, even the complexity of its type system is astounding. I’ve been quite happy using this blog post from Stephen Colebourne to help me. I had some of the same issues after some experiments with Scala. After seeing the answer from Martin Odersky I was a bit disappointed by how he deals with criticism. Blaming people who are investing time to point out weaknesses of a language and its problems to spread FUD.
How I started learning Clojure
Getting into a complete new environment with its own paradigms is hard. Especially if you can not reuse your knowledge from imperative / procedural and object oriented programming languages. Having seen a few real world Clojure applications, I was able to get an understanding of its Java interoparability. With the help of tools like “leiningen” it was easy to build my first applications.
Why I except it to be worth a try
Clojures built-in functionality to deal with the lack of TCO in the JVM (“recur, lazy sequences, …”). I searched a long time in the Scala API for such a feature. It’s not just a wide mix of object orientation with a few functional concepts, which feels like an advantage to me. The community is also adopting good libraries like these for website templates (Enlive, …).
Where to go from here
I will check out the samples for Heroku and Clojure, since Heroku is one of the most popular cloud providers and all of the infrastructure management is done for you. And now they are properly supporting Clojure. There are also goals to play around with the language such as the “petshop” and examples with database / NoSQL connectivity. Once I have tried writing these things myself, I’ll write another blog entry on it. One of my goals is to ensure that Clojure can be used in bigger web projects. I’m not sure Clojure should be recommended for such business projects yet.
[1] http://stackoverflow.com/questions/310974/what-is-tail-call-optimization
[2] http://blog.joda.org/2011/11/scala-feels-like-ejb-2-and-other.html
[3] http://entwickler.com/itr/news/psecom,id,58955,nodeid,82.html
[4] http://en.wikipedia.org/wiki/Write-only_language
[5] http://de.wikipedia.org/wiki/Fear,_Uncertainty_and_Doubt
[6] https://github.com/technomancy/leiningen
[7] https://github.com/cgrand/enlive/wiki/
[8] http://blog.heroku.com/archives/2011/7/5/clojure_on_heroku/
[9] http://thecomputersarewinning.com/post/clojure-heroku-noir-mongo