Why Learning Assembly is Still Important for CS Undergrads

  • Posted December 2, 2009. Last modified August 4, 2010 by

This past semester I had the privilege of assisting in an undergraduate assembly language class. From my experience in my undergrad years, I found this class quite challenging since it was much different from other CS classes I had encountered up until this point. Errors from the assembler / emulator are often more cryptic that we are used to encountering. If you are lucky enough to work with a development board (which I wasn’t when I took the class myself at another school) you may not get much error feedback other than the equivalent of a windows BSOD from the board.

Many students I have encountered feel that this low level knowledge is not useful and that the particular assembly language is obsolete. They see the course as too difficult and a waste of time. I feel I can weigh-in on this debate is a slightly new light from many of the parties interested. I was recently a student in a similar course myself so I am not so far removed as some of the professors. On the other hand, I have had the experience of being involved in the instruction process of the course, I have completed an undergraduate degree and spent some time working so I am aware of the larger picture as well. Perhaps the problem of the course being difficult for students speaks to the state of the primary and secondary education system in Ontario / Canada, but that’s a whole different story.

In my opinion, this course is an absolute necessity for a degree in computer science, or even computer engineering. A big part of computer science to me is about being able to determine why and how a particular solution is faster or slower than another one and how we can improve existing solutions. Understanding the core principles taught in this type of course significantly help in understanding operating system concepts, distributed systems, compilers and many other higher-level topics in computer science. It also allows the student to see some of the limitations in current computer architectures and even how the existing / past architectures work. From a software engineering point of view, the difficulty in getting error feedback and troubleshooting is perfect for learning why it is a good idea to carefully plan and conceptualize your programs before writing. The more complicated topics in these type of courses require good conceptual knowledge of addressing, stacks, interrupts etc. Students can learn the benefit of visualizing the concepts with diagrams, memory maps and flow-charts. The same people who fail to understand memory concepts in this type of class likely have problems with malloc/free and recursion in c classes. Without knowing how the underlying concepts work, how can you be convinced that a particular high level implementation is faster than another one. You would be taking for granted what is happening at a lower level and making serious assumptions about how the system is working.

To me learning only high level languages without any assembly would be like skipping Newton’s physics models and going straight to quantum mechanics. You can probably describe many phenomenon much easier and better than with Newtons models, but without learning about Newton first you would not understand how quantum physics really works. You would not be convinced that certain properties are true and you would loose some of the ability to question what is really happening in some ways. It would be more difficult to extend ideas and even challenge existing paradigms. It really removes much of scientific component of program.

6 comments on “Why Learning Assembly is Still Important for CS Undergrads”

  1.  

    I agree assembly is handy, assuming you do some C or C++ programming, and who doesn't? Inline assembly is not that uncommon. For instance, in the older version of GCC we use at my work, you need to write assembly to do atomic variable increments and decrements for thread safe reference counting.

    The kernel also uses assembly in various places, like dispatching syscalls on a software interrupt. I've had to trace a problem from python, down to the syscall layer before, so it was handy to know a little x86 in that case.

    Also, if you work on embedded devices, which more and more people do, you really need to be good with assembly.

    Assembly isn't something I use on a daily basis, but I think if you are going to school to learn about computers, you'd better study the subject in depth and come out with as many tools in your belt as you can. Besides, it's kind of fun.

    That said, I think it's pretty pointless to learn assembly for non-extant hardware. x86 is a little crufty, but it is still easy to pick up, and practical to use. Plus there's a ton of x86 books and tools out there… and you can run your executable through your normal debugger.

  2.  

    Yes, I believe and agree with your post. Learning assembly is really hard. But I agree that this is the first step for CS grads. I had actually undergone this step. And thanks to your post. The message is clear. Hope the CS grads will take note of this.

  3.  

    "To me learning only high level languages without any assembly would be like skipping Newton’s physics models and going straight to quantum mechanics. You can probably describe many phenomenon much easier and better than with Newtons models, but without learning about Newton first you would not understand how quantum physics really works. You would not be convinced that certain properties are true and you would loose some of the ability to question what is really happening in some ways. It would be more difficult to extend ideas and even challenge existing paradigms. It really removes much of scientific component of program."

    I agree with your main point, that assembly language is useful in understanding how a program will actually run, but this analogy is really flawed. It's a problematic enough analogy that I think it would go better in reverse: high level languages are like Newtonian physics: simple, clean, and fast to work in. Assembly is like modern physics: messy, closer to the way things really work, harder to work with. I don't really like either of these analogies, though. Perhaps a better one would be between learning to do arithmetic by hand (assembly) and with a calculator (high level language)?

  4.  

    Assembly isn't something I use on a daily basis, but I think if you are going to school to learn about computers, you'd better study the subject in depth and come out with as many tools in your belt as you can. Besides, it's kind of fun.

  5.  

    For these reasons:

    1) To understand how high level applications execute on a microprocessor.
    2) Useful for the development of embedded devices where the memory space is limited.

  6. Pingback: First year as a teaching assistant « Jaqoup's Weblog

Leave a Reply

Your email address will not be published. Required fields are marked *