r/AskProgramming • • Jun 19 '22

Other Why is programming so cognitively expensive?

So I run my own SaaS, I code 36-40 hours/week typically.

But after a few weeks of doing this, I almost always crash and my brain is fried.

And then I'll need to take anywhere from 3-7 days off just to recover and restart the cycle.

It's not like I'm having much fun either on those off days, you'd think I can go hike or surf or do something fun, but no I'm mentally exhausted -- sometimes even taking a shower or doing laundry is an uphill battle.

All I can do is sit on a couch and watch Netflix reruns.

Mentally that's all I can do.

Is this just me, or is programming really so mentally exhausting?

How do you guys do this sustainably over years and even decades?

78 Upvotes

29 comments sorted by

65

u/A_Philosophical_Cat Jun 19 '22

To answer the title question, I think it's pretty obvious: Programming is abstract problem solving in it's purest form. We're constantly using and abusing a part of our brain that originally evolved to let us be slightly better hunters and gatherers via planning, and pushing it to its logical extreme. No wonder it's exhausting.

To answer the actual question of the post, work less. If you're actually putting in 36-40 hours a week of actual programming time, you're doing at least twice, if not twice again more programming than the typical full time job demands. Most SWE I know (myself included) spend maybe 15 hours a week programming, about that same amount doing random documentation and sometimes sales support type stuff, and a combination of either pretending or not even pretending to work the other 10 hours in a full-time work week.

3

u/Rutabaga1598 Jun 19 '22

Yes, my hours are time-tracked, and I also do other tasks apart from programming outside those hours.

I feel like I need to code as much as I have spare hours because I already code so slow.

Sometimes a bug can take like 5 hours to fix, even though when I finally solved it it turns out to be something small or stupid.

Other times I accomplish so much in a short amount of time, but then it would feel self-indulgent to just take the rest of the day off, since I'm now "in the zone" and should bang out as much work as possible.

17

u/eplaut_ Jun 19 '22

I think you need to change yiur expectations. You put yourself in a hard position to be, and it is sounds like your workplace is pressuring you to work faster.

At first place, try to adjust your time estimations to the real timing. There is no stupid bug to find, yes we do mistakes, but often finding them is hard, even if fixing them is easy.

Try out this video, it might help.

The software engineer mental health

7

u/MarkusBerkel Jun 19 '22

"Sometimes a bug can take like 5 hours to fix, even though when I finally solved it it turns out to be something small or stupid. Other times I accomplish so much in a short amount of time"

Welcome to programming.

0

u/[deleted] Jun 19 '22

[deleted]

0

u/[deleted] Jun 19 '22

[deleted]

2

u/NiceTerm Jun 20 '22

Programming is just as hard. With maths you need to be much more rigorous, but in programming, you are dealing with a function that looks like runtime behavior = f(x1, x2, ... x10^50) in terms of free variables. And not all of them well defined. x180293982473 is the API timeout you get because some network packets were dropped. The programmer tries to tame that super function with all sort of things - the compiler, types, exception handling and so on. And that is the 'getting it to work' layer. What about user expectations. Bug vs. expected behaviour. And then the deadline. Do we say to mathematicians, break down proving fermats last theorem into small JIRA tickets and then estimate each one. Chase them up if one of those tickets takes longer. And we need that initial estimate before the end of the day, and you need to stick to that plan you come up with.

Also one you 'deploy' a mathematical theorem, well I guess it gets peer reviewed. But if there is anything wrong will you have to immediately drop the other theorem you are working on, switch context in seconds, and then fix the problems otherwise your boss loses a million dollars or whatever.

I think the meta that comes with programming more than makes up for the lower rigour level compared to mathematics.

12

u/glenwoodwaterboy Jun 19 '22

What helps is if you look at different approaches to solving problems. Can you solve the problem by implementing a data structure you don’t normally use for example.

Also what helps me is taking a long lunch break and working out

2

u/Rutabaga1598 Jun 19 '22

Okay, thanks for your advice.

I also take long lunch breaks and work out too.

Is it possible that I'm just not smart enough, so I have to exert myself more just to get the same task done?

4

u/JosZo Jun 19 '22

A lot of programmers feel insecure about their own abilities and suffer from imposter syndrome. Realize that everyone has their weaknesses. Take enough micro and mini breaks. I for instance, work out every day between 10 and 11. And I only program when I'm inspired.

2

u/glenwoodwaterboy Jun 20 '22

Coding is about lots of repetition. What took me two weeks to setup a year ago now can take a day or two with way cleaner code and more reliable as well. I’m not sure where you are in your development path, but I’m somewhere in the very wide intermediate range.

What I’m trying to say here is if you can do things better and faster because you are better, it will eventually not be as taxing.

Also, are you due for a vacation?

2

u/the_friendly_dildo Jun 19 '22

what helps me is taking a long lunch break and working out

Seconding this. The only time I feel like I get restless leg syndrome is when I'm coding and I'm hitting lots of brick walls. Sometimes the anxiety feels like it explodes in me and I just have to get up and run around for a bit. I try doing more menial tasks like walking around, cleaning, counting the number of steps it takes to get from one place to the next, whats the fewest steps you can take to get from one place to the next. Anything to reset your mind and focus on something else.

3

u/lauris652 Jun 19 '22

Have you tried doing sports or working out?

2

u/Rutabaga1598 Jun 19 '22

I do work out.

2

u/lauris652 Jun 19 '22

and how do you feel after your workout? does it reset/drain your brain? because thats how i do it and it helps me

0

u/Rutabaga1598 Jun 20 '22

Honestly, I'd probably code better if I *didn't* work out, because my work outs are so intense, but I know my overall health will be worse (I'll look and feel worse) if I didn't work out at all.

2

u/Swannyj95 Jun 19 '22

I find this helps me. 1-2 hours a day of not having to think about solving problems

3

u/lauris652 Jun 19 '22

absolutely. when mind is at work, the body rests. and when body is at work, the mind rests

8

u/LoganEight Jun 19 '22

You aren't alone. It really is one of those things that everyone underestimates until they experience it. Just existing takes some energy. And the assumption usually is that sitting at a computer all day probably doesn't take much more energy than just existing because it's so stationary. But programming is logically intensive. You need to think purposefully for as long as your working. Thinking uses energy. It's definitely going to make you tired.

6

u/[deleted] Jun 19 '22

You're trying to make a device made up of millions of transistors to do something financially useful for humans. It runs software that you mainly didn't write and is the most complex device humans have ever created. Of course it's going to be an impossible nightmare.

3

u/TomahawkChopped Jun 19 '22

Is your SaaS able to cover the cost of a junior programmer, maybe even on contract?

Personally I know that the most exhausting programming tasks are generally the most minute items that don't really require a view of the big picture. e.g. debugging a failing test, struggling with some UI layout on a particular platform, etc...

Being able to hand off well defined, but time intensive tasks to someone who can be paid to just work in that small context will free you up for the bigger items that may have more impact on your business

2

u/hectoralpha Jun 19 '22

Yes you have to maintain yourself. Healthwise eat well, exercise most of the day and sleep well. Taking care to be stress free throughout the day, allowing the body to relax. I practice concentration exercises and it helps a lot, among other martial arts, taking good care of my chi, and unwinding out.

2

u/vegetablestew Jun 19 '22 edited Jun 19 '22

I find groking and working with code that is hard to understand, full of gotchas, lots of weird one hacks and workarounds, a lot of side-effects cognitively taxing.

But working with code that is neatly encapsulated and can be reasoned about in isolation is not. Its nice to just direct the abstractions and get the result you expect.

Is your code resembles the former and not latter?

2

u/NiceTerm Jun 20 '22

Yes it is. The answer is you can't sustain it, and working for other companies, you get found out for being slow on the JIRA / time tracking treadmills. It becomes a game of keeping head above water.

Hopefully your SaaS will get to a point where you can be more of a CEO and hire people to do the coding. That is your light at the end of the tunnel. Then you can be one of those bosses who occasionally dips into the code for fun or stay current, but generally lets others do the bulk of it.

For now I would advise putting a product management hat on for 1-2 hours a week, decide what is really critical to code that week in an X hour window, where X is sustainable. Maybe 15 hours if you have other business functions to attend to.

Keep doing the 80-20 until you can't no more!

2

u/valkn0t Jul 22 '22

This hits close to home. I’m also running the technical side of a startup, all coding is done by me, across multiple contexts (multiple stacks, DevOps, and Shopify app dev). Anywhere from 40-100 hr work weeks. Days/nights blur together. The last burnout was vicious. Still don’t think I’m fully recovered, even though it took me out for 2 weeks or so.

A trip to Vegas with cofounder looking for potential investors helped me get out of my coding mindset but it’s a bit slow getting back into it.

At this point all we can really do is get to a point in revenue where we can afford a fresh jr. Engineer to hand off well defined coding tasks, and try to achieve a more sustainable working pace. My 2c

3

u/Starkemis Jun 19 '22

Many programmers who end up getting promoted to non-programming managerial roles don't miss programming.

0

u/mikeywhatwhat Jun 25 '22

You are depressed and should talk to someone.

-2

u/_JDavid08_ Jun 19 '22

And because you are sitting all the day doing your work it is bad paid (at least in my country, and most of the third world countries)

-2

u/reboog711 Jun 19 '22

The math doesn't add up.. how does one 36-40 hours per week; and then take a 7 day break?

3

u/immersiveGamer Jun 19 '22

OP said he runs his own SaaS platform. I assume this also means he is self employed.

-3

u/reboog711 Jun 19 '22

Yes, I assumed so too.

Usually when someone says they work 40 hours a week they mean every week; which is not possible if you're also taking a 7 day off each 'week'.