Rough Book

random musings of just another computer nerd

Month: January, 2009

Apple: Blurring the Line Between Hackers and Hipsters

Yesterday, while wrestling with my Windows XP machine to make it do dual-monitor display properly (I can’t get it to set my LCD as primary display), I ended up hosing the registry completely. It took me about two more hours to fix the system and get it back to where it was. During this whole ordeal, there were long periods of waiting when drivers were installing or when chkdsk was running. I took this time to surf the web and ended up landing on a digital copy of In the Beginning was the Command Line by Neal Stephenson. While skimming through the book (I have read the book before; I own the hard copy), I realized a few things. The book is definitely outdated; it was written before Mac OS X came out. However, a lot of points were still valid. I was mainly struck by the changing character of the Mac, and also in some sense, the changing character of (some) hackers:

Hackers like to hack. This is not a bad thing. In fact, “hack” originally did not mean “break into goverment/financial systems and do bad things”, and a “hacker” was not an unsavoury individual who did the aforementioned “bad things”. A “hack” originally meant “an elegant and clever solution to a problem” (although, it paradoxically also means “crude and ugly solution to a problem”), and a “hacker” is a person who comes up with such solutions. Most programmers call themselves “hackers”. The media term “hacker” is actually described by the term “cracker”. Hackers are constantly tinkering with things. Usually they are trying to make things better, but more often than not, they end up breaking it. However, in the process they learn very valuable lessons about how not to break something, and then immediately find another way to break it again. In all seriousness though, what we learn are the limits of the system, and how the system works. Hackers don’t like unknowns and black boxes. They want to know what makes things tick.

My dad got me my first computer in 1990. I didn’t do much on it at first other than play games. I actually started writing code in 1992, and I haven’t stopped. I’ve been hacking around since then, and in the process I’ve learnt a lot of many cool things. Over the years I’ve experimented with various OSes and programming langauges, and in the process broken and hosed many computers. But each time I learnt something valuable from them… mostly. One of the cooler things (I didn’t learn anything from this really, it was just a bug) I did was writing a self-replicating Perl script that kinda ran wild on ASU’s Solaris server. There were so many scripts running around that it brought the server to a crawl. I eventually figured out what was happening and managed to kill all the processes. Anyway, my point is that people like me like to tinker around. We don’t mind if we break stuff while doing it, because we’ll figure out a way to fix it. It’s the “figuring out” part that makes us happy. So what does all of this have to do with Apple, Hipsters, and Hackers? Well, in Neal Stephenson’s book he describes two kinds of people: Eloi and Morlocks. An Eloi is your average internet user; they view computers as appliances and tools and nothing more. A Morlock, on the other hand, is your average hacker. The computer is definitely a tool, but it is a tool that can be used to create other tools. The workings of a computer are usually a mystery to an Eloi, but not so for the Morlock. Before Mac OS X, most users of Macs were of the Eloi variety. The Mac was a beautiful and stylish magic-box that did wonderful things. The inner workings were a mystery. You couldn’t easily get inside and tinker with it, but that wasn’t really an issue because Eloi don’t care about things like that. Morlocks gravitated more towards the PC world. Sure, PC’s were clunky and definitely not as stylish as a Mac. Plus, a lot of them ran Windows which many Mac fans claimed was a clunky and cheap copy of the Mac OS (in truth, everyone basically copied Xerox PARC). However, they could be opened up and tinkered with. At this point in time, there was also this thing called Linux, which was an interesting piece of software (at the time). Linux is basically just an operating system. What most people mean when they say they “run Linux”, is that they run a distribution of Linux. A distribution consists of the kernel (Linux), in addition to a bunch of userland tools (programs that actually let you do something). The cool thing about Linux was that it was free. You could go download it and install it on your computer and it would run. What was even more interesting was that it was made by volunteers. People actually took the time to sit down and write code to improve and enhance the operating system. Running Linux in those days was a chore. Most distributions came with a GUI (X with a window manager), but sometimes things didn’t work quite right if you had an obscure monitor and video card. Getting things to work meant going to the command-line and writing strange, arcane incantations and if the Gods were pleased, your hardware might work. But that didn’t bother the hackers, because it was fun trying to get things to work. In addition there was also a certain elitism about it. Running a Linux box meant that you had the time, patience, and above all, intelligence required to go through the mental contortions required to get a working system. But intellectual elitism is nothing new for hackers since all hackers have a bit (ok, a lot) of hubris.

Mac Sales ChartOk, so where am I going with this again? Seriously, I have a point. Things changed when Mac OS X came out; it had a command line. The command line is very important to us hackers because it lets us look “under the hood” of the GUI. True hackers always go to the command line to do serious work. The command line is a place where a pithy one-liner can replace a series of windows and buttons. To the uninitiated, the command line is a scary place where confusing and dangerous things happen. Just like a magic spell, you had to write obscure words and symbols to the computer, in the correct sequence. If you were lucky, the computer would derisively spit out an error. If you weren’t you probably broke your computer. If you were really lucky, the computer accepted your commands and did what you told it to do. The point of the commandline is that you get God-like power (mostly; to truly be God you had to be root). While this power enables you to be extremely efficient, it also enables you to do destructive things equally efficiently. The GUI shields you from the hard edges of the underlying OS. The cryptic command line is replaced by friendly windows and buttons. When the Mac OS got a commandline in Mac OS X, hacker types were suddenly interested in it. You now got the legendary stability and the “it just works” attributes of a Mac OS with the power of a commandline, and that too, a UNIX commandline (OS X’s kernel is essentially based on BSD, which is a direct descendant of the original UNIX). Which brings me to the main point. What I’ve noticed over the last few years, especially after graduating from college, is that even though I love to hack around and test the limits of a system, most times I simply want a system to work. I want to spend less time fixing the system, and more time fixing my own code. I have also noticed that I’m not the only one with these sentiments. Many of my fellow nerd and hacker friends own Macs and develop on them now. I considered getting a Mac as well, but it was a little over budget for me and I couldn’t justify the cost at the time. Macs provide a very good mix of power and stability, and that is extremely attractive to a developer. You can still hack around on the Mac (and you could probably break it), but most of the time you know it’s something you did that broke the system, than just a quirk with the system. In my personal opinion, I think Apple’s decision to include the command line in OS X was brilliant (their other good move was moving over to the ubiquitous x86 architecture). In fact, if you look over the sales chart (courtesy of the Mac from 1997 to 2008, you can see how their sales remained more or less constant from ’97 to ’02, after which it really started taking off. OS X was released in 2001.

In the old days, Mac users were a tight-knit, elitist bunch who sneered at their less-fortunate Windows-using cousins. Most times, it was with good reason. The Mac OS was stable and polished, while Windows was a clunky GUI bolted on top of a command line. To be fair to Microsoft though, Apple didn’t have to put up with exotic hardware since they had complete control over it. The demographic that Macs attracted was mostly the artistic or hipster bunch. In recent years, the demographic has increased to include some people who also liked the supposed “coolness” of the Mac. If you owned a Mac, you were different. You were part of a “cool”, “hip”, and “artistic” minority. Apple played this up, marketing the Mac as not only a stable alternative to a PC, but a cooler alternative too. Today you have more people than ever using Macs. From a sorority chick who uses it because “OMG it’s like so pretty!” to a programmer who likes it because “OMG d00d it’s lyk teh UNIX!!11!” Apple has successfully bridged the gap between two extremes. In future years, I think Apple will continue to grow stronger, and the sales of Macs will continue to rise, providing a viable, proprietary alternative to Windows. I’m not an Apple fanboi; I like FreeBSD (perhaps why I have a soft spot for OS X) and Linux more, but I think Apple deserves respect for making an excellent OS that’s friendly to hackers and hipsters alike.

The State of Computer Engineering

I was having a conversation with a few good friends (old college buddies, and fellow nerds) over a couple of beers a little while ago. We mainly reminisced about certain key classes we took while we were at ASU, and also about the state of CS and CSE graduates today. Indeed, the very nature of the degree. First, a little bit about those key classes that we took and still think about. These classes are CSE 225, CSE 421, CSE 423/438, and CSE 521. I wasn’t able to take CSE 423 and 438 because they were discontinued by the time I had completed the required prerequisites. But I was able to take the other three. All three classes deal with assembly programming. Assembly programming is the lowest level of programming there is. You directly control the CPU by sending it instructions. These instructions are actually decoded into a bit-pattern, which essentially translate into a series of on and off signals that travel to various places within the CPU (or even associated memory, I/O, etc.) and make it do cool stuff. At this level, you don’t have any of the niceties of higher-level programming-languages. There are no variables. There are no function parameters. There is no easy way to do I/O. Data can sometimes be program code and program code can sometimes be data, depending on your point of view. It’s a highly restrictive and immensely liberating and powerful environment at the same time. It takes a lot of effort to code in assembly, and much more effort to code well.

My introduction to assembly programming began with CSE 225. The class was taught by Lance Johnson and dealt with the Motorola 68HC11 (now produced by Freescale Semiconductor). I was pretty nervous about the class because I had heard how hard it was. As it turned out, yes, the class was hard. I put a lot of time into the class, and in the end it paid off. I got an A. The next class after CSE 225, was CSE 421 and this was taught by Dr. David Pheanis, one of the best professors I’ve ever had. Lance taught CSE 225 the same way Dr. Pheanis taught CSE 421, although it wasn’t as difficult. Both classes had “shotguns” (unannounced quizzes) and lab demos. In both classes you had to document your code thoroughly. In addition, you had to demo your code to the TA’s and every time you failed a demo, you would have 5 points knocked off your score for that lab. Oh, and in addition you were also graded on the efficiency of your lab solution. Embedded environments are usually sparse when it comes to resources, so getting your program to be small and fast is very important. Your efficiency score was calculated against the professor’s score. For every byte that you were over the optimal solution, you get one point taken off your lab score. If you ever beat the optimal solution, you got additional points. Pretty exacting standards.

In CSE 421, it was even harder. Dr. Pheanis would grade you on time on some of the labs as well. You also wrote code on the Motorola 6800, which was the predecessor of the 6811. As a result you were limited on the number of registers you had, which made it harder to write code (well, efficient code). You also had to have a very good amount of documentation. Each lab had a General Overview, User’s Guide, and Internal Overview. Any subroutines in your lab had to have its own User’s Guide and Internal Overview. Stack usage had to be properly documented. Logical groups of your assembly code had to be extensively documented and you had to explain the what, how, and why of your code. So if your program wasn’t adequately documented, you lost points. Our final lab involved implementing an Asynchronous RS-232 receiver and transmitter driver for the 6800. At the end of CSE 421, I learnt a lot of useful things. For one, I learnt how to write efficient code (something that has carried over into my high-level programming) and I learnt how to document my code really well. I also learnt how to be a good programmer.

The last class I took with Dr. Pheanis was CSE 521. You could register for this class, but more often than not, Dr. Pheanis invited you to take the class if he thought that you were a good student, and that you could handle the course load. I was privileged enough to be invited by Dr. Pheanis. In CSE 521, you write assembly code for the Motorola 68000. The 68k is a beautifully designed processor. The instruction set is almost completely orthogonal, and in general, it was a complete delight writing code on it. On a side note, writing on the 68k spoiled me to the point where it was impossible for me to pick up x86 assembly. The design is just atrocious. Anyway, the class was hard. I took it during my final semester at ASU, and I had two other classes (that I actually needed to graduate), but I spent the most time on CSE 521. In addition to the usual stuff you got graded on in CSE 421 (demo-passing code, efficieny (time and speed), and documentation) you were also graded on English grammar. I remember getting my first lab back and finding red marks all over it. Granted, I had done a little better than my classmates. I’ve always been comfortable with the written aspect of the English language and I thought I had a decent grasp of the language. Well, it wasn’t as decent a grasp as I had thought. I was introduced to problems such as “it or this without proper antecedent”, “the scope of ‘only'”, and “proper hyphenation”. Oh, there was also the infamous “Avoid ugly passive voice” stamp. Examples of such problems:

An “it or this without proper antecedent” grammatical error occurs when there is ambiguity in a sentence about exactly what “this” or “it” is referring to. For example, “Susan bought a dress and a hat. It was green.” In this example, we can’t say what “it” is referring to; it could be the dress or the hat. The sentence should be rewritten: “Susan bought a dress and a hat. The hat was green.” The “scope of only” is an interesting one. Consider the following sentence: “John only drinks water.” You might think it means that John only drinks water and not any other kind of drink. Actually, the only restricts the scope much more than that. What the sentence actually means is that John only drinks water and does nothing else. He doesn’t eat, sleep, sit, stand or do anything else for that matter. He only drinks water. The correct version of the sentence is “John drinks only water.” In general, you want to use “only” as late in the sentence as possible. Hence, the “scope of only”. Then there’s “proper hyphenation”. You generally want to use hyphens with compound nouns and adjectives. For example, “dining table”, “fish tank” and “operating system” are compound nouns whereas “black and blue” and “extremely hot” are compound adjectives. When you use an adjective to describe a compound noun (or vice versa), you need to properly hyphenative. Otherwise, the meaning of the sentence will be ambiguous or nonsensical. For example, consider the colloquial expression “It was a cold ass day”, meaning “It was a really cold day”. Does it mean it was a “cold-ass day” (compound adjective “cold-ass” with noun “day”), or does it mean it was “cold ass-day” (adjective “cold” with nonsensical compound noun “ass-day”)? Properly hyphenated, the sentence should read “It was a cold-ass day”.

You might wonder why English grammar is so important in an assembly programming class. Programming is more than just writing code. Once you write something, you (or someone else) needs to maintain it. So it is generally helpful if you can tell what your code is doing. This is especially important in assembly programming where it is not immediately obvious what the code is doing. I remember how Dr. Pheanis used to say that Engineers generally have terrible documentation skill. This is very true. I cannot count the times I have scratched my head looking at code I only wrote a few months ago, trying to figure out what exactly I was trying to do.

Now to the original point of my post. Larry Wall (creator of Perl) along with Randall L. Schwartz and Tom Christiansen outlined the three virtues of a greate programmer:

  • Laziness – The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful, and document what you wrote so you don’t have to answer so many questions about it. Hence, the first great virtue of a programmer. Also hence, this book. See also impatience and hubris.
  • Impatience – The anger you feel when the computer is being lazy. This makes you write programs that don’t just react to your needs, but actually anticipate them. Or at least pretend to. Hence, the second great virtue of a programmer. See also laziness and hubris.
  • Hubris – Excessive pride, the sort of thing Zeus zaps you for. Also the quality that makes you write (and maintain) programs that other people won’t want to say bad things about. Hence, the third great virtue of a programmer. See also laziness and impatience.

In addition to the three listed above, I’d like to add another one: Passion. This is the virtue that makes you like writing code. This is the virtue that makes you sit up till 3 A. M. in the morning hacking out a Mandelbrot-Fractal Generator or an artificial-life simulator just because you think it’s a cool thing to do. This is the virtue that makes you crash your box because you decided to do something bleeding-edge and incredibly unstable and dangerous just because you wanted to. This is also the virtue that gives you the desire to learn; the urge to acquire newer and better skills and to be a better programmer. Passion, is unfortunately in short supply these days among most programmers that come from college (or at least, ASU). In part, I blame the administration itself. When I was in college, the department tried very hard to force Dr. Pheanis out of his class, ostensibly to “modernize” the curriculum. Their rationale was that the processors used in Dr. Pheanis’ classes were “outdated”. Apparently they weren’t able to grasp the concept that assembly programming is not about using the latest and greatest processors, it is about learning the fundamentals. Dr. Pheanis’ last class was in spring of 2004. He’s a professor emeritus, and no longer teaching at ASU. ASU’s current computer engineering curriculum doesn’t have many interesting courses, for example, as I found out from Marc, ASU isn’t offering a compiler-design course anymore. In an urge to make the course more “modern”, I think a lot of soul has gone out of the program. Just taking all the classes doesn’t turn you into a Computer Engineer or programmer. It’s true that I learnt a lot of theory and a lot of other useful stuff from the classes at ASU, but a lot of times I went out of my way to learn things on my own. When I started college, I didn’t know the first thing about Unix. I knew how to write code (I wasn’t great… yet 😉 heh), but that was it. During my first semester I taught myself how to work on a Unix system. I learnt how to use vi and how to write shell-scripts. Over the years I started teaching myself more and more stuff – I taught myself Perl and PHP, and picked up the finer points of web development. I taught myself how to set up and administer a FreeBSD server. What also helped me a lot was that I was around people who found these kinds of things as interesting as I did. The classes and professors fostered the type of environment where you felt inclined to learn more than just what the curriculum offered. There are graduates these days who don’t think there are other development environments besides the GUI. I was writing code on a Solaris system when I was in college. My development environment consisted of the commandline and vi. It’s actually only recently that I’ve been using IDE’s (I hadn’t really used an IDE since Borland’s IDE for C++, and that was during my junior and senior years of highschool), and while I definitely find that they enhance productivity (especially for large projects), I feel equally at home hacking on the commandline. There are graduates today who don’t know anything more than what they’re taught at college (I like to call them “cookie-cutter programmers”). They know Java and/or C++ (and perhaps Lisp, and C). They know data structures, and maybe they’ve heard of Linux. But they really don’t know anything besides what they’ve been taught (I don’t think all is lost, however, there still are graduates who do more than just the curriculum – who are passionate about the field).

I guess what I’m trying to get at, is that I think CS programs at should should foster an environment of self-discovery, self-learning, and exploration. Unfortunately, I find that this is not the case with ASU’s CS program these days. Compared to what it was when I’ve gone through, it just contains a bunch of stock classes that have replaced the older ones. The reason? Supposedly “accreditation”. In fact, I remember feeling extremely disappointed when Google closed their doors in Tempe. The Google office was very close to the ASU campus. Their closing told me that they weren’t able to attract good talent from ASU, and that’s just disheartening. Perhaps the heads of the CSE department at ASU should be more concerned about giving students good, practical knowledge, and teach them how to be better Computer Engineers and Programmers than just being concerned about accreditation.

Happy New Year

Happy New Year, everyone! Hope this year is better than the last. I’m in Irvine right now, with family. I won’t be back in AZ until the 4th. Looking forward to relaxing for a couple of days.

All original content on these pages is fingerprinted and certified by Digiprove
%d bloggers like this: