About my favorite languages, I actually have 2 favorite languages
- Ruby: for all scripting and making quick apps.
- Clojure: for development.
Why Ruby is great
- The language was designed for programmer use, you can see that from the api which is totally intuitive.
- Lots of libraries, my favorite is Sinatra which lets you build quick and dirty web apps and the other is Sequel.
- I wrote a blog post on how to delete RFC-822 in compatible emails (if you are a developer using linux and your company uses Outlook you know what I am talking about), this is a simple example of how I have used Ruby to make quick and dirty scripts.
I have used Ruby numerous times to write scripts to fix production data, correct files, and to generate complex reports. I have used Sinatra with Google Charts to make web apps that can show load times, server status ….
Why Ruby is not so great
- Not really meant for performance, recent years there is a push to develop a virtual machine for Ruby but it is still not anywhere close to C/Java performance.
- Rails is a pain to deploy, Heroku takes away the pain but what do you do if you have to deploy internally ? I personally have 2 apps on Heroku one of which is http://first3links.com/
Why Clojure is great
I have been on a quest to learn a functional programming language for the past 3 years, I have read the Erlang book (please see the various posts I wrote about Erlang here). Erlang is a fine language but I lost interest in it after I could not find a single good library that can connect Erlang to Oracle. The problem, there are too few 3rd party libraries. The next language I looked at was Haskell, lots of libraries and seems to be good at performance on the surface, problem I see is acceptance by business, where most of the code is in Java. Then I found Clojure and fell in love with it.
- It is just another DSL for the JVM, if you provide type hints the code generated will be the same as what Java would (can easily sneak it in).
- Totally embraces the JVM unlike JRuby.
- The author Rich Hickey has done a lot to reduce the pain points of lisp.
- Finally a language that frees you mind of OOP ( Have you ever noticed how much time you spend in trying to achieve the best object model when a simple one would do ? and for what ? the customers don’t care as long as it works, the computers sure don’t care as long it is 0s and 1s)
- Code is so concise and elegant.
Why Clojure is not great.
- It has been called as the language with the steepest learning curve on the JVM, I tend to agree with it.
- Unlike Scala you have no wiggle room, it is either functional code or nothing ( I like this feature actually).
- Debugging is a major pain point. (Though there has been improvement with the latest clojure-swank).
I have written many posts on Clojure on my blog you can see them here. In the most recent post I show you one can parse a one million record file in less than 15 seconds with clojure.
Lately I have been spending time researching on how to integrate with facebook connect. There is a ton of documentation on the facebook wiki page, but as with any wiki you need to know what you are looking for. I am going to document here what I found.
For the really impatient (like me) check out this video.
- To begin with go to this Wiki page on facebook to get familiar with facebook connect and reasons for using it.
- Install the facebook developer app into your facebook page (makes it easy to keep track of your api keys and your webpages ).
- Next on the facebook developer app register your domain and it will generate the api key and secret (don’t worry about saving it you can always look it up from the developer app).
- Once you have done that you will need to download and place this file xd_receiver.htm into your applications root folder. (For step by step instructions to do this go here.)
- Include this tag in every page that you plan to use facebook connect on.
- And also include this snippet to initiate the connection.
FB.init("your key", "/xd_receiver.htm")
Should be in the body not head
- Place the login button
fb:login-button length=’long’ onlogin="successful_login();"
- You need to create the function successful_login, that will do something when facebook authenticates the user. I just went and pulled the user’s picture and show it. The code for that is here
$("#login").html("<fb:profile-pic uid='loggedinuser' facebook-logo='true' > </fb:profile-pic>. Welcome, <fb:name uid='loggedinuser' useyou='false'></fb:name >.");
And that’s about it, if you want you can check out my example at devender.net
Man this is so sad, I want to be working on ruby and rails but my present job is all about Java 😦 this is a very sad situation.
Now I can only work on it nights and weekends (and at work only when no one is looking).
Just registered for the Mountain West Ruby Conf 2009, I am very excited. I went last year and it was a lot of fun and Salt Lake City itself was nice too.
If you have landed on this post from Google you already know what I am talking about, if not read the below intro.
I work for an “Enterprisy” company, so the standard here is using the exchange server and I am on Linux using thunder bird. Every once in a while I get those emails that the exchange server cannot convert to an RFC-822 compatible format and thunder bird chokes on em and even the web mail cannot handle these, the only solution so far has been going to the web mail and selecting the mail and moving it to trash.
Finally I wrote a script to automate the whole thing, it telnets into the server checks each message to see if it is RFC-822 compatible and if not moves it into Deleted Items, you can find the script here. (It’s on GitHub feel free to fork it)
Usage ruby telnet-imap.rb <server> <username> <password> <dryrun>
All arguments are self explanatory, dry run can be y/n
PS : if you mange you blow up your inbox you are on your own!!
UPDATE (2010/03/12): Looks like this has taken a life of its own, please see the comments to find a better/newer versions in different languages.
Man today was one of those days, I am about to give up on Jruby. Don’t get me wrong I absolutely love the idea of Jruby, great way to sneak in Ruby into the enterprise. But I don’t think it is quite there yet.
If you want to use Jruby and Spring all you got do is include these dependencies into your pom file.
And it works great,……………as long as you don’t have to use Hibernate. It just so happens that Jruby uses asm-2.2.3.jar file and Hibernate uses asm-1.5.3 and apparently the api is very different between these two versions, result is
java.lang.NoSuchMethodError: net.sf.cglib.core.Signature.(Ljava/lang/String;Lnet/sf/cglib/asm/Type;[Lnet/sf/cglib/asm/Type ; ) V
Man this is frustrating, I spent all day trying to work around the problem but no go. Now here is the kicker, it works perfectly fine in eclipse and I am using maven 2 ide .
I spoke with my colleague (Tim) about this and he thinks it works because of OSGI which allows different jar’s depend on different versions of other jars.