Skip to main content

My Old School

Posted by editor on November 23, 2005 at 7:02 AM PST

How I learned to think different about languages

Taken together, two of the items on today's page remind me of my favorite Computer Science class in college. CS 108B, taught by my adviser Stuart Reges (Stuart, if you're out there, e-mail me sometime), was ostensibly about processing data, where 108A had been about representing data. But the real story is that 108B was a 10-week crash-course grand tour of computer languages, familiar and unfamiliar, designed to get us out of then-comfortable mindsets of BASIC and Pascal.

We'd basically slam through one language a week, each chosen largely for its striking difference from the others, and with the programming assignments intended to show the unique nature of programming in that language. We started with C, which a lot of us already knew, then moved on to C++. I totally didn't get object orientation then, and really wouldn't until I got into Java. The next week was Ada... I remember not liking it, but Wikipedia insists its Java-like in many ways, so maybe I just wasn't ready for it. Anyways, next we got into the crazy fun languages, LISP and Prolog.

With my eventual course of study, I ended up doing a lot more LISP and Prolog than most CS students would, and what I really like today about having learned them was how profoundly different a line of thinking you have to adapt to really succeed with them.

The way I would express this to friends would be to say "how do you add 1 to every item in a list?" The procedural programmer would say something like "you'd do a for-next loop and increment index n on each pass."

Yep, that's great... in C. But you can barely even express that logic in LISP. The right answer in LISP is to say "add one to the first element, then call yourself recursively with the rest of the list."

If you haven't done LISP, this is obviously insane. But if you have done LISP, you're already thinking of the implementation of this in terms of car and cdr... or you already did so two paragraphs ago when I asked the question.

And take it from me, Prolog requires an even more open mind. Now you have to forget not only procedural programming, but program flow altogether. Instead, you throw a bunch of if-then rules into an evaluation engine and say "have at it". You don't know and can't know what's going to run when, and you don't care. For suitable problem domains, it's crazy liberating when you "get it".

So, these are things I keep in mind as the Book Club discussion of Beyond Java moves into its evaluation of possible successors to Java. While Java's been my bread-and-butter for almost ten years, I remind myself that maybe not everything is ideally represented by an object-oriented language, by Java syntax, etc. The things that LISP and Prolog do well, Java doesn't... will they become important to me in the future?

The latest chapter thread kicks off with
Chapter 5: Rules of the Game.
"Chapter 5's intro says: 'If you think about it, you instinctively know that some programming languages will definitely not be the next big one. Lisp is productive, but the average Joe can't understand it. Perl is rich and powerful, but it's subtly inconsistent, and is prone to produce unmaintainable code. With a little vision and experience, you can apply a similar kind of reasoning to understand the types of languages that might follow Java. I suggest that we define success loosely: the language should be recognized widely and adopted broadly among developers who now use Java. This chapter, then, suggests the characteristics that the language should have to have broad commercial success.'"

Also in today's Forums,
delvento has some advice

Re: Swing threading model:
"In my experience a useful scheduling for the events is 'forget the old events and do the current one'. This makes possible to write very responsive interface in case you need e.g. to show something that depends on mouse position: often is NOT necessary to process the entire (maybe long) event queue. If the task to be performed is heavy, 'forgetting old events' is a very good solution (if it is possible, of course!)"

In Also in
Java Today
tracing a career that includes the earliest days of Java and its public debut, and continues in today's open-source world, original Java product manager Kim Polese describes her career in the speech "Kim Polese Discusses Software Development in Silicon Valley". She goes on to talk about her new role as CEO of SpikeSource and the role of open source software in today's environment, identifying the "seven things that have changed" since she left Sun during the first internet boom to launch the push company Marimba. The hour-long program was presented as part of Stanford University's Stanford Technology Ventures Program, and is available only through iTunes by visiting iTunes' Technology Ventures Program page and finding the program in the list.

Have you tied Hibernate to your web application, only to discover that you need access to your data outside the web container? One option would be to develop separate means of accessing your data, but then you'd have redundant code to maintain. Jason Lee says there's a better way. In Hibernate for Java SE, he shows how to get and use your Hibernate Session, without dependencies on your container.

Tim Boudreau describes a feature he calls Simply insanely cool... in today's Weblogs:
"Want to save huge amounts of typing? It's pretty rare that I stumble across an unsung NetBeans feature that's new to me, but this one has already saved me an enormous number of keystrokes. My hat is off to the editor team! This is simple yet amazing..."

Help Wanted: Intern to Spread the Word... Kathy Walraths says
"If you're a student with a knack for creating Web content, do we have an internship for you! The Swing team has a job opening for a half-to-full-time student intern to help us get the word out about using JavaSE for rich client apps."