November 02, 2007

Software headaches

Every once in a while in your career, you encounter problems or concepts that blow your mind. Either because they are complex or just because they are just plain exotic. Here are a few I can remember over the past 30+ years that I have been in the software industry...
  • Assembly language. I encountered this for the first time on my Apple ][. After a year of learning some Applesoft Basic, I encountered a curious instruction that I had never seen before: CALL 768. When I ran it, it played some music. After weeks of research (this was in the early 80's... no Internet nor even books), I managed to figure out that I needed to switch to the "monitor", convert the address in hexadecimal ($300) and see the "listing" (basically opcodes). I was absolutey mystified. I couldn't make sense of any of this and but I did manage to alter the pitch and tune by inserting values in random places. It took me years to finally get a grasp of what's going on. One thing for certain: I was hooked.

  • fork(). I encountered this mysterious function in my early CS classes, and if you're not familiar with UNIX, it basically lets you spawn a new process. The semantics of this function is absolutely baffling, I just can't understand how anyone could ever come up with this and think it's intuitive. But as years go by, you just get used to it, just like you stop noticing this eyesore building every morning on your way to work.
  • Pointers. Aaah... pointers. Just when you think you start having a handle on this programming thing, a mean teacher throws you a curve ball and tries to explain to you how pointers work in Pascal. How inhuman. I suffered months of mental anguish trying to wrap my head around this concept, and then suddenly, it made sense (and I even managed to relate this to my earlier assembly language discoveries... now *that* was an epiphany).

  • Continuations. As opposed to the other three items described above, I can't say that even as of today, I understand continuations. They just don't make any sense to me and even if they did, I just can't see any practical use to them except maybe to torture students and make sure you grade along the curve. Yuck.

    These are the main painful experiences I can remember, I'm sure there are more.

    How about you, readers: do you have any painful learning experiences to share in the area of computers?

    Posted by cedric at November 2, 2007 10:27 AM

Comments

The main one for me was functions as values/closures. I was coming from a C/Pascal background and it took me a full day of doing an assignment in Scheme for my programming languages course before I figured out what the big deal was. I have not since been happy programming in any other way.

I was also mystified by PEEK/POKE on the Commodore 64, mainly because I had no manual for it and just copied code out of Byte magazine. I would just change values to figure out what to do with them, but it wasn't until recently that I learned what those operations really did.

Posted by: Geoff Wozniak at November 2, 2007 11:37 AM

Perl for me, I have to re-learn it everytime I want to use it :)
Seriously though I struggle to think of a reason I'd use closures. I have a vague recollection of being totally baffled by peek and poke in my Vic 20 days (I was 8). Having learnt to code such a long time ago I find it hard to remember that programming constructs are highly abstract to most people (non-coders). This became very clear to me recently when I was trying to explain objects/classes to an interested friend.

Posted by: David Hayes at November 2, 2007 11:50 AM

Regular Expressions. It is amazing what you can do with expressions that look like line noise...

Posted by: Ed at November 2, 2007 11:52 AM

The one thing that gave me serious trouble was the fact how really quite simple it is to talk to periphery in software, in several senses. Assembler mystified me largely because of this; I understood what PRINT does in BASIC, but I couldn’t fit into my mental model how you would go about doing that in assembly. For the longest time I thought I would have to write code that would be directly responsible for driving the CRT. A similar confusion was that I thought compilers translate code by doing something like treating function calls as macros and inlining their code.

I was irritated about the concept of pointers when I first encountered it, but I understood it quickly, and I started to like them very quickly.

(And a while after that I finally started understanding how assembly really works, whereupon I plunged into a several-year obsession with it, writing graphics routines such as a texture mapper. (That was way before 3D graphics cards.))

I also thought fork() was a really stupid approach to process creation when I first encountered it. But I gradually realised why it makes sense, and now I haven’t just gotten used to it, I do in fact think that any other approach is manifestly inferior.

As for continuations… uhm, I understood them before I knew I did. I pretty much came up with the idea independently before I learned that it already existed and already has a name. To be precise, what I came up with on my own is a special case of continuations roughly on par with what’s known as indirect threading in Forth.

Functional programming was difficult for me when I first found it (heavily disguised under Perl’s imperative-looking exterior) mostly because I had to unlearn years of braindamage from Pascal and the rest of the ALGOL posse. But I could taste it right away and I understood it made sense, just not exactly how; I kept at it until I figured it out.

In contrast, understanding object oriented programming was a pain and a half. It took me over a year before I understood it at all; it took me over a decade before I learned about the Replace Conditional With Polymorphism refactor and finally put together how to really use it to good effect. I now find OOP useful for certain kinds of design problems, but I still dislike it and consider it ridiculously overrated.

Posted by: Aristotle Pagaltzis at November 2, 2007 02:11 PM

Definetly:
- Regular expressions. They really look like someone is insulting you...
- Operator Preceence. I did a conversion from C to Java, and after a while HORROR. They don't have the same priority for / and *...

Nightmares :-(

Posted by: Fred at November 3, 2007 03:14 PM

30 years in "The industry"? ?! You've been a professional coder since you were 6? :)

Posted by: Mark Griffith at November 3, 2007 04:42 PM

I learned pointers in Pascal as well, and it was every bit as painful. I learned the mathematics of the arithmetic more or less, but without understanding it fundamentally. It wasn't until years later (and a degree in math, not cs) that it really clicked.

Now I routinely encounter senior Java programmers who obviously don't really understand pointers. They can talk about pass-by-reference 'til they're blue in the face, but they'll turn around and want to "optimize" some method by passing an int field of an object, instead of the actual, already-loaded-in-memory object...

Posted by: Michael at November 3, 2007 05:36 PM

Wow, 30+ years. You must be ancient. I'm 43 and I only have 18 years experience.

Posted by: Gordon J Milne at November 4, 2007 02:01 AM

Second on the learning assembly, then learning about c pointers. And suddenly it dawns on you.. this is not hard, i've done this in assembly.

move.l #$10000,a0
move.l #$10000,(a0)

(68000 assembly, ymmv)

Posted by: morten wilken at November 4, 2007 11:41 PM

Same thing for continuations, one of the worst memories of a Scheme training.

Now struggling with monads. I'll see if it works better.

Posted by: Stéphane Bortzmeyer at November 6, 2007 01:29 AM

I hate Assembley langunage .I couldn't pass the lesson However I worked :(

Posted by: Çadır at November 13, 2007 10:43 PM

Trees.

I found quite difficult to develop them, because one has to keep track of several pointers at the same time, and be extremely precise on which pointers to change, and think every single routine in a general way, and it's not even easy to debug, and blahblahblah.

In this days I'm writing B-Tree[s] routines for a database, and I spent several hours just to have a working insertion.
Of course, I love trees ;-)

On the other side, I never had any problem anyway with recursion, pointers, or assembler :-)

Posted by: Saverio at November 24, 2007 05:30 PM
Post a comment






Remember personal info?