Ask HN: How do I program with more discipline and less emotion?

17 points by muzani ↗ HN
I'm used to being a hacker. I like doing 48 hour programming "binges". These were incredibly effective and I could often build more in those 48 hours than most people would build in a month.

It worked great when panicked, but as I get more senior and used to the heavy pressure, it doesn't work any more. I have a more comfortable life now and failing projects is not as bad as they used to be. So it's hard to dig up the emotion I used to hack long hours. Now I just end up staring at the code for 2 hours at 2 AM.

Besides, exhaustion kicks in and makes me less effective in the long run. And it doesn't scale as well with a team.

I find disciplined techniques like Scrum and XP appealing. I know I should start adopting them. But a part of me worries that my hacker spirit would die out.

So how would I go from being a code berserker to being a more organized, disciplined, professional programmer?

14 comments

[ 10.5 ms ] story [ 593 ms ] thread
You have the opposite problem. You need more emotion. It's the emotional connection to your work which enabled you to go on those binges. With no emotional connection, you wouldn't be driven to do any programming at all, let alone in binges.
I mean I'm reaching the jaded, cynical senior programmer attitude where I just can't muster up the emotions. There will be a few, but not quite the extreme, startup mindset. So I'm looking for a way to migrate to a style where I can do without them.
Look for a different job? Work with a different team? Change your mindset from programming focus to a customer story focus? Start your own business?

If you don't feel driven within the environment that you're in, maybe it's time to look somewhere else. Or maybe it's okay not to go on these binges. Maybe it's best to scale back and put some of that energy into something else, like family, hobbies or whatever else might capture your interest.

Since we only get one shot at this, I think it's more interesting to change things up. We don't need to walk the same tired ground. There's always new territory to operate on. New challenges. Maybe your current situation is your gut telling you that you need to start working on different metrics rather than raw programming output.

I also used to love "binge programming", a kind of hyper-focused/obsessed productive phase, but I totally agree that it gets exhausting with age and not sustainable in the long run. In fact, for me it creates occasional but fairly regular cases of burn-out. I'm still learning to become a more disciplined programmer.

These days I'm trying to "stretch out the binge", so it's less extreme ups (and downs), rather a more long-term sustained focus and interest.

I'm in no position to give advice, but part of your solution may be emotional and intellectual engagement with the process of programming, the tasks at hand and the problems to be solved. Also, as a programmer, you might enjoy building such a system as Scrum/XP/etc. that suits your situation best.

Actually, I might just end up building my own system. I'm surprised that solution never occurred to me, as I've been trying hard to squeeze existing methodologies into my life and it doesn't work.

I've had a lot of admiration for military techniques and how they train people to get past fear and drop bad habits. I'll probably adopt a mix of XP and some military techniques.

Productivity isn't about writing lots of code.

For example: if you spend 48 hours writing 10,000 lines of code, and then I produce same functionality in a normal 16 hours of work, with just 1,000 lines of code. Who is more productive?

So instead of focusing on writing lots of code, focus on solving problems. The less code it takes to solve a problem, the better off you are, because that's less code to maintain.

This attitude (explained in more detail here: https://codewithoutrules.com/2016/08/25/the-01x-programmer/) then leads inevitably to the idea that working long hours isn't actually useful, nor is working at 2AM a good idea. The best way to be productive is to think, and that is easier when you are well rested, and works better if you take breaks and go do something else (https://codewithoutrules.com/2016/11/10/work-life-balance-so...).

I quite like the point of the article but I have one issue with it.

It begins by focusing on "producing times ten" and then goes on to equate that with "lines of code times ten".

The issue with that is lines of code isn't production. The real production is the value behind that code. If you do the same thing with a tenth of the code, you _are_ producing ten times more.

both of your comments reminded me of the 'the parable of two programmers' [0] (not original). While I disagree on the concept described that each programmer was 'productive' in writing 'lines of code' I think that the lesson learned is more about approach and how solutions should be evaluated.

[0] http://www.bruceblinn.com/parable.html

Emotion is what makes you strive to do a good job. Caring is an emotion and caring about your work is an important quality to have.

Which would you prefer? A programmer that knocks out am untested Italian food stuff thousand line function or a programmer that takes care to structure the code such that it's well tested and factored?

One of my main complaints about cs in university is that they didn't teach how to put their effort and energy into their projects in a healthy and sustainable way. Many students ended up learning the 'magic binge' approach you're talking about.

It depended on that seemingly random lightning bolt of inspiration combined with almost manic mental energy to work crazy hours to get it done. If you've ever worked through the night, met someone who _expects_ future crunch times (aka. binges), or put off working on something important because you just weren't feeling it right now, then you know what I'm talking about.

The closest analogy I've found is writing. Experienced professional authors most commonly give out the advice to work on it consistently, every day, whether you're feeling it or not. I feel like that heavily applies to programming too. If you care about a project, for work or for your self, you've got to make it part of a routine. Pick your days and time that you're going to work on it, then sit down and work whether you're super excited and have 'flow' or not. I think that after a short amount of time each session, you'll find you are creating the inspiration rather than waiting for it to find you.

A few, more concrete, ideas about how you might reduce emotional Bing coding:

Experiment with coffee. Most commonly I see bingers drinking a LOT of coffee, that's what fuels and in part causes the binge. If that's the case, try going to zero coffee and then every other day, try increasing your coffee intake just a little, with a rest day of no coffee in between, until you find out what actually works best for your productivity. You're looking for optimally consistent, not max output in one sitting. It's got to be consistently repeatable.

Try meditating. I recommend the app headspace if you've never done it. Basically a large part of meditation is deliberate awareness of your thoughts and emotions, the goal being to better understand yourself and what makes you tick. If done consistently, it seems to help people guide their thoughts and emotions in a positive way, which can really help with something like programming.

Exercise. We all know the benefits, a zillion studies have shown it helps you feel motivated, relaxed, improves mood, and think clearly. Seems helpful to me.

Decide to take the pressure off of each work session, regardless of what's going on. Even if it's crunch time and the sky is falling, tell yourself this is not the be-all end-all, that you won't remember this in 5 years let alone 20, and to relax. Choose to be calm, and just focus on making the project a little bit better than when you started.

Go for walks. I separated this out from exercise, because the best benefit of walking is that it takes very little thought, freeing up your brain and giving it space to run around. Sometimes I just let it go bananas, the equivalent of a dog zooming around a back yard. Other times, I'm just washing out everything else by listening to a podcast or an audio book. Or, just putting on music and letting myself feel more and think less. All of these are like a pressure release valve for your mind.

Make a list. Follow that list strictly. Nothing is less emotional than a cold hard list. Not something I recommend all of the time, it can make your thinking rigid, but a very simple and effective tool when that's what you need.

I've done all of these.

Coffee - it consistently works, more so if combined with L-Theanine.

Meditation - doesn't help. I've tried headspace, TM, many of the apps. Part of the problem is that it does chill me out, which makes me unproductive. The main benefit is after meetings, where I usually get pissed with coworkers.

Exercise/walks - it feels good, makes me think better, but the data shows no change in productivity. I've been doing med-high intensity exercise for nearly a year.

The list - really the only one that works. The only real problem is when something in the schedule forces me off. I've been modifying it heavily this last week. It's full of if-else statements now, lol. I might just end up putting it in an app to command me what to do, based on the daily situation.

Speaking of writing, Tim Ferriss's Tools of Titans interviews writers heavily. A very consistent pattern is that they do work late at night or morning and often with some kind of music repetitively running or meditation.

A lot of them also procrastinate heavily, some even making it a routine to procrastinate half the day, feel guilty, then use the guilt to channel energy into their work.

Learning this made me question my disciplined attempts and wonder whether it's really possible to be productive without binging. It doesn't help that YC programmers are notorious for working really hard for really long hours.

When I get overwhelmed and feel that tension that comes from digging in to a new project here are a some things I do.

1. Schedule clear time to work on the project - I want to be intentional with my time so there is no ambiguity on what I should be doing. ex. 9AM - 12PM work on this feature

2. Win the war before going to war - A lot of the time, procrastination stems from not being clear of what exactly needs to be done. The task is either very complex or simply not clear. Cognitive complexity is the precursor of inaction. So before I start I try to describe what exactly I'm going to do before I even open my IDE. For example, 1. Get the requirements, 2. Create a flowchart of the data, 3. Describe what I think would be the best approach.... etc

I'll even drill down to actual classes and methods I should be making. This really helps get me unstuck

3. I have 5 truths of work that I remind myself of. Here they are

1. No where does it say that work must be easy for me to do it 2. No where does it say that work must be enjoyable for me to do it 3. This work is important 4. You don't have as much time as you believe 5. Your self worth is not determined by the success/failure of this so just attack

Those are some of my personal methods but in the end, it's about experimenting and finding what works for you.

Hope this helps