CSE341 Notes for Monday, 5/13/24

We started our exploration of Ruby. I mentioned that the 341 class used to cover 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++

OCaml

Dynamically typed

Ruby

Scheme

I said that I wanted to discuss the question of where innovation comes from in our field in terms of programming languages. In the 1970's a lot of innovation came from Alan Kay and the people who worked for him. 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.

The most recent wave of innovation came in the early 1990's. So what happened in the early 1990's? 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 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: Mon May 13 18:14:54 PDT 2024