The Importance of Knowing Your Language – Micro Edition

I was reading about “fast” vs “slow” programmers and came across the assertion that there’s no such thing as fast or slow programmers given the same coding activity. And that being able to find an example of the same/similar problem. And solving the right problem.

I agree that being able to find an example is important. But knowing the language/API well saves a lot of time. As an experiment, I solved the same problem in Java (which I know fluently and use almost every day) and Python (which I know enough to cobble stuff together and don’t use often). As a “handicap”, I used vi for both so the IDE wouldn’t make me faster in Java.

The problem

Read a file and remove all the lines that have “slow” in any case.

Java

This took me just under 4 minutes. About half of which was spent looking up the imports and dealing with stupid stuff the IDE would have handled (throwing the exception and mispelling “output”

The solution:

import java.nio.file.*;
import java.util.*;
import java.io.*;

public class Process {
  public static void main(String... args) throws IOException {
    Path input = Paths.get("input.txt");
    Path output = Paths.get("output.txt");
    List<String> lines = Files.readAllLines(input);
    lines.removeIf(s -> s.toLowerCase().equals("slow"));
    Files.write(output, lines);
  }
}

Python

The same task in Python took just over 7 minutes.

The solution:

input = open("input.txt", "r")
output = open("output.txt", "w")
for line in input:
  if  line.lower().strip() != 'slow':
    output.write(line)

input.close()
output.close()

Conclusion

I didn’t become a slower programmer between writing the Java and Python examples. But I was slower. Because I had to look up more in order to accomplish the task. Someone who programs in Python more often could have whipped it out faster.

I’ve interviewed people who couldn’t have done it in either language in under 10 minutes.(I don’t ask this question at interviews but I have questions of comparable difficulty).

Plus people think and type at different speeds even if they know everything without looking anything up.

And a Funny Story

I was pair programming with a junior developer recently. When he was typing, we needed to read a file and do something with the contents. As evidenced by the above, I’m very familiar with the idiom for reading a file. When he said, “I’ll google reading a file”, I asked to take a turn at the (virtual) keyboard. As I typed the Path/readAllLines() idiom, I commented, “I”ll be google”. I have full confidence my teammate could have Googled this. And that he would have gotten correct code. But it was faster for me to type it. And he still got to observe the idiom either way. (Plus my way didn’t risk him finding the pre-Java 1.7 way and learning that)

trying out toodledo

I have too many things going on my free time that I’m outgrowing my current “task management system” (a whiteboard and pieces of paper.)  A few years ago, I started using a portable calendar to keep track of dates/times which helped and moved a few to dos to it.  But that doesn’t even begin to cover it so I’m left with pieces of paper.  I’m spatial with my to do list so I was resisting an electronic list.  Now that it isn’t working anymore, it is time to switch.

A year ago, I tried the GTD plugin for gmail.  I used it to clean out my inbox, but didn’t stick with it.  I think it’s because I don’t manage all my tasks in email.  And I don’t want to.  Now I’m up to the next attempt which is to separate my e-mail and todo list.  Not sure if I want to actually follow GTD yet.  After some preliminary research, it looks like I needed to choose between Omnifocus and Toodledo.  Technoramble had the best comparison of the two.

Criteria I thought were most important to me

  • Be able to enter tasks on subway/train – sounds like both are ok with it.  Even though Toodledo has a web interface, it does have an iPad app.  And it lets you e-mail new tasks to a separate email to be automatically entered.  And Omnifocus clearly works without internet access.
  • Repeating tasks – both have
  • Ability to sort/filter/use contexts – both have
  • iPad app – both have

On my core criteria either is fine.  I would be using it on all Mac products so that isn’t a downside.  Although a suppose the web interface of Toodledo is a nice to have.

Trying Toodledo

I decided to try toodledo first.   The free version wasn’t much more than my paper list.  No subtasks/minimal organization.  There is a 7 day trial of the pro version so I tried that.  (I bought it the next day.)  In pro, subtasks are nice and intuitive.

What I liked

  • Signing up and entering a task was easy.  As was entering a repeating task.
  • The sorting/scheduling/stats are nice.
What wasn’t obvious to me
  • It wasn’t immediately apparent how to edit a task (besides the task name) or add notes to a task (unless it started with notes).     It assumes a certain screen resolution and requires horizontal scrolling to see things like how to add a note, repeating entry, priority, etc.  After scrolling, I do see how to edit everything.

Note that on the web interface, there are two sets of screenshots online. This one which looks easier to use and this one which is what I see

The iPhone/iPad app

The iPhone app is $3 (no free trial.)  I did pay the $3 but I had some doubts as to whether I was going to like it since I wasn’t crazy about the web interface.  Turns out I like the iPad interface a lot better than the web interface!  You can click a task to show details which is more intuitive to me.  Tasks feel linked better.  Just the overall feel is nicer.

The only thing that wasn’t intuitive to me was that contexts aren’t displayed by default. To start showing them, you go to settings > tasks > fields and defaults.  Then you drag context up to the top of the used fields area.

Cost

$3 to experiment, $15 a year to keep.  Nice!

How it did on my criteria

  • Be able to enter tasks on subway/train – excellent.  While I have the iPad app set up to sync on opening/closing, it gives up quickly when there is no internet without draining battery.  I do have to remember to sync when I am not on the subway if I want to see the to dos in a browser.  This hasn’t proven to be a big problem though as I use the iPad app for reviewing tasks more and the web app for adding tasks if I am already on the computer.
  • Repeating tasks – good – easy to configure and specify dates.  The only thing I’d like is the “on date” field to allow multiple dates.  I can specify a task to only show up on Saturdays but not the whole weekend.  If I choose a regular due date, it starts showing up during the week.  If I choose “after” a date, I lose the benefit of a due date.
  • Ability to sort/filter/use contexts – excellent on the iPad app.  I haven’t used this in the web app enough to comment.
  • iPad app – excellent
Four other features
  1. I configured the ability for toodledo to receive tasks by email.  This is a great feature as I often e-mail myself from work something to gmail that is really a todo.  It is great to reserve email for email rather than a task management system.  The email is a “secret” email which is not rememberable.  I’ve added it to my contact list.
  2. I also set up the gmail plugin.  I don’t find it easy to use and it is the same # clicks to get to the tasks as just going to the website in another browser tab.  I tried in the “old gmail look” and it is less clicks there.  Could be this will get better.
  3. I like the importance score which is a combination of due date and priority.
  4. I like the scheduler where you provide the length of time you have, folder and context.  Toodledo suggests what to do.  That’s great for when you know you should do something but can’t think of what it should be.