Wednesday, January 30, 2008

I finally tried Ruby 1.9 (developer's release)

I have been putting this off - I have been busy. Ruby 1.9 uses the YARV and seems to be about twice as fast as Ruby 1.8 - a nice speed improvement which is likely to get much better before a Ruby 2.0 release. I tried the new version on several of my POR (plain old Ruby) programs, and everything worked fine for me. Rails would not work for me, but I did not expect it to. I like the way that gem and rake are now bundled with Ruby 1.9 - that makes good sense.

With the good work also being done on JRuby and Rubinius, it is great to know that Ruby is under active development.

Saturday, January 26, 2008

More TV/Internet convergence: Hulu.com

I don't know why, but I just received an invitation to beta hulu.com and they look good! Hulu.com has a very nicely done web interface - playlist management looks especially good. Many, many online TV shows with few and short commercials. I have been using Joost for almost a year, so I am definitely into "watch TV shows and other videos anytime you want".

I am a different kind of consumer than my Dad and older brother: between them, they own 4 high definition TVs, 3 Blue Ray players, and 2 HDDVD players. While they favor high definition (which is great!), I favor convenience - I like to take short breaks from work, exercise, and reading to watch movies and some TV. I find that being able to watch 10 or 20 minutes at a time, bookmark what I am in the middle of, etc. is just right for short breaks. For watching movies with my wife and friends, I am sold on Netflicks. I have yet to buy a Blue Ray or HDDVD player for our high def TV, but progressive scan DVDs are good enough for now. If Blue Ray really wins the format war, then I will get a player sooner rather than later. Netflicks provides a great service at modest cost (and I very much like their web portal for ordering movies, etc. - really, a brilliant piece of work)

For me, the loser in the video/movie media competition is cable and satellite TV. We spend a small fortune on cable TV and I definitely do not feel like we get our money's worth - I would cancel all but basic service if my wife would let me. I plan on switching to satellite service just to see if there is a difference and to get some high def channels - I might change my opinion :-) A lot of our friends really like using DVRs with cable or satellite TV, but for me, the rented DVD (soon to be Blue Ray disk?) is better. Unlike my brother who owns 1500+ Blue Ray/HDDVD/DVD disks, I don't want to own media - life is simpler renting what I want and not clutter up our small and very tidy home with stored physical media.

Friday, January 25, 2008

I updated CookingSpace.com - now shows nutrients for meals and daily meal plans

I have been having fun with CookingSpace.com. It is now feature complete as far as what I want in it myself, but have received a few suggestions for improvement since I hosted a new version a few days ago.

I wanted to track the vitamin K and fats in the recipes that I eat, then decided to show most of the nutrients in the USDA database. I now show nutrient breakdown by complete meals and 1 day meal plans. Meals are aggregates of one or more recipes. The easiest way to try it is to just click on "Show random recipe" and "Show random meal plan" a few times. I am only adding about one recipe a day, so it will be a while before there is a large selection.

CookingSpace, except for the nutrient calculations, is a simple Ruby on Rails application. I run it on a very low cost VPS using mongrel clusters and nginx. The only complex part of the web application is the "admin only" part that is used to define recipes. Some ingredients have many entries in the USDA database; chicken has about 100 entries so when entering a recipe I need to match with one specific entry (how chicken is cooked, skin/no skin, part(s) of the chicken, etc.) Because of this, it takes me 5 to 10 minutes to enter a single recipe.

For AI enthusiasts only: I have spent a fair amount of time thinking about automatically processing text only recipes into my internal structured data for a recipe. Tough problem since, for the chicken example, I would need to determine which of the 100 chicken database entries to assign to a chicken ingredient in a recipe based on the textual description for a recipe. I think that, given a half year, I could do this :-) However, I am doing CookingSpace as a public service to help myself and anyone else who wants to estimate their nutrient intake - so I hope that will be useful when I eventually get a few hundred representative recipes entered (the 'hard way').

Yes, tools matter

Sometimes people comment to me that I will change my mind rather quickly. I admit that this is sometimes true: life is a little like a game of chess, and you 'play the current position'.

Anyway, I have been perhaps too smug with Ruby and Netbeans 6.0: really a fairly good development environment for a very good language. Anyway, I have really been enjoying using Ruby+Netbeans - so much better than using TextMate or Emacs.

That said, Patrick Logan's blog on Dynamic Languages: Should the Tools Suck? made me do a double take. The first thing that I did was to fire up Squeak Smalltalk and run Patrick's message sender example. I am grateful to the developers of Netbeans and especially the Ruby support plugins, but yes, Ruby IDE support is still weak compared to Smalltalk - but hopefully getting better faster. (BTW, Squeak is almost as slow as Ruby, execution wise. Commercial VisualWorks Smalltalk is a lot faster if you need the extra speed.)

Ruby and Java integration

While JRuby provides an obvious strategy for Ruby and Java integration, looser coupling via asynchronous messaging is another good way to integrate Java and Ruby systems. I have some bias here: I have been using asynchronous messaging to build distributed systems since 1987 (mostly using ISIS and Java Messaging System (JMS)). Asynchronous messaging makes it possible to tie together legacy systems, modularize development, and allow easier testing of system components by mocking up test messaging interfaces.

I have had some good experiences using Brian McCallister’s Ruby client for Stomp with the JMS implementation ActiveMQ. Installing the stomp client is easy:
sudo gem install stomp
and I have had to make a small change to the ActiveMQ configuration, adding a few lines to the conf/activemq.xml file:
<connector>
<serverTransport uri="stomp://localhost:61626"/>
</connector>
Here is a simple test client and test service:
require 'rubygems' 
require 'stomp'
client = Stomp::Client.open "mark", "mypassword", "localhost", 61626

client.subscribe "/queue/rubytest" do |message|
puts "received: #{message.body} on #{message.headers['destination']}"
end

for i in 1..100 do
client.send "/queue/rubytest", "message number #{i}"
end

sleep 10 # wait for ActiveMQ to process messages

client.close
This example is contrived: it uses Ruby client and service. A more likely scenario is using a Java service; assuming that you have ActiveMQ installed, with required JARs in your CLASSPATH, etc., it is easy to write Java services; start by creating a connection:
Connection connection = createConnection();
session = createSession(connection);
statusQueueDestination = session.createQueue(statusQueueName);
workQueueDestination = session.createQueue(workQueueName);
MessageConsumer consumer=session.createConsumer(workQueueDestination);
consumer.setMessageListener(this);
producer = createProducer(session, statusQueueDestination);
and define a message handler:
public void onMessage(Message message) {
try {
BytesMessage bytes = (BytesMessage)message;
long len = bytes.getBodyLength();
byte[] data = new byte[(int)len];
bytes.readBytes(data); // new String(data) would contain message as a new String

// calculate results and return a message:

Message a_message = session.createBytesMessage();
((BytesMessage)a_message).writeBytes("test message from Java".getBytes());
producer.send(a_message);
} catch (Exception e) { e.printStackTrace(); }
}

Monday, January 21, 2008

Ruby on Rails Fixed Price Quick Start Service

Although I am too busy to accept much new work right now, I am none the less putting in place something that I have been thinking about for a year: a Ruby on Rails Fixed Price Quick Start Service.

I often talk with people who have a good idea but can not take the risk of escalating development costs - same scenario applies to small startup companies. As I have the time to work on them, I am going to start accepting a few small fixed price projects that are well defined.

Friday, January 18, 2008

RIP Bobby Fischer

I never met Fischer but someone I once worked with used to drive up to where Fischer was living to play ping pong with him. He described Fischer as being eccentric (and my colleague, who camped out in his work office to avoid paying rent for an apartment, was an expert on eccentric :-)

Like most people I enjoy chess, but I am not very good a it: the one time that I played at the US Chess Open in 1978 I only scored 4.5 out of 12 points: a poor showing right after perfect scores in two local tournaments. I have worked with two people with international master ratings, and once sat with grandmaster Anatoly Lein while he went over a game in great detail that he had played the night before - people who are very good at chess perceive the game differently than the rest of us!

I don't play much chess or Go anymore, but I do like to play over "famous games". My favorites are ancient Go games played in Shoguns' palaces in medieval Japan - cool stuff indeed.

Wow: a Java application with 25 megabytes of JAR files

I was just writing about the data mining tool RapidMiner on my AI blog. RapidMiner is based on many open source projects for machine learning, clustering, data access, and data visualization, so a lot of developers contributed to that 25 megabytes of compiled Java code :-)

For comparison, NetBeans 6.0 seems to use about 15 megabytes of compiled code and Eclipse weighs in at about 100 megabytes.

Wednesday, January 16, 2008

A Tale of 3 IDEs

Except for occasional Common Lisp development (Emacs!), I just about live in an IDE. For the most part this is the excellent NetBeans 6.0 with Ruby support. However, I have dozens of existing Java projects and they almost all are IntelliJ projects so I will be using IntelliJ as long as I need these projects (long time!). To make this "IDE soup" even richer I am learning Scala (best development environment appears to be the Eclipse plugin) and experimenting a little with Google's Android portable device platform (again, an Eclipse plugin).

It takes me a minute or two to really get into a different IDE when I change tasks - makes me nostalgic for the 1980s and 1990s when I lived in Emacs for programming, email, shell, and usenet. While there are interesting Emacs tools for Android, Ruby, Rails, Java, and Scala, I am not willing to go back in history and spend my days in Emacs.

Thursday, January 10, 2008

The great static vs. dynamic typing debate

I will frame this just using two languages: Java and Ruby. I can make it even simpler: there really is no debate as far as I am concerned. There are certain classes of large mission critical systems that are best implemented using Java for reasons of type safety (avoid obscure bugs that creep past unit/functional/integration testing that occur long after a system is deployed), run time efficiency, and scalability over many CPU cores. There is a much larger class of systems that are not "mission critical" and it is more important to develop and deploy quickly, basically minimizing development and maintenance costs: I use Ruby for this type of development. Equally skilled programmers will always be able to develop faster in Ruby than in Java: less code to write and read for the same functionality because of dynamic typing, blocks, etc. It is not simply a matter of less code: statically typed languages like Scala are very terse, but I believe still slower to develop in.

The problem with just using Java is that you will end up spending too much on development and maintenance costs for some systems where the extra cost is simply not worth it. The problem with just using a dynamic language like Ruby is that for some types of systems it is simply not appropriate for reasons that I have already mentioned.

So, I don't think that there should be any debate at all - but perhaps a difference in opinion on where to draw the line in deciding the type of programming language to use for a specific project. Every programmer should be very familiar with at least two or three languages. Using different programming languages provides different points of view and ways of thinking about solving problems. Learning new languages also helps give us different perspectives on problem solving.

Being able to use the right tool for the right job is the reason to know at least one dynamic and one statically typed language very well. I would then argue that at least a small amount of time needs to be spent at least understanding what new programming languages offer. A very long time ago, when I transitioned from using C to C++ (strong type checking) I was young enough and naive enough to think that C++ was the be all and end all of programming languages. I really liked C++, writing five C++ books and spending a lot of time mentoring C++ and object oriented design. When Java was first released, I made a very quick transition to Java. Looking back on my long term use of C++, in retrospect the only projects where C++ was superior was Nintendo Ultra 64 game development and some VR work - run time efficiency was important. I have not worked on anything in ten years that would be better done in C++ because of the great speed improvements in the JVM.

We will obviously see many more exciting (and perhaps practical :-) new trends in programming languages in the next 20 years and perhaps we will some day reach the point when it no longer makes sense to master 2 or 3 different programming languages at any given time. If there ends up being no debate between when to use static vs. dynamic typed lanuages, this will probably occur when program analysis tools get good enough to provide enough protection to get the same level of safety.

Tuesday, January 08, 2008

Nicholas Carr is correct re: world wide computing cloud

Wired Magazine: But a single global system?

Nicholas Carr:
I used to think we'd end up with something dynamic and heterogeneous — many companies loosely joined. But we're already seeing a great deal of consolidation by companies like Google and Microsoft. We'll probably see some kind of oligopoly, with standards that allow the movement of data among the utilities similar to the way current moves through the electric grid.

Read the entire interview - Carr is right on it. As far as privacy laws, consumer data protection laws, etc. go: I believe that companies like Amazon, Google, Yahoo, and Microsoft (OK, I am being generous including Microsoft :-) stand a better chance of getting it right if one thing happens: quality of service contracts (I am assuming that cloud data services used by businesses and some individuals are paid for on some sort of subscription basis and not free) include guarantees for data security, including sufficient guarentees to satisfy medical record laws, concerns for company proprietary data, etc.

In the future, after the big vendors get the data security requirements down and guarenteed, it will simply be unreasonable to expect the IT department of a 500 person company to have sufficiently talented lead technical architects, sufficient staff, and sufficient redundant infrastructure to compete with Amazon for supplying secure data services. In addition to the big players, small companies like Dabble DB look very interesting but for smaller service companies it obviously becomes even more important to have a separate backup and alternative recovery system (a good idea even if using Amazon and Google!)

Instead of thinking only in terms of building on infrastructures like J2EE, LAMP, relational databases, etc. running on local servers, now architects need to consider the effective use of commercial secure data services and how these services can be used to decrease the cost and increase the reliability and security of custom business applications.

Sunday, January 06, 2008

Cool: Common Lisp Elephant object persistence package

One of my customers uses Common Lisp for a lot of development and we go with Franz, largely because of AllegroCache object persistence and great support.

Until today, I had never bothered getting Elephant installed and set up with a back end data store (I chose CL-SQL with native PostgreSQL). Since I own my own licensed copy of Franz Lisp (and my customer provides me with another license for their work), I was always happy to just use AllegroCache.

Anyway, after reading Vetle Roeim's blog post Implementing a blog in Common Lisp I decided to take a little time setting up Elephant and Edi Weitz's Hunchentoot web server and his HTML-TEMPLATE Common Lisp templating system. I used a fairly recent release of SBCL Common Lisp on a MacBook. This is all free open source software. I found the Elephant API to be easy to use.

After having some fun with this, I do have a few comments on Common Lisp vs. Ruby development:
  • Common Lisp compiled code runs much faster than Ruby: typical benchmark results are about 30 times faster - but Ruby's slowness is mitigated if a lot of processing is performed in native libraries like Ferret.
  • Development with Common Lisp takes longer than Ruby (for me, at least). It would have taken me 10 minutes to get set up with Ruby for this tutorial while it took a full 90 minutes to get 20 different Common Lisp packages and install them in the project directory for Vetle's tutorial. It is true that I will keep this project around, and if I ever need to use Elephant, HTML-TEMPLATE, Hunchentoot, etc., then I will just clone and modify this project (if I don't care about using the most up to date libraries). Common Lisp ASDF is a good package manager but in my opinion is not as good as Ruby Gems.
  • I find that I work a little faster in Ruby than Common Lisp, mostly because the language is terser: simply less code to write and read. That said, Common Lisp is also a great language to work in.

Saturday, January 05, 2008

NetBeans 6.0 Visual Web Pack: not ready, but looks promising

The NetBeans 6.0 Visual Web Pack looks promising: ability to visually edit web pages, wire in navigation, etc. Basically, automating a lot of JSP web application configuration and supports fast creation of JSP pages. I had problems with it however, and from searching the web, it looks like other people have problems also. I am going to make a note on my calendar to check for updates in a couple of months. Rails is my preferred web framework, Django looks good, but it would be naive of me to think that as a consultant I will not also have to write JSP/J2EE based web applications (since I have spent years doing this, and this technology is not going away). I would like a more agile development setup than my old approach of model classes, off the shelf tag libraries, my own custom tag libraries, and hand edited JSPs.

I have been loving the Ruby/JRuby support in NetBeans - that was my motivation for looking at other good NetBeans plugins.

Friday, January 04, 2008

Plone 3: nice!

I had not used Plone in several years. I set up Plone for a customer's development team this evening (a few of us wanted something more full featured than a wiki), and perhaps it was previous experience with Plone, but I was amazed how easy version 3 was to set up.

A few years ago, I needed to write a custom product (plugin) for Plone. At the time, I had little experience with Python and did not enjoy the experience. My attitude towards scripting languages has improved a lot in the last three years because I have spent so much time coding in Ruby. Python == Ruby in 'scripting goodness', although I do like 'Ruby blocks'. I expect to finish up my own Ruby Rails CookingSpace.com project in the next month and I might use Python+Django on a much smaller project that I plan on doing after that (I have just about standardized on using Rails for all web apps, but I do enjoy a change of perspective from different tools :-)

Wednesday, January 02, 2008

Scala programming language

I took a look at Scala last year and set it aside, but this weekend I was looking at the Computer Language Benchmarks Game and noticed just how fast Scala is because it compiles efficiently to the JVM (I dream of JRuby approaching this speed but this will not happen because Ruby is not a staticly typed language and has other nice language features that are harder to optimize)

I am very happy now doing most of my work in Ruby (and/or JRuby) but I am keeping Scala in mind for possible future projects where Ruby is too slow. I find the syntax and language features pleasing and the Scala interactive REPL shell is nice. There is some initial NetBeans 6 and TextMate Scala support, but still works in progress.