Friday, January 11, 2008

Ruby-on-Rails, the appserver for the rest of us.

Ruby is a wonderful language, but a language in and of itself is not a solution. There needs to be well designed frameworks provided so that developers have a model to work from and extend. I had learned about the Model-View-Controller paradigm during my Smalltalk period, but noticed that even the adherents to the idea often violated the principles, adding business logic in a view object and so forth. Enterprise Java developers had a fairly clear model with the Enterprise Java Bean, but the using of servlets as controllers and Java Server Pages as views wasn’t backed up by a proper set of tools to keep things straight. I saw a lot of business logic embedded in servlets, and even in JSPs. When working on MS-Windows projects, developers routinely stuffed monolithic blocks of code into Window procedures, making some of the ugliest, hardest-to-manage code ever written. The lesson here is that MVC is a great idea, but requires a well-thought-out framework that supports and enforces separation of code and concerns within the framework. Ruby-on-Rails (RoR) is that framework.

Like the Programming Ruby book, I found Agile Web Development with Rails to be an outstanding text, full of good humor and good sense. The Rails framework is very elegant, a wonderful piece of design and implementation.

In my opinion, RoR is what Java J2EE could have been, if it hadn't been bloated by big corporations throwing their weight around in standards committees. There just doesn't seem to be a reality check there. Who really needs all that complexity? Too many features were added in order to achieve competitive advantage over another high-tech rival, and not the needs of the customer.

My colleague and I have built and deployed several RoR applications so far. Nothing terribly complicated, but complete 3-tier applications that accept input, store data into databases, support a wide variety of query and reporting operations, and look pretty good too. My admiration for Ruby-on-Rails increases with each project.

Programming in Ruby

I heard about Ruby in 2004 or thereabouts. I think there was an article on about it. I am a fan of object-oriented languages, having written my first Simula program in 1975, and I like typeless languages like Smalltalk, having used Digitalk Smalltalk on several projects in the late 80s. So Ruby looked interesting. I downloaded the compiler and bought the “PickAxe book”, Programming Ruby. I enjoyed reading that text like it was a novel. I found it engaging and a real page turner. I played around with the language, but didn’t have any real opportunity to apply it, since I was working for IBM as an Enterprise Architect.

We were promoting Java, J2EE, EJBs, Message-Driven-Beans, Enterprise Service Buses, web services, WSDL, and all the other stuff that IBM was out shoving down the throats of its enterprise customers. And I was helping, standing by with a glass of water and an explanation when a customer’s system choked on one of our latest offerings.

With the advent of Service-Oriented-Architecture, I thought that we had reached a tipping point in the complexity of our product offerings. There were very few customers who could absorb all this complexity, and in fact, they didn’t need it for about 90+% of their problems. We were focusing the big-guns on solutions that might reach 10% of the market.

There had to be a better way: Ruby-on-Rails

SWAN2B, a 1976 GMC motorhome

So, you might ask, "What is a 1976 GMC motorhome anyway?" Good question. Most motorhomes of that period were based on a standard truck or a van chassis. Motor in front, rear-drive. The living area made out of aluminum trailer material attached to a frame of wooden 2x2s, perched on top of the high truck frame. The construction technique did not hold up over time, they have a real tendency to leak, and it is nearly impossible to repair any damage in that flimsy structure. Very few 70's vintage motorhomes survive.

The GMC is very different.

The drivetrain of is based on the front-wheel drive system that GM developed at that time, and it is basically the same as used in the Oldsmobile Toronado, Buick Riviera, and Cadillac Eldorado.

The use of front wheel drive made it possible to build a motorhome that is not nearly as high as those that have a driveshaft running underneath. The floor is just much lower, requiring only a single step to enter. The skin of the GMC is done in aluminum, built much like an aircraft with aluminum skin riveted to aluminum ribs. The end caps front and rear are large fiberglass moldings.

I lusted for a GMC when they were new, but they were out of my price range, so I settled for one of the 2x2-aluminum things. Maybe they would get cheaper as they got older.

Well they did get cheaper, and they got older.

I finally bought my coach in 2004, and it was cheap. It was also a basket case.

I called my basket case 'SWAN2B', since the ugly duckling could become a beautiful swan, given enough time and money.

I did a complete mechanical rebuild. Engine, transmission, cooling system, brakes, suspension, wheels, and tires. A lot more than I had budgeted, to be sure.

Then came the exterior. I thought I would get the mechanicals done (focus first on Safety and Reliability), then I would work on the interior (plumbing, electrical, carpet, upholstery, etc.), and finally, go after the exterior (body repairs, new lights, windows, windshield, wipers, paint job). My spouse had other priorities. She just could not stand the way it looked, so the exterior had to be done before the interior. The majority of the exterior work is done, the paint job is cool, and all the leaks have been repaired (well, maybe most). The interior has a new water heater, lights, carpet, and some new upholstery. Still more to do.

I have never really attempted a major rebuild like this has turned out to be, but I am happy with the results thus far.

Virtual Machines

I have been fascinated with the idea of virtual machines since I first heard about the concept in the late 60s. I think it was the University of Michigan who modified an IBM 360/65 and made it capable of running multiple isolated program spaces on one box. They called it the 360/67 CP-CMS, and it became the basis for the new 370 line introduced a few years later. Virtual machines were in the domain of mainframes at that time, and it was impossible to visualize that I would be using the concept on my laptop 30 years later. Who knew?

In my work as an architect and presenter for IBM in the 90s, I had the need to have access to the latest web application server product we were selling. These were huge cranky beasts that often corrupted the operating system when they were installed. One version used DCE as a transport protocol, and that thing had the nasty habit of locking up your computer if you changed the timezone. Since I traveled constantly with my trusty ThinkPad laptop, I could not afford to have one of the early WebSphere installs screw up my critical presentations, contact, and email. So, I started playing with VMware workstation.

I think the first version of VMware I used was 4.5.x. I managed to host a Windows NT guest on a Windows NT host, and thought I had really accomplished something! In fact, the limits of memory (I had my laptop maxed out to 1GB) limited how big a VM I could deploy before page thrashing set in, and therefore limited its usefulness. Nevertheless, I knew that VMware was on to something.

When I retired from IBM, I decided to acquire a big desktop system to experiment with. I got a dual-core amd_64 box with 4GB of RAM and a 300GB sata drive. Add a decent video card and wide-screen monitor, and I now have credible Linux-based host system, which can support multiple VMs simultaneously. And it rarely pages to hard disk.

I also experimented with various open-source virtual machine monitors, such as Xen, Virtual Iron, VirtualBox, and KVM/Qemu. For various reasons, I found all of them lacking in some respect. Some just didn’t support the network card I have, some could not provide peer networking, some were so badly documented that I gave up in disgust. I settled on VMware Workstation 6.x because it is stable and it has a good set of features that make playing with VMs enjoyable. I am a advocate of open-source software, but in this case, the proprietary product has set a standard that the others have not yet met.

I maintain two VMs, one the latest Ubuntu, and one Windows 2000, as template systems. If I decide to build a new VM for some specific purpose, I clone it from one of the templates. This saves a lot of setup and configuration, and it gives me confidence that my test environment is stable.

I have found that not all Linux packages uninstall cleanly, often leaving cruft lying around after uninstalling. That is not unique to Linux, of course, but it makes installing and testing complex software sort of like climbing out on the wing of your airplane to service the motor. Things can go very wrong, and you could lose access to irreplaceable data and spend countless hours rebuilding systems if you are not careful. And, in my opinion, backups are not a sufficient safety measure.

So, my solution to that problem is the VM sandbox. I spin up a VM, give it a unique hostname, and voila, it is another peer workstation on my network, with access to data on other servers in my subnet and access to the internet in general. Now I can go ahead and download and install new packages and test them. If they prove useful and of general utility, then I promote them to the template system. If the package disappoints, I can always blow the sandbox image away and try something else.

Virtual machines are also very useful while building web applications. You can set up a VM to be the web server, another as the database server, and several more as mid-tier application servers. They all run as peers on the network and allow sophisticated testing in close-to-real-world environments.

Fun with Linux

I have been having a great time over the last couple of years employing various versions of Linux in my personal network. I have been a Windows user (not a fan), since I worked on a piece of Powerpoint 1.0 in 1990, just before the Windows 3.0 release. I have migrated to Windows 2000, and that is the planned end of the line for my use of Microsoft operating systems.

My original intention was to move all my work to Linux. I do, however, use several key applications for which there is no Linux equivalent, such at Tivo Desktop and Quicken. I also have a large library of photos, music, and videos stored on a big NTFS volume, so I needed a coexistence strategy.

I have developed a wireless network with 1 Windows system and 3 Linux systems. The network consists of 3 wireless routers, two of which are configured as wireless access points. Two of the Linux systems, a laptop and a large desktop workstation have VMware Workstation 6 installed, so those machines can support W2k as a guest. The network also supports two Tivo boxes.

Once I got a machine with a working version of Linux (Fedora 5, in my case), I needed some way to share file systems across the various boxes. Samba came to my rescue. The initial install was somewhat daunting, and I fumbled around for awhile, trying to decode the documentation and edit configuration files. I finally developed a fairly simple configuration that suits my needs, and I am pleased with the results. It is now quite simple to add a new host into the file sharing environment.

I am not a fan of command line interfaces. Those may be "fightin' words" in the Linux world, but I find GUI interfaces much more approachable and easier to learn. I do, however, like the fact that the command line in Linux allows access into configuration areas that Microsoft products keep hidden. The availability of the command line is empowering to the Linux user, even if not used every day. I especially like the fact that many Linux command line assets have nice GUI front-ends, which keeps both camps happy. I like to use Synaptic to browse for new packages to install, but I also comfortable with using apt-get from the command line.

I tried various distros and settled on Ubuntu, starting with 6.06. I am now up to 9.10 and like each release more than the last. I like the Gnome window manager and have chosen it over KDE. There is not a huge difference between the two, but who needs to have all your application names start with the letter 'K'?

With the help of grandson Steve, I upgraded my Linksys router by flashing it with DD-WRT, an open source router based on Linux. This gives me the ability to set static leases for all my permanent hosts, while still employing DHCP consistently across the network. The dd-wrt software also provides a lot of other functionality, such as the ability to use WCP to attach a console terminal on the router. This makes the router file system accessible from my other workstations.

My resume

1966-1968 General Electric
Structural Methods Engineer
Developed Finite Element programs for thermostructural analysis of re-entry vehicles. Programmed in Fortran on IBM 7094 and GE 600 systems.

1968-1970 General Electric
Math Analyst
Developed command and control programs for military reconnaissance satellites. Programmed in Jovial and assembler on a CDC 3800 system.

1970-1973 Eldorado Electrodata
Software Development Manager
Developed and managed a complete suite of software for small business computer systems. Among the products developed were tape and disk operating systems, asynchronous communication systems, word processors, sort/merge tools, application languages and compilers. In short, everything needed to support the sale of small business systems. Programmed in assembler on proprietary 8-bit minicomputers.

1973-1977 Intel Corporation
Lead Software Development Engineer
Was second engineer hired in new Microprocessor department. Developed the first program for the 8080 microprocessor, an early BIOS/debugger. Designed and developed a complete range of development tools: disk operating systems, editors, compilers, assemblers, linkers, and in-circuit emulation tools for 8080 and 8086 systems. Developed a real-time kernel for the 8080. Programmed in PL/M and assembler.

1977-1982 Dharma Systems
Independent Consultant
Consulted with companies in the process of adopting microprocessor technologies. Provided development tools and software development skills.

1982-1989 Convergent Technologies
Manager, Applied Services
Ran a department that performed custom development services for the companies’ line of x86-based distributed business systems. During this period, I learned a great deal about distributed systems.

1989-1995 Callosum
Independent Consultant
Provided software development services to client companies. Clients included Bull Corporation, Microsoft, and Xerox. Programmed in C, C++, and Smalltalk.

1995 – 2006 IBM Corporation
Senior IT Architect
1995 -1996 DSOM Architect
Applied DSOM (Distributed System Object Model) products to a currency position trading system for a major bank. Implemented DSOM server and OpenDoc clients to provide near-real time currency positions to traders. Judicious use of caching reduced position calculation time from 7 minutes to 2 seconds.

Designed a publish-subscribe network for a major railroad. Acted as architect and team leader for the prototype implementation. Results of the project informed and influenced development of the Java Messaging Service and Message-driven Enterprise Java Beans later.

1997-2000 Consulting Architect, Software Group Technical Marketing
Worked on the introduction of the Component Broker application server, which evolved into the WebSphere Application Server. Sold the first CB opportunity in EMEA, at Swiss Bank Corp. Managed the EMEA beta program, with teams deployed at Volvo, GAD, France Telecom, and Swiss Bank Corp. I learned a lot about CORBA and other distributed technologies during this intense period.

2001-2003 Senior Architect, Worldwide WebSphere Technical Sales
Focused on Application Integration with WebSphere, using MQ and JMS. Conducted architectural design sessions with major corporations, such as 3M, Sabre, American Express, and American Airlines. Led a weekly discussion group on J2EE architectural patterns. With the advent of Web Services, this evolved into a Services-Oriented Architecture discussion group. I have given SOA presentations in North and South America, Europe, Asia, and wherever else needed. I have been an invited speaker on many occasions.

2004-2006 Senior Architect, Worldwide WebSphere Commerce
I have applied my experience with application integration and SOA principles to help WebSphere Commerce evolve to better fit the SOA model. Version 5.6.1, in beta in 2005, has a generic service interface, which should reduce integration costs substantially and enable Commerce to participate in BPEL-style process choreography.

2006-present Ruby-on-Rails consulting
I have been combining my love of Ruby and Rails with my extensive background in Enterprise Architecture to help clients build out web applications that are reliable, scalable, secure, and integrate well into existing systems.