My little one has developed quite an interest in techy things. Last week she ate several pages from the Struts-Ajax book and
this morning she happily ripped out some notes from a binder I had from a Java conference. I’m in Sql Server Analysis Services training, our architect is starting to assign me tasks in C#, and what’s really sick is that I’m enjoying it! I wonder if the universe is trying to tell me something? Perhaps the Java books around my desk are just choking hazards and need to be recycled? Perhaps I need to just forget this open source nonsense and become a minion of the evil empire?
I am amazed at how easy it is to create databases, duplicate databases in SQL server, create schemas, build OLAP services. It feels like a developers database, unlike Oracle, which feels like a DBA’s database. I can create my own sandboxes with slick tools, interface with web services, the documentation is complete and there aren’t new releases every six months to sort through.
I wrote my first Ruby program today - a solution for the Ruby Quiz Look and Say Problem. I cheated a little by writing it first in Java and then converting the code to Ruby, but I’m not going to be a Ruby expert in an afternoon. Hell, I won’t even be a Ruby beginner in an afternoon, but I will have a Ruby program with unit tests and associative arrays. I’m happy right now though writing Ruby with Java syntax and that’s enough.
My solution is test-first (as usual). Here is the Java Test and the main class and here is the Ruby test and the main class.
There’s so much to know in the technology field that it’s easy to get overwhelmed. The basics such as memory and threading go deep and new libraries for these applications are being developed all the time. I feel I get lost sometimes fighting fires and office politics. In my ideal job, I would have time to follow the latest developments in GUIs and would translate that knowledge to creating better interfaces for my users.
So I guess it’s a sweet indulgence when I write a computer program in a new language to solve a problem like figuring out the recurrence pattern for the “Look and Say” problem. And the solution is:
$ ruby count_and_say_test.rb
Loaded suite count_and_say_test
0 LOOK AND SAY
1 TWO A ONE D ONE K ONE L ONE N TWO O ONE S ONE Y
2 ONE A ONE D SIX E ONE K ONE L SEVEN N NINE O ONE S TWO T TWO W ONE Y
3 ONE A ONE D TEN E TWO I ONE K ONE L TEN N NINE O THREE S THREE T ONE V T HREE W ONE X ONE Y
...
605 ONE A ONE D TWENTY-FIVE E FIVE F ONE G SIX H FOUR I ONE K THREE L NINE N
NINE O EIGHT R TWO S ELEVEN T THREE U FIVE V FOUR W TWO X TWO Y
606 ONE A ONE D NINETEEN E SIX F TWO G FOUR H EIGHT I ONE K TWO L ELEVEN N T
EN O FIVE R TWO S NINE T THREE U FIVE V FIVE W TWO X TWO Y
607 ONE A ONE D EIGHTEEN E FIVE F TWO G THREE H EIGHT I ONE K TWO L ELEVEN N
TEN O THREE R TWO S TEN T TWO U FIVE V SIX W TWO X ONE Y
Found loop to 178 after 607 iterations
.
Finished in 2.047 seconds.1 tests, 0 assertions, 0 failures, 0 errors
Too often we program at a high-level: using this framework or that application server to hide details as we create ever-more sophisticated user interfaces. Do that for a few years and your mind starts to go soft. Every so often, it helps to review the basics. Here is a great article on memory in the Java model: http://www.javaworld.com/javaworld/jw-09-2000/jw-0908-eckelobjects.html.