Why we can’t have Nice Things

The other day, a TA told me I needed a setter variable in my lab, or I wouldn’t get credit, despite the fact that I had no need to modify the objects after instantiation. He gave me a whole spiel about how “in real life” you have to anticipate expansion of the program you’re writing, culminating in “think about it, did you really have to write that exception class?” Well, I wanted to say “yeah, I shouldn’t have written it.” I wanted to give him a piece of my mind about version creep, and about how trying to predict the future with premature optimization and the like only ends in failure (which I can say from experience). I argued with him for a bit, and then gave up, did what he asked, and immediately left.

How did we get here? How did we get to a point in the teaching of computer science where process is more important than the idea of the code? Where all programming requires design documents and useless objects for the sake of objects? When did computer science become software engineering? To answer that, we’ll need to travel to the complicated history of computer science and understand the overreaction that is our current teaching paradigm.

A Grossly Oversimplified Crash Course on the History of Programming

All modern programming languages come from two very different lineages: those descended from the ideas put forth with Alan Turing’s Turing machine (TM), and those from Alonzo Church’s lambda calculus (here the word ‘calculus’ is used to mean “a system of calculation,” instead of its better known mathematical meaning). The two formal systems have been proven mathematically equivalent, although they have rather different approaches to problem solving. C++ and Java, for example, have descended from TM way of thinking. In a nutshell, the difference is that lambda calculus focuses on functions, much like math. A mathematical function, given the same input, will always produce the same output, and the only way it affects the world around it is in its output. For example, the function x^2 does not “print out” anything–it takes an input and returns an output. TMs, on the other hand, focus on mutable data. A  TM usually outputs something by changing the world around it. When you pass pointers to functions in C++, the function changes something that is outside of itself. In lambda calculus this is (almost) always forbidden.

More modern languages like Python and Ruby tend to inherit ideas from both sides of the “family.” They let you do cool things like pass functions as variables (ala lambda calculus), and they also let you write functions that change things outside of themselves. This is why programmers love them–they are generally inoffensive languages that do what you expect, and adapt to your specific style. I recommend learning at least one of the two. (There will be more on that in the last section).

School

Ah, now we get to the heart of things. The “whys” you’ve been asking yourselves as you stay up until 2am programming to finish that f**king design document. First, realize that CS education was not always this way. Originally, computer science was in the electrical engineering department of schools (interesting side note: in Europe, computer science was under the math department–that alone should tell you something about the different schools of thought in CS). It was an extension of digital logic design, in a sense. That was all well and good for a while, until the rise of more powerful computers, and the advent of the PC. In the upper echelon of engineering schools, a more abstract and intense programming curriculum was developed that was based more on lambda calculus. MIT had an infamously hard course called 6.001 which failed many, many bright eyed young students. It certainly wasn’t perfect; I’m sure a good many of those students were capable of programming, just perhaps not at that theoretical of a level. Still, the degree said “Computer Science,” and that’s exactly what it was, a science.

It was too theoretical. With the dot-com boom, there was an immense pressure on schools to not only graduate more programmers, but ones trained in languages that the industry actually used, not academic ones like Scheme and ML. With all the monetary influences pointing in that direction, it was only a matter of time before things changed. MIT’s intro class is now Python (which is not all bad, it’s just not as in depth as it used to be). In essence, the reason why you have to deal with all of the useless shit you do is because those are the processes that industry demands. And not the startups, but the behemoths. The IBMs and Oracles and all the soul-sucking jobs that you’ll find oh so exciting when it comes time to get one.

How not to be Boring

Read the book “Structure and Interpretation of Computer Programming,” and do all the exercises. This book is almost universally lauded by the better programmers in the programming communities. Perhaps more importantly though, it will add some perspective that is missing from your CS education–the theory. It will show you everything you can do without making an object, and how to make beautiful code. If you’re in CS because you like problem solving, because like me you see elegance in a good solution and you want to learn how to be that elegant, you need to read this book before graduation.

Next, learn Python. It’s easy. When you go to job interviews, and they ask you to write code, use Python. It doesn’t matter if Python wasn’t in the job description, all they’re asking you to do is show them you can code, and Python won’t trip you up with missing semicolons or wrong types. Python, in general, is a good way to express ideas quickly. (Ruby may be even better). See the blub paradox.

The biggest thing is just to do things you like. Don’t think that just because you’re in a CS class, you’re going to learn everything you need to know. That’s just not the way the world works. I’m sorry, but it’s true. If you like games, make a really really simple one. Start with the easiest thing you can think of, and work through a tutorial online. So long as you’re typing code, you’re learning, and what you learn on your own will be much more useful to you in the long run than any of the shit they make you do at school.

 

So really, you can have nice things. They just won’t be handed to you.

It’s Been a While

Sorry for neglecting this blog. I’m tempted to brush it off with an “I was busy comment,” but let’s all be honest with each other; I had time to post before, I should have done it now. I’m sorry.

Something just clicked for me, but for my revelation to make sense you have to understand where it’s coming from first. My (abandoned?) attempt at a simple scheme interpreter wasn’t purely an exercise. It had a definite end goal, and that goal was to make a small, portable (hopefully embeddable) interpreter that would take in information and algorithmically construct images. In effect, a procedural media generator. I learned something from that attempt–interpreters, they’re like, hard, man. It’s a problem I will tackle for sure, but not today. For now, I think I’ve discovered a better solution.

JSON is to XML as ____ is to Java

JSON. As a coder, I’ve largely learned to filter out acronyms. Programmers, for whatever reason, love to name things in short all caps phrases, and when they pertain to cutting edge web development, they can get caught up in the buzz. Generally, when I see an unfamiliar acronym, it tends to be irrelevant. But not JSON. JSON is close to LISP. it’s what XML should have been; not verbose, or pretentious, just simple. And pretty (I may like Python, but the way JSON lays out those braces pulls at me).

To summarize what you’ve pieced together by now, my epiphany is simply to implement some design language in JSON, that will be rendered by a Python (eventually C?) program into an image.

No more lambda calculus, no more parsing, no more worrying about how to deal with closures.

Back to the idea.

 

P.S. If you’re reading this and you can give me a summer internship please don’t hesitate to contact me. In fact, if you’re reading this, contact me. Hell, if you’re a spambot that has evolved some form of intelligence, I’d love to chat. And if you’re a spambot that can get me an internship, tell Skynet I welcome our new robot overlords.

My Headache has a Headache

I hate bad professors. I hate them. I’m dangerously close to losing faith in Viterbi because if they really hire professors this bad, how can I be expected to trust them when they start talking about things I’m unfamiliar with? Should I have to cross-check everything they tell me is true?

I shouldn’t say any more, just yet. I need more ammo before I can really complain about the professor, but I will. This charade doesn’t deserve my attention or time, but I can’t let other students ‘learn’ from these horrible people.

“You know, I’m a rather brilliant surgeon. Perhaps I can help you with that hump…”

I reverted my computer to its “pre-winter break” state, and tried the python again. It works! I’m trying not to jump up and down as I type this. I need sleep, I have 9am class tomorrow. This is so cool.

To hell with “virtualized linux boxes;” I’ve got virtualenv!

To all those who may have similar problems with Python and OS X (especially OS X Lion):

  1. Follow this blog post about getting the Homebrew package installer.
  2. Follow instructions for installing python, virtualenv, and virtualenvwrapper.
  3. Goto /usr/local/share/python, and open virtualenvwrapper.sh
  4. In the comments at the beginning of the file, follow the instructions on what to add to your .bash_profile.

You should be done, if you haven’t messed up your computer too badly from before. Close and open your terminal to make sure the changes are in effect, then type “mkvirtualenv” to make one, “workon” to get a list of created virtualenvs, “workon name” to set your shell to that environment, and “deactivate” to finish the session.

Enjoy!

Because Everything Just Costs too Much Nowadays…

I’ve been something of a “V for Vendetta” fanatic for the past month or so after seeing the movie then reading the novel. I like both (Hugo Weaving is a fantastic V in the movie). Even if the two mediums the emphasize slightly different points, I believe that they have the same underpinnings (Alan Moore might disagree). Yes, the movie is targeted at an American audience. No, it does not bring up the critical point of V’s anarchism. But ‘movie V’s’ line about “where once you had the freedom to object… you now have censors and systems of surveillance” I think rings true to the idea of the novel as well. It certainly strikes a chord for me living in the present day America.

There’s been much ado about privacy and censorship in the news of late. I downloaded the anonymous browser Tor in response to SOPA, and also because I’ve always wanted to see it in action. It’s slow and probably unnecessary, with the multitude of ip resolution plugins for Chrome, but it was an interesting exercise. It got me thinking about why we seem to lack any semblance of privacy on the web. For example, there’s a javascript framework called visitor.js that makes cookies and visitor tracking a breeze. It can pinpoint your location based on your IP address, which, while not always accurate, is almost always in the vicinity of where you are. It knows that I’ve visited before, when I’ve visited before, and much more. And let’s not even go into mobile devices–I do not enter any personal information because I have no idea who or what is tracking me at any time. When you use 3g for web access you can be tracked within a mile or so of where you are (because cell towers only have a range of one mile).

So why do we lack privacy? After all, our society does have privacy advocates like Richard Stallman (rms), and there are consumer watchdog groups. Surely, we should be protected. Who is to blame? In the words of Weaving’s V, “truth be told…if you’re looking for the guilty, you need only look into a mirror.” So much of the web is free these days. Google makes free everything, and yet they are a billion dollar multinational. It’s the same with Facebook and Twitter. How do they do it? How do they make money off nothing but free products? There’s a saying I’ve heard going around: “if you’re not the customer, you’re the product.” And that’s exactly what we are. Necessity is the mother of invention; we asked for free, and the entrepreneurs of the world found a new set of customers: advertisers.

I want to fight for my privacy rights. I want to give these companies what’s coming to them, and never let them sell me again. I want to feel betrayed. But I don’t, because where we are now is exactly what I asked for.

If we eat free lunches, are we even consumers anymore?

When You Stare Into the Void…

I’m still not quite sure how, but I have irrevocably broken my Python installation. (Note: not the core one in /usr/bin that makes my computer do nice things, but the one that comes in the python installer. It is broken to the point that I can’t find anyone that knows enough unix, osx, and Python to help me fix it. So I’m gonna wipe this lil puppy clean and try it again.

The worst part of all of this is the smug comments I’ve gotten from more than one other programmer saying I “should’ve done all development in a virtualized OS.” It hurts because that’s exactly what I was trying to do–install ‘virtualenv,’ a program that would let me create an environment per project.

I want to like Python so badly. I’ve forgiven it for its version schizophrenia, and its slant against functional programming, and its explicit self controversy. Those fade away against the backdrop of me getting things done. But I’ve never had to face a problem quite like this when doing C/C++ development. My compiler never told me it doesn’t like the directory I chose (“can’t process .pth files in this directory”) or anything insane like that.

It’s been less than a week with Python and I’m already at my last resort: Guido van Rossum, if you’re out there, somewhere, can you help me?

I made a cursory attempt at full list processing stuffs in the scheme interpreter, which failed. I forget the exact error, I’ll look into it in more detail this week.

I’m not giving up on the interpreter, but I feel as though I’m slowing down. I was approached by a friend to help him design a social media website. I knew no scripting or web programming languages, and the DOM confuses me. This blog has given me my only real exposure to web programming, in that I glanced at the source of WordPress and the ‘$’s everywhere scared me attacked my eyes. Knowing all of this, I immediately accepted his offer (no, I actually did, I’m not joking).

So anywho, I’m now fairly rapidly picking up Python. I’ve delayed learning the damn language for so long for a number of reasons: a) it is between versions; I can either learn the useful one or the future one, b) the culture is subtly hostile towards functional programming, and c) I arrogantly assumed I didn’t really need to know a scripting language (at least for now).

Honestly, I feel stupid. While in theory, I don’t agree with some parts of the language philosophy, in practice it’s an annoyingly productive language. A custom web server in 5 lines (see Bottle, Flask), without any tricks? Bah.

Back in my day… :P

This week in afitsum!

  1. I have learned how to use Git + GitHub. My account is semisight. I have uploaded my current scheme implementation, and you can follow me there. Here’s a link to the project in question.
  2. I think I finally understand how I’m going to implement the scheme parser. My new ideas since the last update are to a) use stringstreams instead of strings (they carry position information), b) more general ideas on standardizing the “pipeline” (so to speak) for parsing. The parse function will now call token() one or more times. token() takes a stringstream& and produces the next valid symbol (unprocessed–as a string) as a return value, while incrementing the position on the input stream. Some conditional logic will determine the proper Object constructor, which will then be called and parse will either return that Object or (in the case of a list) progress until a ‘)’ is reached.

Git is awesome. I’m glad I’m getting a chance to play around with it now, and I really think they should teach it at school. Not in some optional “practicum,” or any of that bullshit. Version control is important. It’s a cardinal sin (or it should be) to work on any large project without it, and students should not be shown that they “don’t need it” (because the teacher ignores it).

I was disappointed with my grades this semester. It’s fair to say they were pretty good, and people have pointed out that they’re especially good for an engineer (despite the fact that I only took one engineering course this semester, and got an A).

Whereas some might think that a GPA above 3.0 is great, I know I could have done better. When I say that, I don’t mean “oh, if only I had pulled three all-nighters before the final” (I think those kids are beyond stupid). Because I did study, and I did do as well as I could on the final. I failed because I couldn’t maintain my organization and neglected to turn in a single assignment, which cost me .08 points off my GPA.

When I think about my GPA, I know I haven’t yet failed. Some people, given my position, might disagree. But the way I see it, that GPA is not yet my GPA. It is very real to be sure, but it is not finished. Nothing is set in stone until I finish the very last graded assignment of my college career, and that day won’t come for seven semesters. If nothing else, this blog is my ongoing evidence that I will work harder.

I don’t understand most peoples’ attitude on failing. Most people define failure by exclusion: what is failure but anything that is not success? In that light, you might as well count almost everything I’ve done as a failure, because I’ve rarely gotten things right on the first try. Of course, if one takes this point of view, one quickly encounters feelings of depression. There’s a phrase for this: learned helplessness (know your enemy and such).

Failure isn’t not succeeding; it’s not being willing to try anymore. As long as you haven’t given up, you haven’t failed. As long as you’re trying, even if progress is slow, it is still progress.

It’s not about how fast you move. It’s the direction you’re going that matters.

Far better is it to dare mighty things, to win glorious triumphs, even though checkered by failure… than to rank with those poor spirits who neither enjoy nor suffer much, because they live in a gray twilight that knows not victory nor defeat.

-Theodore Roosevelt.

I wouldn’t normally post politics here (the stuff in the Soft Reboot post was borderline) seeing as this blog is my public voice, I thought I’d ask the world, nay the universe, a simple question: how is it that Fox News anchors can declare that religious freedom is over when the president doesn’t conform precisely to the anchors’ religion?

It just seems a bit hypocritical is all.