CSE341 Notes for Monday, 2/26/07

We started our exploration of Ruby. I mentioned that the 341 class has traditionally covered Smalltalk as its final programming language. I know quite a bit about the language, but I thought it would be more fun to look at Ruby. Like Smalltalk, it is a pure object oriented language. And like Smalltalk, it is a dynamically typed language. This will allow us to complete the language survey I mentioned in handout #1:

 

Object-oriented

Functional

Statically typed

Java/C++

ML

Dynamically typed

Ruby

Scheme

I then mentioned a comment I once heard from Alan Kay and was disappointed to find that almost nobody knew who he is. Alan is one of the pioneers of object-oriented programming and one of the chief architects of Smalltalk. He worked for Xerox PARC during the 1970's. One of his most famous quotes is that, "The best way to predict the future is to invent it," which you'll find along with some amusing stores in Kay's paper on The Early History of Smalltalk (one of the most interesting papers I have ever read). Kay and his colleagues invented the future at Xerox Parc in the 1970's: a computer with a graphical user interface, a mouse, using a desktop metaphor, on a network with services like email and chat, programmed with object-oriented techniques. Xerox couldn't figure out how to make money from it. That took Apple and Steve Jobs. Then Microsoft made it work for IBM PCs and the rest is history.

My Alan Kay story was that around 25 years ago I heard Alan say that major shifts in programming paradigms seem to coincide with major sunspot activity. In 1958 we got the revolution of switching from machine code to high level languages with languages like Cobol and Fortran that used the kind of "goto" based code we are exploring in assignment 7. Around 1969 we shifted to structured programming with Algol-68 and soon after Pascal, C and other a number of other languages that used control structures like if/else and while loops instead of gotos. Around 1980 we got another shift to object-oriented programming with Smalltalk-80 and soon after we got C++ and Objective C and other OO languages.

Alan was predicting another upheaval in 1991 when sunspots would again peak. So what happened in 1991? That's when Tim Berners Lee invented the world wide web and that changed everything. The big problem with the web was that it had only one-way communication. You could create web pages that would present data along with hyperlinks, but the page couldn't interact with the user.

Sun was working on Java at the time, although they were targeting it for embedded systems (programs running on handheld devices like cell phones). When the web became popular, they realized that Java would be useful for programming applets that would run in a browser. Applets have always had some degree of popularity, but they have generally turned out to be too big of a pain for people.

The other dominant paradigm that emerged was the idea of running software on a server that would interact with a user. So the challenge was to program the server. Suddenly scripting languages became very important because they allowed programmers to quickly develop code to be run on the server. This was a very different kind of programming task than writing a gigantic program like Microsoft Word. Plus, because it was running on the server, you had a great deal of flexibility about what language to use (any language that you could put on your server).

Perl was the early favorite scripting language, but many other popular languages have emerged to fill this niche. Python and Ruby are two such languages. I gave the analogy that they are to the programming world what indie films are to the movie industry. Java, C++ and C# are like Hollywood blockbusters that cost incredible amounts of money to produce. Python and Ruby are like small independent films that are produced on a tiny budget but are often more creative and interesting than the films produced by Hollywood.

Ruby is the brainchild of a Yukihiro Matsumoto, also known as "Matz". He has said that one of his primary goals was to create a language that programmers would find fun to use. Given what I've seen and heard about Ruby, my opinion is that he has succeeded.

We spent most of the lecture in irb seeing how Ruby works. I won't try to recreate that in the notes, but I'll mention some of the key points to remember:


Stuart Reges
Last modified: Tue Feb 27 12:03:06 PST 2007