Filed under Programming

Grit for Programmers

It turns out that the best indicator of success isn’t IQ or natural talent or how well off you were at birth. Rather it’s something called grit – the perseverance and passion for long-term goals. Grit requires a clear goal, self-confidence and a careful balance between stubborness and flexibility. For the last few months I’ve been living one of the most productive (and most challenging) times of my life. I’ve been building a system that has more parts, does more things and is much larger than just about anything I’ve built before. It’s been challenging and rewarding work and I couldn’t have done it without lots of support from great mentors. As I’ve stumbled, fallen down, hit brick walls, picked myself up and kept going I’ve been wondering – does grit apply equally to programmers and success in building good software?

Programming culture is generally synonymous with hard work and long hours — death marches, all-nighters, 80 hour work weeks, we do them all. But we’re talking about grit here, not masochism. Grit isn’t strictly equal to working obscenely hard, long hours. Part of the problem with thinking about grit in relation to programming is defining what success means for a programmer. Is your definition of success simply finding a working solution? Does it mean finding the most efficient solution? Are you successful if you cover every single edge case or is it enough to just take care of the most common ones? Is your program really better if it handles everything you could throw at it or should you handle core uses cases well and fail gracefully on the others? Part of the problem of coming up with a good solution is asking the right question. This is especially true of building software. However merely coming up with the right question requires a certain amount of grit. We need the patience to look beyond the obvious problems and solutions and ask the hard questions.

So now we’ve found the right question and defined bounds on the possible solutions. What next? How does grit help with the actual act of writing code and building stuff? Programming is not easy. It can be fun and exciting and uplifting, but sometimes it is downright hard and depressing. Sometimes we spend hours sifting through possible solutions before hitting upon the appopriate one. Sometimes we spend several intimate hours with a debugger tracking down pointer bugs before finding that one variable we forgot to initialize. Being tenacious and persistent in the face of seemingly unrelenting roadblocks is not an added benefit for a programmer – it is a bare necessity. When it comes down to the act of sitting down, writing and debugging code grit is not optional. Without it not only can we not be good programmers, we can’t even be an average ones.

But if our goal is to be a good (maybe even great) programmer, then grit will continue to help. One of the qualities of good programmers is that they get a lot of stuff done. In particular they do a lot that isn’t strictly their job. This includes fixing and extending their tools and improving core infrastructure. They do this even if they aren’t in charge of infrastructure because they realize that their code depends on what’s underneath. Grit is the difference between waiting for someone else to fix the annoying bug in the library that you depend on and diving in and fixing it ourselves. When Steve Yegge talks about the difference between “superhumanly godlike” and “smart”, grit is a part of what he’s talking about. Not that there’s anything wrong with being smart, but it might not be enough. Of course to cultivate that level of grit we need to cultivate a good deal of courage. Diving into someone else’s code and fixing it can be a daunting task but it’s one that has to be mastered.

While I’ve always liked programming it’s taken me a long time to understand the importance of grit. When you do something because you like it (mostly) it’s tempting to stay away from the parts that are painful and hard. For a long time I avoided writing large programs because I was afraid of all the complexity that was involved. I was afraid of becoming familiar with complex algorithms because I was afraid of the possibility that I’d get it wrong. I understand now that I can’t become a good programmer if I don’t push myself to do the things that I consider hard and dislike. I need to have the grit to handle large complex problems and spend the time to understand and apply advanced algorithms. The good news is that just like perseverance and discipline, grit can be trained and improved. I’m no longer as afraid to dive into unknown codebases as I was a few months ago. I now find it much easier to hold complex code paths in my head. I’m certainly far, far away from being superhuman, but I try to suck a little less every day.

Tagged ,

Predicting Human Intent

Readability is one of my favorite web services. Readability is well designed, carefully made, unobtrusive and they’re not trying to wring me of personal information to datamine and sell at every turn (at least I don’t think they are). Their web service gives you browser plugins that strip out everything but the content of a page and present it in a clean, crisp format. If you sign up for an account you can make use of their “Reading List” to store pages for later reading. Recently they released beautiful iOS and Android apps that sync with your reading list allowing you to stock up on things to read at your computer and read them on the move.

Though Readability is a great service and they have great supporting apps they have one flaw. However, it’s not entirely their fault: I think it’s a side-effect of the difficulty of predicting human intent. The problem has to do with Readability’s reading list. When you install the browser plugins you get three buttons: a “Read Now” button, a “Read Later” button and a “Send to Kindle” button. The “Send to Kindle” button formats and sends the web page you’re on to your Kindle (assuming you’ve set up and connected your Kindle properly). The “Read Later” button saves the page you’re on to your Reading List which can be synced to your iOS or Android devices. The “Read Now” button will do the Readability formatting on your current page and show you the cleaned up version right then for you to continue reading.

That’s all great. However, the “Read Now” button also drops the page you just converted into your Reading List. This is great if you start reading a long article and then have to leave your machine. You can come back to it later, on another browser or another device entirely. But what happens if you finish reading the article right there and then? The article still ends up in your reading list. That would be fine if the list was simply a history of things you’ve read. However the Reading List is also a list of things you’re going to read. So the Reading List now contains things I’m going to read, things I’ve read and things I might want to read again. I think this problem stems from the fact that Readability started as a formatter and added read-later functionality unlike services like Instapaper which are designed for savings articles for later.

How can we differentiate between all these types of articles? Readability provides the ability to “Archive” and “Favorite” articles. Once I’m done with reading an article I Favorite it if I’m going to read it again and Archive it otherwise. But could Readability do this for me? Could Readability somehow figure out what I want to happen to the article? The simplest solution would be to archive whatever I Read Now and only add to the Reading List ones that I mark to Read Later. However that means that if I start reading something and then have to leave it ends up in the Archive where I might never look at it again. Could Readability be a little smarter? One heuristic would be to check where I am in the article. By default an article is always added to the Reading List as it is now. But when I scroll to the bottom Readability takes that to mean that I’m done reading and moves it into the Archive. If I liked it and wanted to come back to it I manually mark it as a Favorite. (I don’t expect Readability to be that clever. Yet.)

Without having actually tested the solutions, I can’t say how well they would work. There are certainly edge cases: what if I scroll down to read a footnote and then scroll back up to read the rest of the article? What if I get to the end and then go back to re-read a particular section? What if I quickly skim through an article to get to the end and want to come back later to read it in more depth? I think there’s no clear answer because fundamentally we’re trying to have Readability “guess” what we’re trying to do without giving an unambiguous signal. Sure, all of them could be solved with a few manual interactions. But the whole point of having advanced software is so that I don’t have to tell my computer what to do in excruciating detail.

Like I said at the beginning I don’t think that Readability is necessarily at fault for how their service works. Any attempt to automatically manage the Reading List would require making some assumptions as to what it is the user wants to do. Even if those assumptions are right most of the time, there will almost certainly be times when they’re wrong. We are, after all, dealing with people here, and people aren’t perfectly predictable agents. If they were, human computer interaction and economics would both be very different fields.

Predicting human intent is a hard problem. Ultimately, some amount of direct intervention might be inevitable. While Readability is meant to be a product it would be interesting to see researchers using it (or similar services) for doing research with real users about how our software can make choices for us in a way that closely reflects what we would have done ourselves. Unlike some people I don’t want my software to do less and have fewer features. I want it to do more so that I can concentrate on more important things. Like saving the world.

Etudes for programming

From Wikipedia:

An étude (a French word meaning study, French pronunciation: [eˈtyd], English pronunciation: / ˈeɪtjuːd /) is an instrumental musical composition, most commonly of considerable difficulty, usually designed to provide practice material for perfecting a particular technical skill.

I noticed today that Michael Fogus (one of the authors of Joy of Clojure) has a number of Github repos with names such as etude-ocaml and etude-syntax. I also realized this week that I’m a pretty slow programmer. I’ve been getting better over the years but I’m still slow, especially if there’s a good amount of API design involved. While I think that writing lots of code will make me faster over time, I do wish there was a more structured, focused approach.

In general, I wish there was more by the way of études for programming — problems and exercises of considerable difficulty designed to provide practice material for a particular (set of) skills. There are of course great textbooks for programming and computer science and those books have good exercises (I particularly like SICP and the K&R C book), however in most of those cases the point is to teach first and practice second. What I’d like to see is the reverse – assume that the reader already knows about functional programming or the C language but needs to “level up”, so to speak. The exercises would be harder and more in number but would also cover a broad area in terms of application of the concepts involved.

This is related to what I’ve written earlier in terms of deliberate practice for programmers. That post talks about “level up” lists – a list of programs to make that help explore the different areas of computer science and help you gain experience and hence “level up” as a developer. On the other hand études would focus on depth rather than breadth – each one would focus on a small technique or technology and fully explore that area. Together a continuous habit of working on études and doing level-up projects would give programmers a steady stream of deliberate practice exercises to work on.

The question is, where are we to find these études? I’m not sure if there are programming books out there that fit that description. If there are, I’d love to here about them. But in the meantime I’ve found an acceptable alternative — homework and assignments for college level courses. This semester I’m the TA for a course on functional programming and throughout the semester we have a set of 6 assignments for students to do. Each of them have about 3 to 4 problems (each with multiple parts) that tackle a small area of functional programming. I think exercises like this are great material for études. I’m currently working through the exercises at the same time as the students (other TAs are making them). Even though I’m already familiar with most of the material it’s been a good learning and great practice for me. I can’t really measure if I’m improving (apart from running my solutions through the test harness) but it’s more direct and practice in functional programming that I’ve ever had.

I’ll be done with this particular étude in a few months. I don’t think I’ll be releasing the code since the problems often get reused. However I do think there will be lot more where those came from. There are lots of college courses with website out there and there’s lots to learn. I’ll probably try compilers next. All that being said, it would be great to see some curation and collection. With Amazon’s Kindle Shorts and the growing interest in short, self-published books putting together a regular series of études might be a pretty lucrative endeavor.

Tagged ,

How much do environments matter?

The last week and a half has been really productive. I’ve written a lot of code, made progress on my research project and learned a lot of stuff in the process. Unfortunately it’s all been in one area, but that’s a matter for another post. But given how productive I’ve been one thing that I’ve been wondering is how important an environment really is to productive.

I’m usually of the opinion that environment (both physical and in terms of setup) is really important for any sort of creative or intellectual work. However I’m not quite so certain anymore. My current working setup is less than perfect. Though I have a nice DIY standing desk and a brightly lit office I also share the office with six other people and at times it can get pretty busy and crowded. I have a very powerful work machine but most of my recent work has been in a basic Ubuntu virtual machine with no customization other than my Bash and Emacs setups.

Despite the fact that my environment is not perfect the last week has probably been the most productive I’ve had all year. This begs the question: are environments really as important as I had thought they were? Or is it sufficient (and necessary) to have a project you’re really interested in? Of course, I understand that this is a personal question, so I’m just going to try it for myself.

What I’m starting to think is that the environment doesn’t need to be perfect, it just has to be “not painful”. There are some things that I just can’t stand: I can’t stand bad chairs, environments that are too noisy or too high of a room temperature. But once I have air conditioning, a standing desk and decent set of headphones I can quite easily tune out everything else. Similarly, once I have a command-line UNIX environment and a decent enough keyboard I care much less about what window manager I’m using, what size my monitor is or even what my language or toolchain is. Once I’m in the zone there’s very little that I care about.

I would say that environments matter, but only to some extent. After a point an interesting and exciting project can easily make up for any deficiencies in the environment. However, the opposite – a great environment but an uninspiring project – hardly makes you want to jump out of bed in the morning and get to work.

In addition to my Macbook and my work machine I have a small Eee PC lying around with a bare bones Arch Linux install on it. As a small experiment I want to see if I can be as productive on that machine as I am on my work machine. In addition to my research project I’m taking a programming languages class and TAing a functional programming class, so I regularly find myself in the mood for some OCaml hacking. Admittedly it won’t be a scientifically controlled and rigorous experiment, but it will be interesting to see how far an interesting project can compensate for a less then ideal environment.

Crystallized Archetypes

Manuel Simoni writes a very interesting (and brilliantly named) blog on programming languages entitled The Axis of Eval. For almost two years now he’s been delving deep and wide across the field of programming languages. He was interviewed by the State of Code blog a few months ago. I read something in that interview that has been lurking on and off in the back of my mind:

I think Lisp is the archetype, the crystallized form of all dynamically-typed scripting languages, and for that reason I like it. I also like C and Haskell, because they’re similarly crystallized languages in their respective areas.

As I study more about languages, and use a growing number of them on a regular basis, I can’t help but think: what are some of the other crystallized archetypes of languages out there?

Let’s start with Manuel’s list. Lisp stands out as the archetype for dynamically typed scripting languages. Other similar languages (Perl, Python, Ruby and the like) all emulate bits and pieces of Lisp (with varying success). Each new scripting language that becomes popular seems to be just a little more Lisp-y. Haskell is then the archetype for statically typed, functional programming languages. One could argue that this title belongs to OCaml or the various other MLs. From my experience working with them both occupy very strong points in the space of statically-typed functional languages. Which one you choose depends very much on what your particular needs are.

On another level entirely resides C. While both Lisp and Haskell strive to help you create elegant towers of abstraction, C will happily lay open the bare hardware for you. C is your archetype for a low-level systems programming language for a von Neumann machine. There’s certainly a new generation of systems programming languages waiting in the wings: D, Go and Rust to name a few. Though I have limited experience with any of them, from what I can tell they are all a few layers above the machine. While that’s certainly great for programmers (and I hope it picks up speed) if you want to get down into the guts of your computer you’d better reach for your C compiler. If you have more experience on this front, feel free to enlighten me.

While Java and C++ might have introduced much of the world to object-oriented programming, the title of archetype almost certainly goes to Smalltalk. While Lisp can play host to a powerful object system and OCaml goes far towards combining OO and functional programming, Smalltalk stands out as being object-oriented from the bottom up, so to speak. Of the modern popular languages, Ruby is probably closest to the Smalltalk way while still being a scripting language for Unix-like systems. I’ve only done a tiny bit of Smalltalk programming myself (and certainly haven’t made a large system) but it’s definitely a very interesting experience. I don’t know if there’s an ‘aha moment’ like there is with Lisp, but I highly recommend it if you write OO code regularly.

While those four cover most of the ground for popular programming paradigms, there are a handful of other interesting archetypes out there. For concatenative programming I’d recommend Factor. Similarly, Prolog stand for declarative, logic programming. I’m hesitant to name archetypes for web or distributed programming. Personally I think of JavaScript as more of a prototype-based OO language that happens to be in the browser than as the archetype for a web programming language. Somehow I feel like we can do better than the HTML, CSS and JS trifecta we have now.

As I keep learning about languages, I’m looking forward to exploring these archetypes in greater depth (and their particular instantiations). I might even try implementing a few of them. So much to learn, so much code to write, so little time.

Follow

Get every new post delivered to your Inbox.

Join 338 other followers