A programmer’s nit-picks

Programmers are notoriously nit-picky. We have opinions, stances, and preferences on just about everything and tend to get into frivolous (and often heated) arguments and discussions about our nit-picks. Compiled language vs. interpreted language? Nit-pick! Tabs vs. spaces? Nit-pick! Braces on same line or new line? Nit-pick!!!

In fact, programmers are so passionately nit-picky we invented a process to force our nit-pickyness onto others when they contribute code to our open source projects: code reviews! We even prefix some of our comments with “Nit:” for emphasis! (Do understand I am using hyperbole here. Code reviews are a good thing and I am grateful for them.)

Lately I have been reading the book RailsSpace (1st edition website) to expose myself to the Ruby programming language, Ruby on Rails, and MVC. I am not actually running any of the code, simply reading the book, code and all. It has been rather interesting and I may have to write a post on the experience when I finish it.

As I read through the book, I came across a code snippet containing something I (and many other programmers) are nit-picky about. Allow me to post the relevant lines:

if (redirect_url = session[:protected_page])
  session[:protected_page = nil
  redirect_to redirect_url

Do you see the nit-picky statement? It is the redirect_url assignment in the condition. Some programmers (maybe you) like or do not mind it because it makes the code more compact. Others dislike it because it can be easy to miss and makes grepping the code harder. Coming from a Python background, it looks strange to me because Python does not allow it. Because of this, I do not use it in my JavaScript and would have it removed if it came up in a code review. Why? Because I nit-pick about it.

What about this paragraph from a little earlier in the book?

Parentheses are optional on Ruby methods, including those that take no arguments. If you want to, you can certainly use parentheses… This might make you Java/Python/PHP programmers out there happier, since user.save might look a little too close to a class attribute… On the other hard, leaving off the parentheses in this context is very Rubyish…

Upon showing this and some relevant code to a few programmers, none of whom have ever programmed in Ruby, by the way, they all shuttered. The very thought of no parentheses to call a method irked C, C#, Java, Python, and JavaScript programmers all alike. Why? For starters, each person’s primary language requires them. Secondly, our minds are not trained to think that way nor are we experienced in Ruby, so we negatively nit-pick about the language’s features and abilities.

One more example. I personally like the white space in my code to be clean. This is imperative in Python, as one extra or missing space at the beginning of a line will kill the whole script. Although I also program in JavaScript, a generally white space-ignorant language, I still keep my white space clean and neat. Why? Because I nit-pick about it. I like my white space clean. I like everything even and consistent. If it is my project, I maintain it according to my standards, and I have called it out in code reviews before. I am confirmed nit-picky about white space.

I talk about my personal nit-pickiness because, from my limited observations and experiences, I have found it is a programmer’s nit-picks that greatly define their coding style. The majority of programmers are passionate about their work, style, and beliefs, hence the aforementioned heated arguments. Programmers also have their own preferences. Two people can learn how to program from a single instructor, or one person can work closely with another on a project and learn from the more experienced. For a while, each student will follow the same style and have the same preferences as their instructor, but given enough time and code, they will begin to develop their own style and preferences. In the same manner, inherited nit-picks will change, be removed, or added to.

Just as our clothing style defines how we dress and our environment affects our frame of view, so preferences and nit-picks define our programming. I like casual, relaxed clothing, so I prefer wearing a nice polo shirt, dark blue jeans, and low top Converse shoes. Someone who lives in a large city may believe working from home is an important factor in a job opening more than someone who lives in a small place. In the same token, because I began programming in Python, Where Whitespace Will Work Well™, I like my white space to be clean. I run linters and set my IDEs to display white space so I can ensure everything is consistent and satisfies my nik-picks.

One thing we do need to be aware of is the personal nature of nit-picks. Something I nit-pick about may hold no bearing on you. As we all have opinions, so we have nik-picks. Just because someone does not share the same nik-pick as you (and some person that must be to not agree with you on these trivial matters!) does not give permission to bombard them with broadcasts about your perspective and how they are wrong. In the end the only person that cares about the nik-picks is yourself. Thus we should be respectful of each other and their different perspective on the matter (although yours is obviously the best).

We hear all the time we ought not to nik-pick, as it can be rude, impolite, and inconsiderate. While I agree with this life rule of thumb, maybe we need to nit-pick a tiny little bit. Maybe we need to have passionate debates with random people on the Web over insignificant matters. If we do this a little bit while respecting others perspectives and opinions, we can build a solid foundation in knowing what you know in important life areas (what cut of socks you prefer not being one of them).

-Caleb

Advertisements

Triangular Reactions

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s