Side Effects Of Programming

“Nelson: Ah, he’s the greatest showman since that kid who eats worms!
Kid Who Eats Worms: My 15 minutes of fame are over!”
The Simpsons, Episode 3G02

The post about Durian seems to have been the most popular one in the recent history of . This once again proves that eating gross things is entertaining to the masses. To prevent the surging popularity of my blog I absolutely must write a little bit about something that I almost never write about. Programming.

My co-worker who could not understand why he could not increment a variable in XSLT found an amazing piece of technical writing in an O’Reilly book about XSLT. Here it is:

“Although these XSLT variables are called variables, they’re not variables in the traditional sense of procedural programming languages like C++ or Java. Remember that earlier we said one goal behind the design of the stylesheet language is to avoid side effects in execution? Well, one of the most common side effects used in most procedural languages is changing the value of a variable. If we write our stylesheet so that the results depend on the varying values of different variables, the stylesheet engine would be forced to evaluate the templates in a certain order.

XSLT variables are more like variables in the traditional mathematical sense. In mathematics, we can define a function called square(x) that returns the value of a number (represented by x) multiplied by itself. In other words, square(2.5) returns 6.25. In this context, we understand that x can be any number; we also understand that the square function can’t change the value of x.

It takes a while to get used to this concept, but you’ll get there. Trust me on this.”

(full text here)

The quote that I highlighted in bold absolutely gets me. Yeah, that’s one good side effect. I get the feeling that XSLT was committee designed with the specific purpose to make life miserable for programmers. Also that committee must have had some really good stuff to smoke.

Uh, see, now this is what happens when you try to write programs without actually understanding computer science fundamentals. I did not realize that XSLT was functional, not procedural. Like most mediocre programmers out there I was not exposed to much functional programming (I did try to teach myself Lisp, but quickly gave up). Having to do a lot of SQL(which is near-procedural) over the years improved my understanding of functional programming, but not enough to realize what the XSLT book was talking about (reading it from beginning would have been helpful too). Now hardware XSLT accelerators, which made me laugh when I first heard about them, make sense too.

Call Me Dr. Uncoherentrant Rafi

My brain is completely fried. I spent the last two weekends writing horrible XSLT templates for work. This Sunday I was I was listening to Survivor soundtrack, Sgt Pepper’s Lonely Hearts Club Band and Doc Watson cds. Big Drama on the Survivor CD goes especially well with my mood right now. I hate XSLT.

Lost a few pounds. Not eating in the evening and running seems to have nudged me off the plateau. In fact, I am going to the gym right now.

In other news: the doctor’s office with a phone number that is similar to my work number is back in business! The new doctor’s name is either Rafi or Ravi.

Reading The Night Land by William Hope Hodgson. All I have to say, this is going to be the subject of the next “Best Sci-Fi You Haven’t Read” article. , if you are reading this, check out Night Land and Hodgson’s biography. Good stuff.

Why did I get into an argument about abortion with ? I don’t have any spare brain cycles for that. What will I do next, start arguing about animal rights with MIA ? Am I turning into ?

Wright’s book The Golden Age seems to be on a Hugo list at NESFA. I know it’s worthy of a Hugo and I think Gernsback would have agreed too. Heh heh, interesting how spellcheckers suggest “greenback” for “Gernsback”.