Rant on Programming.
As both an avid programmer, and computer engineer, I see more and more informatics students finishing their bachelor or master’s degree without having the faintest idea about how a very basic CPU works. And by this I don’t mean that they don’t know how to write HDL, or how caches work. It’s that the closest thing that the students encounter is the Java Virtual Machine, or the CLI from Microsoft. Now, I’m not going to start the entire “Which language should we teach the Students(tm)” discussion all over again, although I agree with Patterson on this manner ( Down-Up ).
However, independent of which programming language you learn in your freshman Computer Science track, I see no reason why not to combine it with some basic introduction to computer architecture. This on the basis of, independent of your future specialization, having a basic idea of how a computer works is really not a silly thing at all. At least on the level where you know that you have registers, memory and special flags. Furthermore, the modelling of a CPU lend itself very well to implementation in a high level language. At least if you are interested in a high level functional simulator. Writing such a piece of code could be as easy as you want, the code could be easily modular, and due to the nature of a processor or a virtual machine, you could easily introduce all the introductory concepts of programming. Your different functional units would be classes, the logic needs your basic control structures, and for parsing the input program, you need basic string processing.
Now, as always, to check if my hypothesis was correct, I took 5 minutes to write a simple model of a virtual machine / processor. Currently it supports 4 instructions ( add, put/load imm, prt, end ), so not all that but I think it illustrates the point. More importantly, the code base itself is more or less 200 lines of Java ( lending itself nicely to a exercise ), and I have tried to use some different concepts, such as basic control structures, OOP, all which you could find in your introduction to rogramming course. All without going overly complex.
Check the code out from git using: http://git.langly.org/java-cpu, or just point your browser to it.
No comments yet.