Joho the Blog » programming

April 3, 2014

Hackathon love

Last weekend I was a judge at the Toronto Startup Weekend – Library Edition and was reminded again not ony how much I love hackathons, but how unexpected they are.

Toronto Startup Weekend for Libraries

The Toronto event wasn’t strictly speaking a hackathon. A hundred people met, many pitched ideas, and then people formed teams. They had to come up with a business idea and pitch it to five judges, explaining their idea, perhaps including a demo, showing their research (including user surveys if appropriate), and making the case for it as a sustainable business enterprise. (Non-profits welcome.) It was a fantastic event.

But to keep things simple, consider a classic hackathon: developers get together for a day or a weekend and are challenged to write working code, usually constrained to a particular genre (e.g., games) or using an open data set (e.g., the DPLA hackathon or the Open Syllabus Project hackathon). And the amazing thing is that they do it.

Just think about all that had to happen to make a hackathon possible and not a cruel joke.

We need browsers and HTTP and the ability to request data through them.

We need well-documented, standard ways of requesting that data.

We need open sources of data.

We need Open Source software to let us build on work done by others.

We need frameworks that let us do easy things incredibly easily.

We need libraries so we can do complex things incredibly easily, such as visualizing data.

We need an Internet to connect programs to data, software to users, and everyone to everyone.

We need an ethos that encourages sharing, experimenting, and prototyping — finding what’s right in a project not all that’s gone wrong or has been left unfinished.

I love hackathons.

Be the first to comment »

March 29, 2013

[2b2k] Back when not every question had an answer

Let me remind you young whippersnappers what looking for knowledge was like before the Internet (or “hiphop” as I believe you call it).

Cast your mind back to 1982, when your Mommy and Daddy weren’t even gleams in each other’s eyes. I had just bought my first computer, a KayPro II.

I began using WordStar and ran into an issue pretty quickly. For my academic writing, I needed to create end notes. Since the numbering of those notes would change as I took advantage of WordStar’s ability to let me move blocks of text around (^KB and ^KK, I believe, marked the block), I’d have to go back and re-do the numbering both in the text and in the end notes section. What a bother!

I wanted to learn how to program anyway, so I sat down with the included S-Basic manual. S-Basic shared syntax with BASIC, but it assumed you’d write functions, not just lines of code to be executed in numbered order. This made it tougher to learn, but that’s not what stopped me at first. The real problem I had was figuring out how to open a file so that I could read it. (My program was going to look for anything between a “[[" and a "]]“,, which would designate an in-place end note.)The manual assumed I knew more than I did, what with its file handlers and strange parameters for what type of file I was reading and what types of blocks of data I wanted to read.

I spent hours and hours and hours, mainly trying random permutations. I was so lacking the fundamental concepts that I couldn’t even figure out what to play with. I was well and truly stuck.

“Simple!” you say. “Just go on the Internet…and…oh.” So, it’s 1982 and you have a programming question. Where do you go? The public library? It was awfully short on programming manuals at that time, and S-Basic was an oddball language. To your local bookstore? Nope, no one was publishing about S-Basic. Then, how about to…or…well…no…then?…nope, not for another 30 years.

I was so desperate that I actually called the Boston University switchboard, and got connected to a helpful receptionist in the computer science division (or whatever it was called back then), who suggested a professor who might be able to help me. I left a message along the lines of “I’m a random stranger with a basic question about a programming language you probably never heard of, so would you mind calling me back? kthxbye.” Can you guess who never called me back?

Eventually I did figure it out, if by “figuring out” you mean “guessed.” And by odd coincidence, as I contemplate moving to doing virtually all my writing in a text editor, I’m going to be re-writing that little endnoter pretty soon now.

But that’s not my point. My point is that YOU HAVE NO IDEA HOW LUCKY YOU ARE, YOU LITTLE BASTARDS.

 


For those of you who don’t know what it’s like to get a programming question answered in 2013, here are some pretty much random examples:

40 Comments »

February 5, 2013

[berkman] Diana Kimball: Coding as a Liberal Art

Diana Kimball [twitter:dianakimball] is giving a Berkman lunchtime talk on coding as a liberal art. She’s a Berkman Fellow and at the Harvard Business School. (Here are some of her posts on this topic.)

NOTE: Live-blogging. Getting things wrong. Missing points. Omitting key information. Introducing artificial choppiness. Over-emphasizing small matters. Paraphrasing badly. Not running a spellpchecker. Mangling other people’s ideas and words. You are warned, people.

She says that she’s loved computers since she was a kid. But when she went to Harvard as an undergrad she decided to study history, in part because there’s a natural specialization that happens in college: the students who come in as coders are fantastic at coding, whereas Diana had greater strengths as a writer of prose. She found HTML and programming intimidating. But in her third year, she got interested in coding and Internet culture. She was one of the founders of ROFLcon [yay!]. She got hired by Microsoft after college, as a technical product manager with the Powerpoint team in Silicon Valley. “This was culture shock in the best possible way.”

When she graduated in 2009, she and some friends started found the SnarkMarket blog that considers what the new liberal arts might be (inspired by Kottke). She wrote an essay that’s a proposal for coding and decoding. She reads it. (It’s short.) An excerpt:

Coding and Decoding is about all modes of communication, and all are in its view. But it is built with particular attention to the future, and what that future will be like. Technological experts can seem like magicians, conjuring effects wordlessly. By approaching that magic as a collection of component parts instead of an indivisible miracle, we can learn to see through these sleights of typing hands. In seeing through, we will learn to perform them ourselves; and think, as magicians, about the worlds we will build.

Language, now, is about more than communication. It is the architecture behind much of what we experience. Understanding that architecture will allow us to experience more.

Her boyfriend taught her how to code. They spent a lot of time on it. “He picked up on something I’d said and took it seriously.” After two years at Microsoft, she was enthusiastic, but still a beginner. It wasn’t until she started at Harvard Business School that coding really took off for her. The entrepreneurial atmosphere encouraged her to just do it. Plus, she was more of a geek than most of the other students. “This was great for my identity, and for my confidence.” She also found it a social refuge. “It takes a lot of time to get over the hump.” She refers to Ellen Ullman’s “Close to the Machine” that talks about the utility of being arrogant enough to obsess over a project, cycling back to humility.

She decided to code up her own site for a project for school, even though the team had been given the money to hire devs for the task. Last fall she took the famous CS50 course [Harry Lewis, who created the course in about 1981, is sitting next to me.] CS50 teaches C, targeted at people who are either taking only that one class, or are going to take many more. For her final project, she did a project that used multiple APIs that she was very proud of. She’s also proud of her Ruby projects folder. Each project is something she was trying to teach herself. She’s more proud of the list than the finished products.

“Learning to code means reclaiming patience and persistence and making them your stubborn own.” [nice]

Ideally, everyone should be exposed to programming, starting at 5 yrs old, or even earlier, Diana says. Seymore Papert’s “Mind-Storms” has greatly influenced her thinking about how coding fits into education and citizenship. At a university, it ought to be taken as a liberal art. She quotes Wikipedia’s definition. And if “grammar, rhetoric, and logic were the core of the liberal arts,” then that’s sound like coding. [Hmm.] What the law was to the liberal arts, programming ought to be, i.e., that which you try if you don’t know what else to do with your liberal arts degree.

Why isn’t it seen that way? When computer scientists teach you, they teach they way they learned: at school. But many of the best programmers are self-taught. CS50 does give a variety of assignments, but it’d be better if students solved their own problems much earlier.

But the number one problem is the academic attitude, she says. Students get fixated on the grade, even when it doesn’t matter. Coding is critical for children because debugging is part of it, as Papert says. But grades are based on the endpoints. Coding is much more like life: You’re never done, you can always make it better.

Diana has a proposal. Suppose coding classes were taught like creative writing workshops. Take it whenever you’re ready. Taught by hackers, esepcially autodidacts. It’d vary in substance — algorithms, apis, etc. — and you’d get to choose. You’d get to see something on screen that you’d never seen before And you’d be evaluated on ingenuity and persistence, rather than only on how well your code runs.

She says what her syllabus would look like:

“Coding should be taught in the same breath as expository writing… Everyone deserves to be exposed to it.” She’s not sure if it should be required.

She quotes Papert: “…the most powerful idea of all is the idea of powerful ideas.” There’s no better example of this, she says, than open source software. And David Foster Wallace’s commencement address: “Learning how to think really means learning to exercise some control over how and what you think…If you cannot exercise this sort of choice in adult life, you will be totally hosed.” Diana says that’s her. She was wrapped up in writing from an early age. She has a running internal commentary. [Join the club!] Coding swaps in a different monologue, one in which she’s inventing thing. That’s the greatest gift: her internal monologue is much more useful and interesting. “If you wanted to be a novelist in 1900, you’d want to be a programmer today.” The experience of creating something that people use is so motivating.

Q&A

Q: Would you be willing to webcast yourself programming and let people join in? I do this all the time when at hackathons. I think, OMG, there must be 10,000 kids in India who want to be here. And so here they are. “Hackers at Berkeley” does this really well.

A: That’s awesome. I want more people to have more access to that experience of sharing.

Q: Are you familiar with RailsBridge — non-computer scientists who are teaching themselves how to code via weekend workshops.

A: RailsBridge is extraordinary. It’s great to see this happening outside of the university context.

A: [me] Great talk, and I’m a humanities major who spends most of his hobby time programming. But aren’t you recommending the thing that you happen to love? And programming as opposed to traditional logic is an arbitrary set of rules…

Q: Yes, but it would be really useful if more people loved it. We could frame it in a way that is exciting for humanities majors. I’m proposing an idea rather than making an airtight argument. “You’re basically right but I don’t really care” (she says laughing :).

Q: I like your idea of teaching it like a writers workshop so that it doesn’t turn into just another course. But I’m not sure that colleges are the best at doing that.

A: not everyone loves programming.

Q: [harry lewis] I take responsibility for eliminating the Harvard requirement for a programming course. Also, take a look at code.org. Third, the academic world treats computer science the way it does because of our disciplinary specialization. That label — computer science — came about in the context of fields like political science, and arose when computers were used not for posting web sites but for putting people on the Moon where a bug could kill someone. The fact that CompSci exists in academic departments will make it very difficult for your vision of computing to exist, just as creative writing is often an uneasy fit into English curricula.

A: That’s very fair. I know it’d be hard. RIT has separate depts for CompSci and coding.

Q: There’s an emergent exploration of coding in Arts schools, with a much more nimble, plug and play approach, very similar to the one you describe. My question: What do the liberal arts have to offer coding? Much of coding is quite new, e.g., open source. These could be understood within a historical context. Maybe these need to be nurtured, explored, broken. Does seeing coding as a liberal art have something to offer sw development?

A: ITP is maybe the best example of artists working with coders. Liberal Arts can teach programmers so much!

Q: Can we celebrate failure? That’d be a crucial part of any coding workshop.

A: Yes! Maybe “find the most interesting bug” and reward introspection about where you’ve gone wrong. But it’s hard in a class like CS50 where you’re evaluating results.

Q: This is known as egoless programming. It’s 40 years old, from Weinberger [no relation].

Q: You’re making a deeper point, which is not just about coding. The important thing is not the knowledge you get, but the way you get there. Being self-reflective about you came about how you learn. You can do this with code but with anything.

A: You’re so right. Introspection about the meta-level of learning is not naturally part of a course. But Ruby is an introspective language: you can ask any object what it is, and it will tell you. This is a great mirror for trying to know yourself better.

Q: What would you pick to teach?

A: I love Ruby. It would be a good choice because there’s a supportive community so students can learn on their own afterwards, and it’s an introspective language. And the lack of ornament in Ruby (no curly braces and little punctuation) makes it much more like English. The logic is much more visible. (My preference is Sinatra, not Rails.)

Q: What sort of time commitment the average person would have to put in to have a basic grasp of a programming language? Adults vs. children learning it?

A: I’d love to see research on this. [Audience: Rottmeyers, CMU (?)] A friend of mine reported he spent 20 hours. The learning curve is very halting at first. It’s hard to teach yourself. It helps to have a supportive in-person environment. CS50 is a 10-20 hour commitment/week and who has that sort of time except for fulltime students? To teach yourself, start out a few hours a time.

Q: How about where the MOOCs are going? Can you do a massively online course in compSci that would capture some of what you’re talking about?

A: The field is so focused on efficiency that MOOCs seem like an obvious idea. I think that a small workshop is the right way to start. CS50 requires so much fear of failure and resilience that it wouldn’t have been a good way for me to start. At CS50, you can’t let others read your code.

Q: We shouldn’t put together Computer Science and programming. Programming is just a layer of expression on top of computer science. You don’t need compSci to become a programmer. And the Net is the new computer; we’re gluing together services from across the Net. That will change how people think about programming because eveyrone will be able to do it. The first language everyone should learn is ifttt.com

Q: I’m a NY Times journalist. I love languages. And I love the analogy you draw. I’m 30. Do you think coding is really essential? Would it open my eyes as a journalist?

A: It’s never too late. If you keep asking the question, you should probably do it. You don’t have to be good at it to get a lot out of it. It’s so cool that your children are learning multiple languages including coding. Learn alongside them.

8 Comments »

September 9, 2012

Beginner2Beginner: Javascript multi-file upload + PHP to process it

Much as I love being a hobbyist programmer, it can sometimes be frustrating as all get-out. Sometimes it’s just a bug because I made a dumb error (getting a variable’s scope wrong) or because I made an assumption about how something works (BBedit‘s hex dump does not show you the content of the file on the disk, but of the file in memory, including the line endings it’s transformed). But then there are the frustrations that come from not having the slightest idea of the basics. The worst are the basics that are so basic that the explanations of them assume you already know more than you do.

Welcome to the world of pain known as uploading multiple files using Javascript. For example, suppose you are writing an app that lets users take notes on an article using a plain old text processor. They can then upload those note files to some code that processes them, perhaps turning them into a database. Rather than having users upload one file at a time, you want to let them upload a bunch.

There are plenty of slick, free examples on the Web that provide beautiful front ends for doing this. Many of them I could get to work, but not exactly the way that I wanted. Besides, I was really really really confused about what happened after the front end.

So, after a lot of skullpounding and forehead slapping, here’s a guide. But please take seriously this warning: I barely know what I’m doing, and I’m undoubtedly doing this in the clunkiest fashion possible. I am very likely getting important things wrong. Some of them may be fatal, at least in the programmatic sense. (If you have a correction, please let me know. Note I may fix the code that follows, rather than doing the usual — and proper — Web thing of striking through the errors, etc.) Here goes….

To enable uploads, you’ll be writing code that will live in two places. The user interface code is in the HTML running in the user’s browser. The files are going to be uploaded — copied — to a web server. The code in the browser is going to be Javascript. The code on the server is going to be PHP, because Javascript is for browsers. (Oversimplification noted.) Those two places can be physically the same machine. If you’re using a Mac, a web server comes standard; if you don’t have a web server handy, there are bunches of free ones; that’s beyond the scope of this post.

After experimenting with many of the beautiful packages that are available, I gave up and went with the HTML5 solution. Modern browsers will have no problem with this. If you need to design for the world of old-fashioned browsers, then you need to find a competent explanation. In short: I love you, but go away! (Apparently, if you use the HTML5 solution, it will still be usable in lesser browsers, although it will allow users to select only one file at a time.)

HTML5 makes it ridiculously easy to do the user interface bit: you just tell it you want to allow multiple selections within a file-chooser dialogue. This comes from a post by Tiffany Brown:

<form action="processThem.php" method="post" enctype="multipart/form-data">
<input type="file" value="" name="upload[]" multiple>
<button type="submit">Upload!</button>
</form>

This will create an input field that when clicked will launch a file-browsing dialogue box in which the user can select multiple files. It then sends it to the PHP script called “processThem.php” on your server. The two key points to note are that the first line does the work of allowing multiple choices, and the “[]” in the name turns that variable into an array that will pass the entire list of user choices to the PHP script waiting on your server.

Here’s what it looks like, although this particular example won’t actually upload anything:



Now you have to create the “processThem.php” script (or whatever name you’ve specified) on your server. The uploaded files get placed in an array called $_FILES. But, they don’t get stored on the server for long: they are stored in a temporary folder from which they are automatically deleted after a little while. So, you need to process them, and quite possibly move them for permanent storage to a folder of your choosing. Here’s some sample PHP code from an anonymous commenter (“Me”) on the Tiffany Brown post:


<?php
$error_message[0] = "Unknown problem with upload.";
$error_message[1] = "Uploaded file too large (load_max_filesize).";
$error_message[2] = "Uploaded file too large (MAX_FILE_SIZE).";
$error_message[3] = "File was only partially uploaded.";
$error_message[4] = "Choose a file to upload.";

$upload_dir  = './tmp/';
$num_files = count($_FILES['upload']['name']);

for ($i=0; $i < $num_files; $i++) {
    $upload_file = $upload_dir . urlencode(basename($_FILES['upload']['name'][$i]));

    if (!preg_match("/(gif|jpg|jpeg|png)$/",$_FILES['upload']['name'][$i])) {
        print "I asked for an image...";
    } else {
        if (@is_uploaded_file($_FILES['upload']['tmp_name'][$i])) {
            if (@move_uploaded_file($_FILES['upload']['tmp_name'][$i], 
                $upload_file)) {
                /* Great success... */
                echo "hooray";
                //$content = file_get_contents($upload_file);
                //print $content;
            } else {
                print $error_message[$_FILES['upload']['error'][$i]];
            }
        } else {
            print $error_message[$_FILES['upload']['error'][$i]];
        }    
    }
}
?>

Let’s walk through this.


$error_message[0] = "Unknown problem with upload.";
$error_message[1] = "Uploaded file too large (load_max_filesize).";
$error_message[2] = "Uploaded file too large (MAX_FILE_SIZE).";
$error_message[3] = "File was only partially uploaded.";
$error_message[4] = "Choose a file to upload.";

In the first few lines, Me does us the favor of providing non-technical explanations of possible errors, so that if something goes wrong, it will be easier to know exactly what it was.


$upload_dir  = './tmp/';

Then Me designates a particular folder as the container for the uploaded files. Me chooses one called “tmp” in the same directory as the PHP script. (Make sure you have such a folder and the permissions are set, or, of course, create one with whatever name you’d like.)


$num_files = count($_FILES['upload']['name']);

Then Me gets a count of how many files were uploaded, and stores it in the variable $num_files. You tell that variable that you want the number of files that were included in “upload[]” in the form on your HTML. (You can use whatever name you want on that form, so long as you use the same one in your PHP.)


for ($i=0; $i < $num_files; $i++) {
    $upload_file = $upload_dir . urlencode(basename($_FILES['upload']['name'][$i]));

Then Me loops through all the files, assigning each one in turn to the variable $upload_file. But notice the weirdness of this part of the line:

$upload_file = $upload_dir . urlencode(basename($_FILES['upload']['name'][$i]));

First the easy parts. The baseline function returns just a file’s name without any path information; we want that because the point of this line is build a path to where the file will be saved in the folder you’ve set up for it. Also, I added the urlencode function in case the name of the file your user uploaded contains spaces or other characters that makes your server barf.

Now consider $_FILES['upload']['name'][$i]. It’s got those weird bracketed terms because $_FILES is an associative array. You can think of the usual sort of arrays as pairing a value with a number; give the array the number and it returns the value. In an associative array, values are paired with arbitrary keys (i.e., a word); give it the key and it returns the value. Here are the pre-defined keys for the associative array that gets sent to the PHP script when a user uploads files:

  • name: The file name of the uploaded file
  • type: Is it an image? A music file? etc.
  • size: The size in bytes
  • tmp_name: The crazy-ass name of the copy being stored on the server
  • error: Any error codes resulting from the upload

So, suppose you’re cycling through the array of uploaded files as in our example, and you want to get the name of the current file (i.e., file $i in the sequence):


$fname = $_FILES['upload']['name'][$i];

The ['upload'] designates the array of all uploaded files. The [$i] pulls out of that array all of the information about one particular uploaded file, just like with ordinary array. The ['name'] gets the value associated with that key for that particular file. As $i is incremented, you get the name of each file. If you wanted the crazy-ass temporary name, you would put in tmp_name instead of name, and likewise for the other parameters.


if (!preg_match("/(gif|jpg|jpeg|png)$/",$_FILES['upload']['name'][$i])) {
        print "I asked for an image...";
    }

Next Me optionally checks the name of the uploaded file for a particular set of extensions in case you want to limit the uploads to images (as in Me’s example) or whatever. Me is using regex to do the work, a function for which I am doomed to a copy-and-paste understanding.


  if (@is_uploaded_file($_FILES['upload']['tmp_name'][$i])) {

Next Me does a check to make sure that the file was actually uploaded and is not the result of malicious code. is_uploaded_file is a built-in PHP function. The preceding “@” suppresses error messages; I don’t know why Me did that, but I’m confident it was the right thing to do. While you are debugging, you might want to take the @ out.


move_uploaded_file($_FILES['upload']['tmp_name'][$i], $upload_file)

If the file passes that test, then Me moves it to the folder s/he designated. Note that we’ve already put the pathname to the storage folder into $upload_file.

Obviously, where the script has the comment “Great Success” you would put the code that does what you want to do to the uploaded file. I have added two lines — commented out — that get and print the content of the file; that gets ugly if the file isn’t some type of text file.

So, please let me know what I’ve gotten wrong here. (And maybe sometime I’ll give you some truly embarrassing code for returning the results of the PHP on the page that has the upload form on it.)

7 Comments »

May 22, 2011

Remember what it was like to be dumb?

No, kids, you probably don’t.

I used to be a terrible, horrible, miserable hobbyist programmer. I enjoyed it a great deal, but land-o-lakes was I dumb!

I learned out of books, most of which are still bending the shelves they sit on. A good programming book is a pleasure. It teaches you the principles and the basic moves. But, programming is fun because it’s so specific. You need to measure the length of a line displayed in a particular font, or you want to set the opacity of a circle based on its diameter, and the book you’re using just does not happen to hit those examples. The time I used to spent guessing and poking around was not instructive and did not build character. It was simply what you had to do when you were dumb.

I am still a terrible, horrible, miserable hobbyist programmer. But my ability to solve problems, and, yes, eventually even to learn, has gone up orders and orders of magnitude because of three inter-related things:

1. All problems only arise the first time in a population once. Therefore, most problems have already been addressed by someone before you. They’ve either been solved by someone else or, if there are no solutions, someone has already discovered that.

2. It’s now so easy to make your work public

3. The hacker ethos has resulted in superb developers making their work available as examples and as entire libraries.

The second and third together has resulted in an enormous and public repository of questions, answers, examples, and explanations. (For example, see Rebecca Murphey’s introduction to JQuery…and then consider the centuries of engineering time libraries like JQuery have saved us. (Hat tip to ReadWriteWeb for the link to Rebecca’s book.))

4. Search engines are so damn good that we can find our way through that gigantic, unplanned repository.

You know every single thing I’ve just said. Still, it’s just good to remember now and then how amazing it is that we all know this as if it were always so. Especially if for you it has always been so.

6 Comments »

January 20, 2011

If you laid out all the shelves in Harvard’s libraries…

Mainly because I wanted to futz around with the Google Maps API, I’ve created a mashup that pretends to lay out all the shelves in Harvard’s 73 libraries on a map.

Screen capture of map
Click to go to the page

You can choose your starting point — it defaults to Widener Library at Harvard — and choose whether you’d like to see a line of markers or concentric circles. It then pretends to map the shelves according to how many books there are in each subject.

Here’s where the pretending comes in. First, I have assumed that each book in the 12,000,000 volume collection is one inch thick. Second, I have used the Dewey Decimal system’s ten subject areas, even though Harvard doesn’t use Dewey. Third, I used an almost entirely arbitrary method to figure out how many books are in each subject: I did keyword subject searches. Sometimes, when the totals seemed way too low, I added in searches on sub-headings in Dewey. At the end, the total was probably closer to 4 million, which means my methodology was 300% unreliable. (Note: Math was never my strong suit.)

So, the actual data is bogus. For me, learning how to use the API was the real point. If you happen to have actual data for your local library, you can download the page and just plug them into the array at the beginning of the page. (All the code is in the .html file.)

4 Comments »

August 2, 2010

The flatfooted learning society

I’ve been a hobbyist “programmer” since 1984 when I got my first computer. It was a KayPro, and, although I was a humanities guy with no computer background, from the first time a character I typed showed up on its screen, I was curious about how the damn thing worked. So, I started poking around. I ended up teaching myself SBASIC (a structured version of BASIC that came with the machine) and then some Assembler because SBASIC over-wrote the section of memory that contained WordStar documents I wanted to rescue from the machine’s frequent freezes. One of the pieces I’m most proud of as a writer is was my beginner’s tutorial on assembler, using my WordStar program (SaveStar) as an example, published in Profiles, the KayPro magazine.

Back in the old days, most of the time you put in learning programming on your own was spent being stuck. I remember in 1985 or so calling a random professor in Boston University’s computer science department after spending days and days unable to figure out something about file-handling in SBASIC; he didn’t return my call, and email was not an option. Now Google can answer just about any programming question I have, because as a perpetual beginner, my questions are rarely unique. Within seconds, you get a list of freely available code that you can just plug into your own project. Boom, done.

But not necessarily boom, smarter.

I “program” for two reasons. First, I enjoy it. For me, it’s puzzle-solving. I also like the sense of control over my environment. Of course, the environment is a hugely artificial, constructed environment. But, it happens to be the environment in which I spend almost all of my day.

Second, “programming” is a semi-practical pursuit. Over the years, I’ve written utilities customized entirely to my needs and preferences. In most cases, the time it took me to write the utility far outweighs the amount of time it saved me — usually by orders of magnitude. In a few cases, I’ve used the utilities for years, adding features until they are over-stuffed, hideous beasts. The best example is the blog editor I’m writing this post in. Some of the features — e.g., the color picker — were obviously needless additions, but I got interested in how to programmatically create a display of all the Web-safe colors. Other features never quite worked, but I’ve left in the UI access to them because maybe someday I’ll get around to fixing them. And some features are so useful to me that I don’t know why every blog editor doesn’t have them; for example, when I create a link, my editor remembers it and offers it to me the next time I select the same text. It also records how often I’ve used each link, information I’ve never looked at but it’s comforting to know it’s there. (Don’t tell me all blog editors do that now! I don’t want to know!)

There’s another dimension of the pleasure I get from “programming.” The Web is an incredible environment for the pure fun of learning. When it comes to software, you can almost always find an explanation that is just slightly over your head, so you’re stretched. You can do it in private, googling as many dumb questions as you want. (Note: Some questions are dumb. Believe me. I google them all the time.) Software development is such a deep, deep field that you’re never going to run out of things to learn. And, you get to actively observe a culture that is extraordinarily rich in norms, mores, and personalities.

But, I am a flatfooted “programmer” and always will be. I have limitations that would have kept me from ever becoming a professional. I have an odd inability to handle indirect relationships, e.g., pointers; I did fine with C, but bombed at C++. I have problems with recursion, so although I once did a fair bit of hobbyist Lisp “programming” (I once wrote a beginner’s guide to Lisp as a document extension language), I can’t handle the self-reflexive capabilities that turn Lisp into a super-tool for Paul Graham. I’m terrible at math. I simply could not have become a pro.

At the same time, as a hobbyist, the programs I write are also quite limited. They tend to be small. If they get biggish, almost always it’s because I’ve added more features, not because they’ve gotten more complex. They are for personal use. I am doing this in my spare time.

Give my limitations, the limitations of the programs I write, and the reasons why I enjoy “programming,” I think being flatfooted is a pretty rational approach. (Not that I have a choice about it.)

Let me be more exact. I write code that goes step by step through a process even when I know there’s a more efficient, more elegant way to do it. I do things the long way. I spell things out that could be abbreviated. Why? Because it’s easier to debug, it’s easier to figure out what I was doing if I go back to it, and my “programs” are so small that extra processing steps will not noticeably affect performance. For example, if I want to create an array that associates two values in Javascript, I’ll just create two arrays and keep them in sync. I know there are more elegant ways of doing this. But this way works and lets me give each a descriptive name. I also use too many globals, create functions when adding methods would be better, often skip jquery’s shorthand because I have trouble reading it, and have passed multiple variables out of a function by combining them into a single string with some unique delimiter between them.

So, I am flatfooted. Pedestrian. A literalist. Without grace. Inelegant. Inefficient. Wasteful. Taking long cuts. It’s embarrassing. I see the leaps professionals make, and I am awestruck. It’s like watching aerialists at the circus while you’re schlepping back to your seat with root beer stains on your shirt.

Nevertheless, I want to encourage my fellow flatfooted beginners. Since I’m “programming” almost entirely in Javascript these days (and loving it), there’s no problem finding tutorials and helpful guides. But, when you have a specific problem — some bit of functionality you can’t figure out how to create — you are often dropped into a geek-on-geek world that assumes the person asking the question understands more than beginners like me do. The code can get so compressed, so efficient, so elegant that it can be just about impossible for someone like me to understand. Real programmers of course should and will explain what they do in their own terms, and with the most advanced techniques they can create. That’s why beginners like me should share more of what we do. We don’t do it as well, but we can often learn from one another better, even though it means exposing flatfooted code to a world of professionals with wings on their ankles. And the especially kind ones will swoop down now and then to set us straight when we’ve gone too far wrong.

11 Comments »