I realize that this blog is mostly about politics, economics and gender issues with a bit of business creation thrown in, but this post is going to be geeky as hell. You see, in my day job I am a programmer and I have been since around 1994.
This post is going to be about abstraction… the process that is so popular in programming these days of breaking code into small, small pieces that interact with other small pieces, and some of the standard practices that are around that are just stupid ideas.
Lets start with databases… maybe it’s because so many of the people I work with weren’t around in the early nineties, and they were introduced to the industry after SQL became widespread that they don’t understand exactly what it is that they are doing when they write database abstraction classes that remove writing actual SQL from their code. See, back when I started out every database was accessed differently. You had to learn a specific language for that DB and often that meant you were programming in whatever flavour of the month you were using. In C and Assembly Language it was worse. You created the database and the access methods most of the time (only if you had a lot of money for the project could you use one of the SQL based DB’s). This meant that you had hundreds and hundreds of pieces of syntax floating around in your brain just to get the information your program needed to function. SQL ended all that. There were minor differences (this database supports limit, that one doesn’t, etc.) but for basic tasks like reading, updating, inserting and deleting simple data you were fine. This actually led to a lot of the web 2.0 revolution. Now that it was easy to figure out the database end of things and you could get a free database that did everything you needed, you were welcome to concentrate on the more important bits.
Now, everyone creates a class for accessing SQL. Some kind of Active Record beast that uses a custom syntax (instead of SELECT * you type findall… etc.) They object oriented methodologies to make it an object that has methods you can access. In the end it just means that you have to learn a unique syntax for every project you work on and you have hundreds of methods for accessing a database floating around in your head…
Another big guilty party is the whole idea of MVC and templating. Every MVC system I know of uses a templating system, often Mako templates, but maybe something else. Now, instead of learning the language you are using, you have to learn at least three languages. You have to know HTML because that is the main presentation language and if the content isn’t presented in HTML you are not going to be able to output to a web browser, and since most business programming does output to a web browser these days… of course you have to know that actual scripting language you are using (python in the case of my day job, sometimes c, sometimes php, etc.) and then you have to know Mako. Mako is a bad language. It is a cludge of a clusterfuck designed to abstract programming from the person building the page, but one that still supports variables, conditional branching, looping, basically all of the features that make a programming language a programming language. Technically you could make a Mako template that accepts no data from anywhere and have it actually be a program… although without something feeding it data it would always display the same thing as it is lacking any input methods. Hell, combine it with some JS and you could have a decent web app… oh yeah, make that four languages for a modern app. The worst ever offender for this is PHP using Smarty. PHP is a templating system folks, it isn’t even all that much more powerful than Mako… more functions and some actual input abilities, but at the base you could create a page that was identical to a Mako template in every way except that it used the slightly more elegant PHP coding where Mako has its cludged together crap-tacular coding (this is a real, honest to god, function call within a Mako template: ${h.form(h.url(action=’add’, method=’POST’))} and something that is the equivalent in PHP <?php form(url(‘add’,’POST’)); ?>, how in gods name does Mako add anything to that?)
Lets talk MVC. For the uninitiated, MVC stands for Model View Controller. It is a way of breaking program down into standardized blocks. The Model describes the data the program will use. It provides an access point to the database (for your incredibly awesome Ruby on Rails Active Record implementation). Just to be clear, this means that you have to define your database in two places, inside the actual DB and in your model… they match because your model takes care of creating the DB structure for you, but in reality that DB structure now exists twice. Then you have a view. A view is bits of code that feed data to Mako templates and decide which Mako templates to use (or some other template schema… but usually Mako). Again, you create memory variables which feed Mako memory variables. Finally, you have the controller. The controller takes data that the user supplies and data from the model, does various things to it (like summing up a bunch of numbers or deciding which names belong in a list of top customers) and feeds them to the view. It is yet another step in the ages long quest to turn programmers into assembly line workers. All of them doing the same thing at the same speed. In the end it produces code that can only be read if you are using an Integrated Design Environment that will find where something is actually declared for you, because you can’t possibly decipher the damn program yourself. The argument has gone from VI vs. Emacs to Eclipse vs. Microsoft Visual Studio. VI took up a few kilobytes of memory, same with Emacs. Eclipse can take up hundreds of megs of memory. Even worse though, programmers are losing the ability to think. They are in fact becoming assembly line workers, the creative spark beaten out of the ones that possessed it.
Object Oriented Design was the beginning of this. The idea is that in the real world there are objects, each object is made up of smaller bits, other objects, that have the properties of the parent (oddly enough, that system of human classification breaks down very quickly under scrutiny, but is the reigning metaphor for software development). In practice it means that when I want to say, get the name of a user, I don’t type something like getUsers(‘bob”), instead I type something like function.users._user.getUsers(“bob”) and if I want to change what a user looks like I have to figure out where the hell the code actually is. Thankfully I have an IDE so I can right click on getUsers in my code and select goto definition, or whatever the equivalent of that action is in the IDE I am being forced to use at work this week. When I started, I would look at my include lines. One of them would be called something like “users.c” and I would open it. Then I would find (by quickly scanning this fairly small file that was just functions that dealt with users) the getUsers function. Then I would make the changes I needed to. See, I did object oriented design right before doing it wrong became the way of the world.
Bad programmers produce bad code, if it is object oriented code, they produce bad object oriented code. Good programmers produce either good code, or JAVA.
I didn’t realize I was this angry about this stuff until now.