Friday, May 25, 2007

No Assembly Required

Once upon a time, probably in the early 80s, and much later for some places, and some places never at all, computer science departments stopped requiring courses in assembly language. For the most part, there were only two choices: Intel's 8086 or Motorola 68000.

At some point, assembly stopped being required. Some teachers rue the day that happened, saying people don't truly understand programming unless they do assembly. This isn't entirely true. Assembly, in and of itself, is really tedious, prone to error. This is why higher level languages were invented.

However, understanding how to translate basic C code into assembly is useful, because you see that computers have no sense of objects, structures, loops the way we understand it, let alone higher level concepts like iterators, generators, anonymous classes, closures, etc. However, there is support for functions via jumps and returns.

Learning assembly also teaches you the magic of registers and memory and the stack. However, it has to be put in context. You can easily learn assembly and never really appreciate that registers are so much faster than RAM.

Those departments that still teach assembly often do it in this context. How assembly relates to higher level languages. Those who teach it like a language are hopelessly out of date. You might argue that you are programming on "bare metal" (why it's called that is not entirely clear to me, as it's silicon).

In any case, even assembly is an abstraction. The hardware merely has to implement the specification (the assembly language is indeed a specification) and could do so, say, by converting these instructions into other instructions and executing that, in effect, doing on the fly translations. Indeed, many Intel processors are supposed to convert x86 code, that prototype of CISC-y code, into a more RISC-style code. What's happening underneath the covers may not be a one-for-one translation of assembly to real hardware, as it once was.

I raise this point because I wonder if these stone age teachers of programming were right or not? Are current students of computer science missing out, or are they getting the right amount of information about assembly, that is, enough so they understand how it's used, but not so much that they could seriously hack in the language?

No comments: