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)

Java for new Programmers

Today was a great session about Java in education

From Oracle

Resources from Ken Fogel’s talk

  • Sample code showing Java brevity
  • Single File Source Code Execution (I really like being able to write java MyProgram.java). Way less explanation for new programmers!
  • Type /edit in JShell to open in an external editor (I didn’t know about this – cool)

Other resources I like

  • Online IDEs
    • https://repl.it/languages/java10
    • https://www.jdoodle.com/online-java-compiler/

eleven weeks of being at home + feelings update

On March 22nd, I blogged about being at home for over a week. I posted an update about two weeks later.

Communicating about how doing

As an update on the original topic, I talked about how I was doing (poorly) on:

  • A number of one on one calls with various people.
  • A weekly call we have (that has about 30 people on it.) I *really* didn’t want to. The person running the call provided a perfect scenario for someone to say that everything wasn’t ok. I didn’t want to. But when things are “normal”, I’m often someone who speaks up when “anyone” could. And I wanted to support the messaging of “it is ok not to be ok.” So I made myself. The following week we had a special senior person guest on the call who said he wanted to hear from three people before we moved on. So I made myself say something again. (just like at all hands meetings where I am often someone to speak up.) The person who runs the meeting commented later that I must be doing better because I’m more chatty on the calls. I nearly lost it. That was definitely NOT what was happening there.
  • One team retrospective. My teammate brought up an important point in this space. I replied to it, but I really had to hold in my feelings so I wouldn’t fall apart.

Tracking feelings

Anyway, this post is about something more positive. Every day for the past 11 weeks, I’ve been keeping track of two metrics

  • How “working during pandemic” is compared to normal voluntary telecommuting.
  • A “difficulty concentrating” score.

I also kept track of some data points like what time I started work, current events and external factors. Some of it was to see if it I could find patterns. And some was to see what I could improve with experimentation.

The first two weeks were absolutely terrible. After that the first metric got better faster than the second. The second metric was way more spiky. Some days were decent (I’m not going to say “good”, but I’ll say decent.) And some were terrible.

I also kept track of how many times I cried during work hours. If you asked me three months ago, I would have told you that I don’t cry often. But the last 11 weeks have been so overwhelming that hasn’t been the case. I used up all my resiliency and didn’t have enough left to deal with normal work events.

All of this data was helpful. It let me volunteer for tasks that were useful to the team but fit better with what I was able to do in the state of affairs. (For example, I like pair programming but doing it for an extended period was too much.)

My boss said he never saw Excel use for feelings before :). It helped though. It gave me data to work with. And it let me something more analytical to anchor on.

Approaching Memorial Day

The week before Memorial Day was the worst since week two. It was a combination fo a few things:

  • As I go for my walks, I see more and more people “breaking quarantine”. So the stats will go up and my governor will wait even longer before allowing people to gather.
  • I felt people were going to “break” quarantine for Memorial Day weekend regardless of direction from the government which again would stretch out when numbers will go down to trigger phase one of reopening.
  • I see more and more people on the street without masks. (If I can see your nose and mouth, your mask doesn’t count!) Yet again, stretch out when numbers will go down.
  • Many messages about disconnecting and recharging over the three day weekend. (Normally, I would spend a bunch of time away from devices. But that’s hard now)
  • Many messages about spending the long weekend with your loved ones. (I live alone)
  • It’s been hard not seeing people in person. After work, it’s only somewhat hard because it is a short time. On the weekends, it is harder. So a three day weekend was not something I was looking forward to as relaxing.
  • I’m on a distributed team. So I got to hear about what teammates were doing for the long weekend where doing things is a thing. I’m happy for them, but it still reminded me that I can’t.
  • Connecticut and New Jersey had both issued directives about the number of people who can gather. CT was at 25 and NJ was at 10. I don’t need 10. I need 3 or 5! But NY hadn’t even been talking about it being a future thing. What we did have was a steady stream of “only do things with members of your household.” So while it’s great that people can go to the beach or whatever, it doesn’t solve the problem of being alone.
  • NY has a fairly extensive plan with the four phases and the details and the discussion about risk. We also have a governor who is on TV every day sharing lots of info. So the fact that he didn’t even talk about a plan for small gatherings wasn’t promising.
  • NY said people could get together in groups of up to 10 for Memorial Day observations and religious observations. Wait a minute. If it’s safe to do that, why can’t I sit outside with one or two friends six feet apart. Now it just feels arbitrary and unfair.

When Things Got Better

  • Friday at 3:30pm was really hard because that’s when the holiday weekend started. So I had a whole stretch of time in front of me.
  • At 3:45, there was a robotics team “history lesson”. I watched it live (archived on YouTube). Just listening to three hours of people I know chat helped me not think about three days of being alone. I also got to say hi to the guest before it started and look up a link during it.
  • When I checked the news after that, I saw that Cuomo announced that groups of 10 can gather for any reason. (According to the media, this was in response to a legal challenge).
  • This helped a little because it gave me a little hope.
  • A little after that, a friend checked in on me. When I commented about the groups of 10, he invited me over to lunch with his family at some point. That gave me a little more hope. (I know what some of my friends feelings on get togethers are. But a lot of people I don’t because discussing something hypothetical isn’t everyone’s cup of tea)
  • Saturday at 4pm, I had a video chat with two friends. And we made actual concrete plans for next weekend. They are safe plans (walk in the park and eat outside.) We even discussed logistics for using the bathroom. And these friends are married so it really only two “groups” getting together. This is pretty much the safest gathering I can do. This filled me up with hope. Because it is real. It’s not that maybe I’ll see someone in person one day. It’s an actual thing I can put in my calendar.
  • Now that I have plans with actual real life human beings for next weekend, I’m ok for this weekend. Granted, I’m still spending the weekend alone with things closed. But it feels more like a holiday where things are closed for the holiday and my friends happen to be busy/away. I’m fine with *one* weekend to myself. I’m not fine with all of them combined with all the weekdays to myself too.

What I Learned

  • I have a lot to be grateful for: I can work from home. I have a job. I’m healthy. I don’t have anyone close to me who died. I’m grateful for all this. But that’s not enough to be ok.
  • Video chats are nowhere near enough to be a substitute for human interaction.
  • Be careful how you word stuff. “I” messages are better than “we all” messages. When listening to someone say “I enjoy that I can have lunch with my kids every day”, I’m fine. It’s great that you can have lunch with your kids. It’s great that you enjoy that. I’m sure they do to. When listening to someone say “It’s great that we can all have lunch with our families every day”, it triggers “when am I going to have lunch with anyone. This sucks”. Very similar message. Very different reaction.
  • It’s ok to talk about feelings at work. I didn’t want to talk about how I was doing. I didn’t want to appear broken or weak. I didn’t want to be the only one struggling. It took a long time to get past that.
  • For the first 2-4 weeks, things just kept getting worse. So there wasn’t even a steady state to try to adjust to. I was very worried that some things that were happening in other countries were coming. One of the big ones I was afraid of was losing the ability to go for a walk.
  • I hate the phrase “new normal” in the context of COVID-19. Prior to this, I had heard the term in relation to financial stuff. Hearing it on things that affect day to day life and emotions is harder. First of all, this situation we are in is NOT normal and is NOT permanent. Pieces of it may be. For example, we may never go back to shaking hands. But the current state of affairs is not permanent. Hearing repeatedly about how we are “adjusting to the new normal” is not helpful when one is falling apart.
  • The weather getting better helped a little because I could take longer walks and sit on my balcony (and make my small apartment a little better.) Which means if we are doing lockdown again next winter, it’s going to be even worse for me.
  • The open-endedness was the hardest part. Granted it is still open ended. For example, I don’t know when I’ll be on a subway again. But knowing that I’ll be seeing friends in a week means I get part of my support system back. And that’ll make it easier to deal with the other parts.

I want to thank everyone who has been virtually checking in on me. Even though it wasn’t “enough” to make things better, I’m sure things would have been far worse without it. And special thanks to the three people who gave me hope this weekend!