Sunday Selection 2013-05-05

Happy Cinco de Mayo and Orthodox Easter everyone. Last week has been a bit quiet as far as reading is concerned. I have a hefty backlog in my RSS that probably won’t get cleared till next week. But here’s the pick of what I did read and discover:

Around the Web

10 Rules of  a Zen Programmer I’ve been doing meditation on a regular basis over the past few weeks and it’s been an interesting experience. I definitely feel calmer throughout the day and it’s getting easier to sit down and focus on tasks I would normally procrastinate on. This article agrees closely with both what I’ve been experiencing while meditating and as a programmer. I’m not a Zen practitioner, but you don’t have to be one to use the information this article provides.

I’m still here: back online after a year without the Internet This is the last (I think) in a series of articles by a journalist who spent a year offline. It’s an interesting read, though it ends on a very weak note. The author’s experience seems to agree with my own views on the matter: the Internet (and technology in general) is a tool and it’s up to us to use it best. Using it, or not using, is not suddenly going to make us a better or worse person. It’s up to us to use these tools according to our desires and help realize our potential.

Star Wars: Online review culture is dotted with black holes of bad taste This articles looks at the rise of popular review sites (focusing on Yelp and Amazon) and discusses how the reviews on these sites are often less then helpful to the point of negating the importance and usefulness of a review. There’s research going on at Cornell on better analyzing online reviews and review systems so this article was particularly interesting to me. While there’s something to be said for the usefulness of multiple opinions from different viewpoints, sometimes you just want an authoritative answer from an expert about the quality of a service and product, and that’s increasingly difficult to come by.

Software

Tomato.es As the end of the semester approaches and the amount of stuff I have to get done explodes, I’ve been starting to use the Pomodoro technique to keep on top of things. Tomato.es is a simple timer that counts off 25-minutes intervals. If you sign in using Twitter or Github, you can keep a record of what you’ve been doing in those intervals.

Rust to OCaml via FizzBuzz

Last month fellow PL grad student Lindsey Kuper wrote a post about the Rust programming language and used the FizzBuzz problem as a running example to demonstrate Rust’s pattern matching features. While reading the post what was struck me was the resemblance to the OCaml language. After reading the post I sat down and ported Lindsey’s code to OCaml. The resulting code is on Github as a gist, feel free to take a look and fork away.

Lindsey’s Rust code and my OCaml code look practically identical (modulo syntactic differences like braces and semicolons). Both languages seem to support similar basic types and matching on them. I haven’t looked into Rust into any detail, but it seems like an interesting language. I’ve been using OCaml a fair amount over the past few months and I’ve come to miss its type system and pattern matching when working in other languages. I’m looking forward to seeing those features in a systems programming language and am particularly curious about how it will interact with an object syntax. There’s a big tutorial with lots of interesting stuff, so I’m looking forward to more exploring.

For your convenience, here’s the OCaml code:

Sunday Selection 2012-04-28

Around the Web

Minecraft, Scrolls, 0x10c: The past, present and future of Mojang as seen through Notch’s eyes. I’m not much of a gamer, but I do like making cool stuff and I love reading about people who are making amazing, beautiful things. Notch is the creator of Minecraft and the anticipated 0x10c and this interview is full of interesting tidbits.

The Terrifying Reality of Long-term Employment As a recent college graduate who has chosen the temporary sanctuary of the ivory tower, the job market is something I can afford to avoid, but it’s still something at the back of my mind. The state of the current market makes me wonder if we need to rethink jobs and value structures in an age where long-term stability is increasingly rare.

The Boston Marathon Bombing: Keep Calm and Carry On. I usually don’t write about current events, partially because I’m never quite sure what to say, and partially because I’d rather not add to the noise if I don’t have something useful to say. That being said, I’m all too happy to point in the direction of people who I think are actually making level-headed and rational comments about the current state of affairs. Bruce Schneier is certainly one of those people and I can’t help but wonder how different the world would be if people like him were in charge of our security.

Software

Capsule: The Developer’s Code Journal. I find that keeping a record of things I’ve done through the day is very useful. It’s a good estimator of where my time went through the day, and an empty log is a sign that things didn’t go quite right.  I normally have a text file on my phone that I just dump everything into. Capsule looks like an interesting solution for programmers (both teams and individuals) to keep a quick and dirty log of what they’ve been up to. I’m probably going to put it on my Linode for a week and give it a try.

Amazon has good customer service

Last week I realized I didn’t have a single usable USB Flash drive. So what do I do? I hope on Amazon and order myself one of course. I got this nice Kingston 32GB drive that looked small enough to fit on my keyring and spent a few minutes in awe of the fact that this tiny thing had more capacity than my first computer’s hard drive (a paltry 20GB).

I ordered it on April 15 at night and since I have Amazon Prime, I got an estimated delivery date of April 18. Unfortunately, the 18th came and went and there was no sign of the package showing up. The tracker on Amazon said that the package had “left the seller” on April 16 but had made on progress since then. Since this was the first time Amazon had been late with a package, I decided to give them some slack and wait a few more days. On Monday, April 21, there was still no sign of the package so I decided to contact and see if I could get some answers.

Once I found the Amazon Contact Us page I was glad to see that there was a live chat option along with the usual phone and email option. The chat experience was really smooth. After some simple questions to narrow down the problem I was talking to a real human (I think) within a few minutes. Once I told them what the problem was, they checked on the package status and immediately offered me a free replacement or refund, without even asking. I went with the replacement and today the package showed up at my doorstep. The process was smooth and quick and entirely without fuss. It’s definitely one of (if not the) smoothest customer service experience I’ve ever had.

It wasn’t perfect: the orders page has options to Track, Return/Replace Items, Leave Package/Delivery Feedback or Write a Review. There’s no way to say that the package delivery seems stuck. Under the Delivery Feedback I can say that I haven’t received the package, but it just tells me to leave more feedback when I get it. It would be great to actually have an option to say that there’s something’s wrong with the delivery and I want Amazon to look into it. Secondly, while the whole contact process was smooth, it was hard to find the contact page in the first place. There doesn’t seem to be a contact button or link on the main Amazon page or site and there’s nothing of the sort on the Track Orders page either. I had to Google for “Amazon contact” to find the page. It was smooth sailing after that point, but it’s definitely something I wish was smoother.

Anyways, the point is that I had a smooth customer service experience with Amazon and though there are rough spots, it was very good on the whole. Now I’m going to stop talking about my first world problems and get back to hacking in OCaml.

Breakfast

Note: This is a boring personal-ish post while mainly to help get back into the habit of writing regularly. If you’re not interested in what I had for breakfast (literally), please check back next week when I’ll have something more interesting to say.

After a few months of trying I’ve managed to get into the habit of making and eating breakfast everyday. A healthy, high-protein, slow-carb breakfast takes me about 20 minutes to cook, eat and clean up. This includes setting up the coffee machine at some point (but drinking the coffee takes a bit longer). 20 minutes is about the length of one episode of any number of TV shows. My choice so far has been the US version of The Office so far. But a few days ago I cancelled my Netflix account for a variety of reasons, not the least of which is wanting to watch less TV. While I’m glad to have the $20 (and the uncounted hours) of savings per month, it leaves the question: what do I do during breakfast?

I could do nothing — just cook and eat breakfast without anything else, but that’s not really my style. While I’m all for being comfortable with solitude, making and eating breakfast in complete silence, all by myself, is a bit much. At the same time, I do enough reading and writing each day as is and I don’t really want to do more of it first thing in the morning. What I would really like is some kind of semi-passive activity that doesn’t shut down my brain in quite the same way that TV does.

To that effect, I’ve been thinking: podcasts. Unfortunately my knowledge of podcasts is pretty limited. I used to listen to some technology podcasts a few years ago, but that kind of thing no longer interests me. (I’d rather be working on the cutting edge of tomorrow’s technology than keeping up with the latest Apple product or Valley startup.) I’ve subscribed to some podcasts that friends have mentioned including NPR Technology, Freakonomics and Debbie Millman’s Design Matters. While I like each of them, they’re generally much more than 20 minutes and usually vary in time. While I enjoy listening to longer podcasts while doing chores and such, my mornings are usually pretty tight and I don’t want to spend more than 20-30 minutes on breakfast related things.

So it’s audience participation time: what are some interesting podcasts that don’t have a popular tech or productivity focus and are reliably 20 to 30 minutes in length? Failing that, what are other mostly passive things I could be doing over breakfast?

What do you do to break a creative block?

I’ve been wanting to get back to blogging for a while now. Unfortunately a combination of graduate student life and not wanting to spend even more time than I already do in front of a computer has made me put that off. At the same time, I’ve been having some bursts of activity on Quora. I think Quora is an interesting site and serves a a good purpose, but I’m not very happy about its Walled Garden policies and I would like the information I put in to be more generally available (at least the stuff that doesn’t involve the more obscure points of Tolkien’s legendarium). So for today at least I’m going to report an answer I wrote up while i was waiting for my experiments to finish.

The post asked about overcoming creative block, in particular writer’s block. The poster said that time was sometimes, but not always a factor and that s/he had been writing quite prolifically before. (The previous sentence made me realize that English desperately needs a gender-neutral third-person pronoun that isn’t ‘it’.) Given my blogging predicament, I avoid this uncannily relevant. Anyways, without further ado:


Personally I’ve found that what helps is a combination of three things: good routine, new experiences and boredom.

First, routine.  If you’re having trouble getting time to write, or trouble sitting down to write even when you have time, a strict routine can definitely help. As Somerset Maugham supposedly said : “I write only when inspiration strikes. Fortunately it strikes every morning at nine o’clock sharp.” Find a quiet space, free of people and distractions, grab some coffee (or tea, or just water), turn off the Internet and your phone and just write. Write anything. It doesn’t have to be in your preferred genre or what you’re trying to write. It can be an essay, a journal entry, a letter to friend (or an enemy). The point is just to get into the habit of writing. Once you’re comfortable with sitting down for some time each day and just writing something you can move on to what you actually want to write.

Second, experiences. If you’re going to be a serious writer then it helps to have things to write about. While it’s definitely possible to create interesting by isolating yourself in a cabin in the woods (see Walden by Henry David Thoreau), I think it’s a safer bet (and far more interesting) to gather lots of interesting experiences and ideas and weave them together in interesting ways. Travel new places and keep your eyes, do things you thought you’d never do, talk to people you normally don’t interact with, eat foods that look strange and unfamiliar, look up random topics on Wikipedia, explore a new subject each month. The more ideas you have in your head, the easier it will be to have things to recombine and use as a basis for interesting writing.

Third, boredom. As a complement to the above, as you’re gathering experiences you need to have the time and energy to put them together. Spend a Saturday on the couch (or the hammock if you have one) with the TV off and without any people around. Stand in the checkout line and just stand. Get bored sometimes, don’t rush the mindless things like doing the dishes and vacuuming. You need to put interesting things in your head but you also have to give yourself the chance to let them interact and recombine. This part is often hard to do because you feel like you should be doing something productive, but I believe this stage of just letting ideas percolate and react is crucial to any creative activity.

Finally, to make the most of the above: carry a notebook and pen always. It doesn’t have to be a fancy Moleskine or anything of the sort. It just needs to be something where you can record interesting experiences and ideas and look back on them later.

Good luck and good writing.

Coding standards are communication tools

I’ve been writing a lot of C code over the past few months. It’s been fun and I’ve learned a good amount about writing solid, low-level, procedural code. While cranking out code I’ve also been developing a simple coding standard, mostly for my own use and based on on the K&R standard. I’m not working with a particularly large group (and probably won’t be anytime soon) so I won’t be asking anyone else to follow these standards anytime soon. They don’t follow the rest of the code 100% either. But even being essentially the lone hacker on the project, I’ve found sticking to a standard helpful.

C is a great language but often I want to say things as part of the program that I can’t put in the code. For example, there are often things about variables that aren’t captured by the type and even if they are, I don’t want to have to look up the type every time I see the variable to get that information. But by following simple rules about how my variables are named, I can pack in a lot of information. For example, a plural name is an array, a name prefixed with num_ indicates that it holds the number of something in the system, a name prefixed with rv_ means that it stores the return value from a function (probably for error handling). Outside of variables, function names are verbs, locally defined types meant to be private are CamelCased, exposed types have a _t suffix. Of course, these don’t apply in all cases and some amount of discretion is involved.

Following a standard like the above has a double benefit: first I can think less when it comes to naming things and it prevents casual naming conflicts. Secondly, as I hinted to above, it’s a communication aid. There’s a certain amount of information that is encoded into the language’s syntax and semantics. This layer is checked and enforced mechanically at compile time. But a coding standard allows for a secondary, optional layer that can convey more information without expanding the language standard (and allowing teams and individuals to develop their own, suited to the task at hand).

Note that I’ve mostly talked about naming conventions and I haven’t said anything about formatting. Personally I think formatting conventions are less important and helpful. It can be annoying to read code that is formatted differently across files (or in the same file), but I think the benefits to be gained from consistent formatting are less than that for consistent naming. In fact, I think that formatting issues should be eliminated by having a tool that will automatically reformat code to a single standard. I have the Go language’s gofmt tool in mind, but I’m sure there are others. (This is also one of the pet peeves I have with Haskell: it’s apparently really hard to write an auto-indentation tool for its syntax)

One caveat is that I have no personal experience as to what effect a coding standard has across a large group. I’ve found two articles arguing against coding standards on teams, but they’re both far too emotional and hand-wavy for me to take them seriously. Personally I would be wary of a developer who can’t adapt to a coding standard in a reasonable amount of time. That being said, there are definitely more important things than adhering to a standard (getting working code for one). However, I do think that coding standards fit into a larger culture and system of good coding practices. These include things like code review, appropriate use of version control and proper communication channels to talk about bugs and feature changes.

To conclude, a coding standard can be a great tool for personal uses. In some ways it frees up my limited mental RAM to think about more important things. It also allows me to pack more information into my code, outside of what the language syntax or semantics allow. I’m less certain of the benefits for large groups and as Emerson puts it, a foolish consistency is the hobgoblin of small minds. That being said, I’d like to believe that a good coding standard (with formatting mechanically enforced) along with practices like code review can lead to a higher code quality.