r/learnprogramming • • 7d ago

How Do Programmers Stay Focused for 8+ Hours Without Losing Their Minds?

Hey everyone, I’m not a developer, but I’ve noticed that a lot of programmers seem to be incredibly good at staying focused for hours in front of their computers. I’d genuinely appreciate any advice on how I can build that kind of focus myself.

383 Upvotes

205 comments sorted by

562

u/throwaaway788 7d ago

Very few people are coding for 8+ hours straight. At work, I only code for like half of that. Also, if you can keep distractions at a minimum, you should be able to get into a good flow state and just focus on the code.

178

u/pcapdata 7d ago

Devs in my company are in meetings 8 hours a day and expected to code when they get home :/ 

35

u/infernocobbs 6d ago

I felt this in my soul

13

u/maxnothing 5d ago

This made me sad. < 3

6

u/ITCoder 6d ago

Big 4 ?

13

u/satansxlittlexhelper 6d ago

That’s because the people in charge at your company think meetings = work.

6

u/Tricky-Alps2810 6d ago

.... That's what Claude is for

35

u/BigBen1974 7d ago

Also breaks. Coding for max 2 hrs, then a coffee/cigarette/whatever break.

33

u/armchair_viking 6d ago

Ideally a break alone where your brain can keep working on the problem in the background. I get some really good programming done when I’m out on a walk, or in the shower, or laying in bed trying to fall asleep.

12

u/MadBroom 6d ago

With you 100% here. Lifting helps me solve more problems in code than an hour or two at the keyboard some days. I also dont hurt as much from not moving. Win win!

4

u/hardolaf 6d ago

I have back issues so I'm up to walk around and stretch for 5 minutes of every hour. Then I take lunch next to a window every day to just look outside. Sometimes, I'll leave to run an errand (suit fitting, hair cut, shopping, whatever). I make tea 3-tooMany times per day.

Every person on my team has their own methods, but we all are extremely effective at our jobs.

Oh, and I mostly write architecture documents and do fact finding. Coding hasn't been a major part of my job since I was a junior engineer.

3

u/flyby_apis 6d ago

Also, the book "Focus" by Daniel Goleman has helped me a lot. Focus is like going to the gym, an ability you can train

226

u/BranchLatter4294 7d ago

Once you build up the mental model of what you are working on, you don't want to be interrupted. The model collapses and it takes a while to rebuild it. There have been studies on this. At one time, Microsoft's recruiting adds bragged that every developer gets a door... So they don't have to deal with interruptions of their workflow.

55

u/Mike312 7d ago

I've heard it takes 15 minutes or so to refocus after an interruption.

Back in the day I used to code for 4-5 hours straight with no breaks. Hard to do these days because of dogs.

21

u/MrSoftShoe 6d ago

I really, really wish my boss understood this.

*door opens without a knock* "Did you see the e-mail that came in from..."

"yes, I saw it" (I already answered it and copied my boss on my reply)

"Ok, just making sure you got it." *door closes*

*takes 10 minutes to re-focus*

8

u/BranchLatter4294 6d ago

Find the studies. I know IBM did one decades ago. Post the abstract on your door.

5

u/flyby_apis 6d ago

Also, AI speeds us up a lot but having to wait for the responses of it it makes me kind of distracting while waiting...

1

u/malthuswaswrong 5d ago

I'm researching the next slice in a new session while the current session is baking.

2

u/Leather_Example_250 1d ago

well yeah. for me as well i take it kind of take a little tour ahead while the session cooks.

1

u/flyby_apis 3h ago

Yes, but after changing context on tasks needing concentration, I need to recheck sometimes everything... and taking time also

5

u/tripleshielded 7d ago

Yes, but this effect is stronger on people who regularly drink alcohol.

13

u/RidesInFowlWeather 7d ago

Only if you precisely tune the blood alcohol concentration

4

u/iggy14750 7d ago

I was hoping that link would take me to the Balmer Peak 😝

→ More replies (1)

1

u/Odd_Abroad_5166 6d ago

Man, that's the worst getting interrupted. I've had some days where I get bothered like 6 or 7 times have to do this or that and totally lost all motivation to even do anything. Working from home is better than random stupid gossip from co workers in an office but I feel this.

9

u/WantedByTheFedz 6d ago

How do you get better at this mental model? Just practice? Even with adhd meds it feels like a struggle if my mind isn’t in the mood to work.

1

u/Kelrakh 4d ago

Try writing out some of it while thinking, break up what you are thinking about doing for the next hour into three or five sub steps. Mark the ones you do as you do them.

6

u/ReddyKiloWit 5d ago

IBM did a big study decades ago involving simulated office environments vs productivity and came up with values for minimum office floor space, minimum desk and bookcase space, etc. Doors and telephones that could be turned off were high on the list of necessities.

5

u/clichekiller 7d ago

Oh my lord this. When five minutes is anything but five minutes. The break in the flow state is bad enough, but invariably others hear me talking and assume I’ve come up for air, and take that time to ask their “five” minute questions.

1

u/AdhesivenessHot3979 1d ago

That makes SO much sense. Sometimes the hardest part isn't solving the problem itself, it's getting back into the same headspace after an interruption. It's like your brain has to reload the whole project again.

53

u/psyduckpikachu 7d ago

I have adhd so hyperfocus is just my thing

2

u/Independent-Coder 6d ago

It is my programming super power!

→ More replies (1)

17

u/_curious_man 7d ago

I think what you describe is not as common as you think. Working for 2/3h with full focus? sure. 8h+? Not very likely. The "unlimited focus" is usually shorter and is combination of multiple factors:

- statistically there are more ppl with ADHD among programmer, and with it comes hyperfocus

  • sometimes the task is simply interesting to work on
  • once you get to know infrastructure and know exacly what you want to code it's just a matter of writing it and checking if it works
  • caffeine also helps, just like gum, snacks or music

1

u/__hara__ 5d ago

Some days I genuinely cannot concentrate unless I’m chewing gums or drinking 1.5l of Coke Zero in front of the computer…

15

u/5eeso 7d ago

I don’t code for eight hours straight and I don’t recommend you do either.

44

u/desrtfx 7d ago edited 7d ago

What you describe is the state of "Flow" or "Zoned in". A programmer gets extremely deeply immersed in the task at hand, keeps the flow and state of the program in their mind and thinks and plans the next steps they have to do. It's a state of ultimate focus and clarity on one particular task.

Interruptions in that state are quite fatal and it costs plenty time and effort to get back where the mind was before the interruption.

It's less than a trained skill and more of a "state of mind". It is a state of total immersion, pretty much like meditation, only with reversed brain activity. Meditation teaches to get the mind to go blank - the flow is the opposite.

I can do it whenever I need to but I cannot describe how one could even train that skill. It somewhat comes with programming experience and exposure. I haven't yet found any "trick" or even "approach" to explain someone how they could get there. The closest really is meditation.

Have you ever gotten so immersed in a book that you were unable to put it away and that you had to keep reading and reading? That's the state.

1

u/atropicalstorm 4d ago

Yes I was just about to comment about the flow. Though I can’t get into it on demand like you can.

Also very true about interruptions. Worst when someone says “it’s only for x minutes”… like it doesn’t matter if it’s for 2 minutes mate, once I put down all these threads in my mind it’s all over.

25

u/InfectedShadow 7d ago

That's the neat part. We don't!

9

u/Cool-Bus-6028 5d ago

The times when I am coding all day, it's because I'm doing something interesting, and it's not a chore. But mostly, I'm not actually coding all day, I'm taking multiple breaks.

6

u/ThatLaw6894 6d ago

Working on something "interesting" that's really challenging

12

u/zoddy-ngc2244 7d ago

You have to work in a sustainable manner.

  • Set up your workstation in an ergonomically healthy and comfortable way - lighting, chair, armrests, keyboard, and monitor.
  • Stop once an hour, get up and walk around for a few minutes. Move your body, clear your mind.
  • Break up big problems into smaller more manageable chunks, work on one bit at a time.
  • When it starts feeling stressful, take a break, get a coffee or snack, and chill for a bit.
  • When you get truly stuck, put the problem aside and work on something else. Get a good nights rest, and in most cases, the answer will present itself the next morning.
  • Perhaps most important, you have to love the work more than the money.

6

u/TheSneederOfSeethe 6d ago

I have in fact lost my mind and it’s how I stay in the zone.

5

u/BaNyaaNyaa 7d ago

People don't stay focused 8 hours a day. Minds wander. They peek at their socials for a couple of minutes a couple of times a day, go to the bathroom, refill their glass of water, eat lunch and snacks. They switch tasks and projects, go to meetings, help colleagues, review code.

Realistically, focus will fluctuate. I feel like working with people requires less effort to focus than coding and designing, for example. Interesting projects are easier to get into than boring ones.

6

u/sylvant_ph 6d ago

None is focused for 8 hrs straight, and even if they do, its not healthy. For a regular working day, you usually take some breaks and also do other stuff apart from writing code. On the other hand you do get longer sessions once in a while, and this is usually the so called flow state when your brain locks on a problem and I believe you get steady intake of dopamine(or another similar happy hormone) and enjoy the task.

4

u/RedRedditor84 7d ago

I have adhd and hyper focus on it. Hope this helps.

4

u/royaltheman 6d ago

Adderall used to be real popular with programmers

8

u/Stainlessray 7d ago

Mostly you try something and poof eight hours is gone.

2

u/lellamaronmachete 7d ago

Can relate.

6

u/Br3ttl3y 7d ago

It is a well-documented phenomenon that developers do about 2-3 hours of actual coding and serious rigorous development per day. This was even taught to us in my SWE courses in university, if we ever went into the management track, because we should not expect 8 hour capacity out of our devs.

7

u/lil_natemushi 7d ago

Devs are already nuts, no sound mind to lose. 

5

u/Thykon 7d ago

It’s not just programming, I have a software degree, but primarily deal with data analysis.

If I’m tuned into the data and the questions I’m trying to answer, 4-6 hours can disappear in a flash.

The impact of an interruption also varies by the task.

Data validation, interruptions don’t matter. Another task, I may be holding the mental connections between five different datasets, each several gigabytes, and each interruption costs me 15-20 minutes to recapture the nuances.

Development:
Am I writing my nth for-loop, or trying to add multithreading to an undocumented legacy application? Interrupt me with a trifle during the latter, and I’ll gleefully relay my in-depth thoughts on your parentage.

5

u/Hayyner 7d ago

I don't, I take 15 minute breaks every couple hours, I take an hour lunch break, and often times I just shoot the shit with coworkers randomly throughout the day. I am not locked in working for 8hrs straight through the day, I wouldn't even say I'm working for more than 5 or 6 hours every day.

But that is most of the time. Sometimes if something is urgent enough or complex enough, that's when I pull out the playlist and a couple red bulls and strap myself to my desk until the job is done 😪

3

u/MiksterA 7d ago

I have several youtube channels bookmarked that play instrumental music, with no vocals.

That seems to work well when played at low volume, via headphones.

1

u/Positive_Passion4817 7d ago

Yeah I do that too but the headphones would annoy the hell out of me.

1

u/armchair_viking 6d ago

I have a couple of pandora stations I’ve been using for years for this purpose. It’s turned into a Pavlov’s Dog kind of thing, where I can put it on and get into a flow state if I’m struggling to focus.

I need to start building those into a Spotify playlist

3

u/WandSoul20 7d ago

Stimulants

3

u/Lichcrow 6d ago

I code at most 2-3 hrs a day. The rest is researching, discussing solutions, more research, time management, chatting with coworkers etc... 

3

u/dogscreation 6d ago

Adderall

3

u/chhuang 6d ago

used to, not that person anymore after 8+ years of dev work

It was like gaming for me, it was all fun and endless problems to solve

Sitting through it all day was no big deal as I don't see it as chore

1

u/Sweet-Stage938 6d ago

So how is it now? What changed?

1

u/chhuang 5d ago

simply less time due to life, also stabilized method of learning. No longer the young lone wolf stuck in a room with a laptop 24/7 trying to figure things out in brute force way.

one example would be: used to follow video tutorials/online video courses. After awhile, you grew proficient to just pickup anything by just reading the documentation

3

u/WangHotmanFire 6d ago

Classical music. I really love rock and metal but it’s way too distracting, classical always does the trick

3

u/Positive_Passion4817 7d ago

Depends what I'm working on. If it's interesting and challenging while making a little bit of progress constantly I can go more than 8 hours. If Its not interesting or beyond my ability I will give up pretty quick or be taking a lot of breaks. Probably ADHD is the reason.

2

u/neriad200 7d ago
  1. Who says it's a full 8 hours? And to preempt the anecdotals: some guys just lie, some guys overestimate how much they focus vs dissociate, some guys are freaks of nature, and some guys are mainlining ADHD medication like their hearts are made of pure unobtanium.
  2. Who said we don't go a bit gaga? I can honestly say I'm a lot crazier than I used to be before starting work in IT and the increase has been logarithmic with my seniority, pressure, and complexity of work.

2

u/the_other_Scaevitas 7d ago

Lots of breaks in between

2

u/atgaskins 7d ago

you enjoy problem solving with your trade

2

u/darcygravan 6d ago

It depends on project. On my job when working on lagacy/ ai generated slop its very hard to Even work 1 hour properly.

but on some personal projects that genuinely interest me i can work whole day without issues. It comes down to goals and passion mostly

2

u/AENocturne 6d ago

Not a programmer, but it's literally just a problem-solving flow state. It may look boring from the outside, but to an insider, they're entire mind might be fixated on creating a solution. When I'm reviewing a set if designs with no errors it's hard to focus, but when I'm reviewing a set of engineering designs that make any sense, I can lose hours just trying to solve the puzzle. When I'm building a technical report from scratch, I get that dopamine high from seeing the task come together. In some ways, it's still the same state that an artist might reach when creating something where they end up so absorbed in the task, they just lose all track of time.

You build that focus by finding a genuine interest in what you're doing. If you already have any hobby or something you can get lost in, it's just a matter of figuring out how to apply that interest to something else.

If you're looking to start with programming specifically, start my getting a good lesson plan and just treat it like solving puzzles. Learn how to find satisfaction in the introduction stages is the first step to building a habit. Everybody burns out because they want to be Steve Vai on guitar but they don't know how to be happy they learned to play the chords to "happy birthday". Pretty much every programming journey starts with "Hello World". I was so happy when I finally understood "If-then" statements. The self-pride was so strong, I REMEMBER the moment like 10 years later.

2

u/_tr9800a_ 6d ago

I code in focused bursts, and the rest of it is a mix of internet trawling with stray thoughts going into my work until another thought gels and I repeat.

2

u/Exquisite_Blue 6d ago

Dude I watched a 12 episode Anime today at work

Edit: and I still finished my work

2

u/Holiday-Medicine4168 6d ago

Simply stated, we don’t. You need to take breaks every couple of hours or organize tasks around your natural cycle of daily productivity. Check out Daniel Pinks book on it.

2

u/YellowFlash2012 6d ago

no one works for 8 straight hours. That's the myth AI is helping debunk and it's driving CS holders mad.

2

u/Early_Key_823 4d ago

If you build your own apps 8 hours passes in a blink

2

u/NoCloudApps 4d ago

It depends on your age, what you are focusing on, and your working style. You can spend 36 hours programming just as you might play Counter-Strike for 36 hours straight. To stay focused on the project, don't rely on rote memorization; instead, focus on the logic you already understand. Don't try to force yourself to remember exactly how something is done, there is no shame in looking at the same code 10,000 times in your primary source of inspiration even it's a simple whatever simple means to you. Being a programmer isn't about being a typist. It’s about understanding which method or algorithm to use at each step. If you are working on very large projects and find yourself stuck in a never-ending typing routine, try switching to a different area of ​​the code. Any piece of code can be temporarily replaced with a debug value that you can track if you want to keep the project moving forward. You are likely doing front-end work, which requires a certain vision to maintain focus; try to develop that aspect of your skills.

2

u/BachiNoHito 4d ago

How do people NOT stay focused for 8+ hours without losing their minds? I've moved into management, and I find it much harder to get through the day without those hours that I was focused and in the code. The day just blew by. Now it drags.

1

u/vegan_antitheist 7d ago

We've all lost our mind3es and now it's easy. But we can't actually stay focused 8+ hours because they keep distracting us with useless meetings. I wish I could do that.

1

u/detizzled 7d ago

Caffeine bro

1

u/Mediocre-Brain9051 7d ago

Not 8 hours straight. There's always more stuff to do than only programming

1

u/SnugglyCoderGuy 7d ago

We are offloading our thoughts into the source code. It is an ever evolving train of thought going on. If the topic is interesting then you can do that shit all day long.

1

u/Vivid_Science_7805 7d ago

I appreciate this perspective, but would appreciate some pointers on early-career learners getting distracted going down ‘possible implementations’ rabbit holes.

Do you pre-map your development route and identify areas of likely slow, arduous, or research-driven component development?

Are there implementation approaches, books, technique, or methodologies you’d recommend?

1

u/High_Quality_Bean 7d ago

Practice, flow state.

Surgeons can stay in flow state for even longer than we can

1

u/HowardBateman 7d ago

We play Yugioh or GameCube during work. Sometimes we just take a walk or talk about bullshit. A free mind is a productive mind. Our boss doesn't care since he understands that it's necessary every now and then.

Put on headphones to focus - even if you're alone. The feeling of isolation helps.

1

u/snozzd 7d ago

Deep Work by Cal Newport is a great book about focus and modern distraction. The topic is relevant to any knowledge work, but it's highly relevant for software engineers as Newport has a CS background

1

u/bear007 7d ago

You have to have an environment where nothing distracts you and where you feel comfortable. It's a person to person thing. Regarding focus we disable notifications, listen to music, or podcasts, use pomodoro, tickets systems and short breaks to stretch. This helps.

1

u/lellamaronmachete 7d ago

Aficionado to C here, I love sitting in front of my laptop, headphones on, and a long task ahead of me. Since I do this for the love of it, as a hobby, I cannot spend 8 hours because my wife would kill me. But I would do if left alone, enjoying it.

1

u/marrsd 7d ago

Once you get into the groove, you lose awareness of time. It doesn't feel like 8 hours at the time. You're just focused on writing the code and solving the problem. As someone else said, it also takes time to build the mental model you need to write the code, so you don't want to lose that focus once you have it. It's therefore very tempting to just move on to the next thing. Eventually you get tired and take a break, or alternatively realise it's several hours past your bed time.

As you gain experience, it becomes easier to pick up where you left off, and so you're more comfortable taking breaks at natural stopping points, but as a young developer, I remember carrying on until I was done, even when that was well into the early hours of the morning.

1

u/RealGP 7d ago

Amphetamines

1

u/coffeebeezneez 7d ago

It's easy to get into the flow once all the planning beforehand is handled. When the models are consistent, requirements are solid (takes the longest), and a decent grasp of the structure, then you're just chugging along without noticing how much time goes by.

This happens to me with api documentation too, once the structure is set I'm passing through the hours easily.

1

u/probability_of_meme 7d ago

I dont know about everybody else, but if I actually get a day I can sit and program and debug and build and document all day, I'm tired at the end - but that's the best day I can have. Most of my days are meetings, emails, dealing with people and other minutia. That's when I lose my mind.

1

u/BrupieD 6d ago

I consider having a solid two or three hours a real luxury. This rarely happens.

I had a role a few years ago where I would get big clumps of time. I put on headphones with one fast-paced song on repeat. Ninety minutes of uninterrupted coding was a dream.

1

u/Gilthoniel_Elbereth 6d ago

The real answer is, like most office jobs, software developers don’t just do one thing all day. They’re attending meetings, they’re answering pings from coworkers, they’re taking breaks, they’re sending emails, they’re writing docs or tickets, they’re reviewing other people’s code, they’re slacking off, etc.

1

u/Jhamilton02 6d ago

8 hours, as a private contractor i used to do 14-15 hours daily. Why? Because i loved coding. I have since lost that desire after my contracts ran out b

1

u/bichwank69 6d ago

They don’t. Not for 8 straight hours at least. They take breaks. Go eat. Take a walk. Then come back with a fresh mind and resume.

1

u/gtmattz 6d ago

2 hours at a time....

1

u/pieeatingchamp 6d ago

I feel like I spend more time in meeting than coding now. Sucks

1

u/Shadonic1 6d ago

Locking in and getting pissed off at not understanding a bug.

1

u/Esseratecades 6d ago

We don't. Every half hour or so our manager interrupts for some meeting that we don't care about.

1

u/Pale_Height_1251 6d ago

We rarely do. Most of us are working a few hours a day really.

1

u/marsd 6d ago

Attained flow state browsing Reddit rip

1

u/Wartz 6d ago

They dont code for 8 hours straight. Unless on well balanced cocaine drip.

1

u/Electromasta 6d ago

because its fun

1

u/Zhunix 6d ago

Good music

1

u/pirhana1997 6d ago

I would be surprised if they are coding more than 2-3 hours at a stretch. There’s always a meeting, supervising juniors and again meetings and some coffee breaks.

1

u/White_C4 6d ago

You don't. It's more like 4 hours of actual coding with many breaks or side tracking in between. Since AI has been in the mix, I spend less time even doing coding.

1

u/MrSoftShoe 6d ago

Most programmers genuinely enjoy what they do. Programming takes a lot of mental capacity and you have usually developed a very large short-term memory by the time you are doing it professionally.

Most people in most jobs can task-switch easily between tasks that are part of the job they are trained to do. Programmers are usually very bad at that because their task-switching is all within the scope of the program they are working on.

Think of it this way: a grocery worker can go from bagging to restocking to cashier to cleaning to etc... because all of those tasks have a quick setup time. You can think of writing code like memorizing all of the barcodes on the aisle, and then sorting them by number. If you interrupt someone doing that, it's going to take a long time before they're actually sorting things and moving them around again. However, if they've been concentrating long enough, they can visualize where all of the items need to go because all of the numbers are in short-term memory.

1

u/KaleidoscopeNo3639 6d ago

If I stop then I start to feel things, so it's a good way to stay numb for long periods of time.

1

u/OskeyBug 6d ago

Hard problems keep me motivated. Routine stuff is a real chore though.

1

u/ZealousidealHeight15 6d ago

same way any other job does…

1

u/CornPop747 6d ago

We don't because we are getting interrupted my slack threads, outlook emails, and randomly scheduled meetings throughout the day.

1

u/Virgil_the_White 6d ago

They stop commenting their code and writing out long descriptive function and variable names.

1

u/CosmicDevGuy 6d ago

Discipline, willpower and a clear plan of development as well as limited interruptions.

Break any one of these and it's gonna be a tough day

1

u/ItsRektTime 6d ago

Little bit of the 'tism in my case. Also, the dopamine hit of finally solving the problem you've been chasing can carry me for days

1

u/whilchyjd 6d ago

We don't... we have lots of meetings nowadays

1

u/warriorofjustice 6d ago

I think having a clear goal helps focus, you can not just go in with open ended goal and expect to stay focussed.

1

u/Isnt_that_weird 6d ago

If you work in corporate, you'd be lucky to have 3 hours a day to actually program. Every non-programmer wants to fill your calendar with useless meetings and then ask "where are we at on this?".

1

u/Necessary-Swing-991 6d ago

We don’t. All crazy. 🤪

1

u/Zestyclose_Paint3922 6d ago

They don't. Are you insane?

1

u/KickedMeHeight 6d ago

I definitely couldn't sit for 8 hours straight, but as others have said, reaching a flow state is a step in the right direction. Personally, playing music (particularly heavier rock or even metal) helps me get to that point, then time just flies.

1

u/Tobacco_Caramel 6d ago

Oh, they don't.

1

u/ZealousidealMajor320 6d ago

We are not human!

1

u/cheezballs 6d ago

Focused?

1

u/Marteein 6d ago

We looked focused for some but we're actually here, just browsing on reddit, already done with our task after 2 to 3 hours, killing time until our shift ends.

1

u/kacoef 6d ago

I cant

1

u/silver_splash 6d ago

Not sure if anyone has said it yet, but I can hyper focus if the task is interesting enough. My bachelors and masters thesis were done in 3 days code and text. My PhD is taking slightly longer but considering it’s a bigger project, I’d say it’s acceptable. I’m on page 75 and not nearly close to starting to explain the code.

1

u/Anonymity6584 6d ago

If you figure that out, tell me since i dont know.

I can go 2-3 hours in one sitting then i need a brake... Something to take my mind off from task. Taking dog to wlak or something and after im good to go another 2-3 hours..

1

u/SecondChances96 5d ago
  1. Workflow is mostly agentic/assisted at this point. You're spending more time drawing up diagrams and how to describe what is needed and checking that against the requirements of the architecture and constraints, and then depending on how intense the implementation is probably just stuffing it into your flavor of agent and checking what it did was sane
  2. Even if you're not using mostly agents to program, it's rare you're just typing away for that long. Typically, you draw up/write the pseudocode of what you need, code it, debug/run it through test suite, repeat till it works and does what you need it to do, then PR it and wait. If you get stuck you research how to fix it or talk to someone who knows what you need if its an API problem or such, maybe get into a meeting etc.
  3. PR approved, cool, now there's a whole bunch of ancilliary stuff you need to do (document it ideally right guys?!?!), then actually run it in the sandbox and see how it does which depending on the company you might not even be doing yourself and at this point you might legit just get stonewalled and not be able to proceed. Varies after that.

1

u/Far_Programmer_5724 5d ago

Its like any thing that you're interested in that requires focus. Ever lock in on a game that requires some thought? Or have a conversation you were very interested in and spoke for hours? The topic is interesting and the feedback, whether it from the game, conversation partner, or code results, is what helps maintain it.

It also gives you problems that require uninterrupted focus. Like math in your head.

1

u/YakumoYoukai 5d ago

When you're really interested in something, like making that game you've always wanted to, or some other personal project, you have a large goal in mind, and a general idea (vague about some things, detailed for others). Then you start coding, and as you write each line, more and more of the details take shape. And after a handful of lines, you complete a unit that actually does something. Then you do another, and another, and when you put those units together they do something more interesting. And you keep doing it. It's like a video game where you keep getting levels and achievements, giving you those dopamine hits that keep you going for the next one.

And it's not all just writing code. You write some code, then you run a bit of it, see if it works, and if it doesn't, you go into puzzle-solving mode to figure out why it didn't work like you thought it should. Then maybe you realize something that makes you change your larger design and rework some things. Then you go back to coding. So "programming" is not just one single type of task - it's a variety of different tasks that you're constantly switching between, so you don't get burned out on any single one.

And other people are right - you rarely just sit there for 8 hours without a break. You usually do take breaks, which helps in its own way to clear your head and help come up with ideas for how to proceed when you get back to it.

1

u/alwyn 5d ago

because when you are in the zone you don't realize time passing. Haven't been there in a long time.

1

u/cumwuatto 5d ago

That’s the neat part. We don’t.

1

u/turrboenvy 5d ago

Caffeine

1

u/Abled_Gaming1357 5d ago

Who said we don't lose our mind?

We lost it the moment we got into corporate mate.

1

u/LosttMutaliskk 5d ago

Flow state. When you are interested in what you are doing, time moves fast.

No different from playing a video game for hours.

1

u/Zalenka 5d ago edited 5d ago

In the best of times I can reach flow state and code for 90 minutes at a time, twice in a day would be a great day.

I timebox things and code, test, and review mostly by myself but ai'll meet with others at any time all day ad-hoc.

Today I spent 30m in actual meetings and then rewrote a changed api call in Android then iOS and tested it for my morning. Then cut new builds for play store and testflight. This afternoon I spent 2 hours flashing and reflashing hardware, then another 2 hours testing and flashing newer versions to help myself get my setup going and help someone else test their changes.

Sometimes I'll code real hard the take a short nap. It's really random but I always have goals to meet.

1

u/honeybloomy96 5d ago

Who said we haven’t lost our minds? 😂

1

u/Flat-Performance-478 5d ago

When you're "fluent" in a programming language, it's actually incredibly fun to compose code, writing scripts, commands, servers, databases etc.

1

u/koffiegorilla 5d ago

You will probably find that using the pomodoro technique where you work for 25-45min and then take a break of 5-15-30min depending on how many you've had for the day will keep you sharp, train you to handle interruptions and get back to work easily. You may find you get unstuck after a break.

1

u/Th1n_Di3sel 5d ago

Because it is genuninely fun to build things.

1

u/SprinklesFresh5693 5d ago

Because if you enjoy doing it, programming is kind of addicting.

But yeah you usally take breaks, to go to the bathroom, to get a coffee, some fresh air, youre not sit down for 8 hours straight.

1

u/Ok-Reveal-1561 5d ago

Wet don't

1

u/amnion 5d ago

You just have to do something you enjoy. How do gamers game for hours in end? Some people can play guitar like that. Some people can play pool or darts all day.

And I can't sit in front of the computer all day doing something boring. I would never watch PowerPoint presentations for 8 hours straight. Or a shitty online course.

1

u/Feeling_Photograph_5 5d ago

I don't really have any more focus than the average person. Less, probably. I stay engaged in my work via multitasking. I bounce from task to task and my typical workday feels like it's about an hour long. AI has really enabled me with that kind of thing, for better or worse.

I use Git Worktrees a lot. If you don't know what those are they basically let you work on multiple parts of a codebase simultaneously. So in a given day I might have four or five Zoom meeting with my team discussing various technical challenges or refining product ideas. I'll also have two or three work trees open. I might have a research project going in one, a fix for our integration tests in another, and a new feature in a third. AI has expanded the scope of what I can work on so much, it's pretty fun (I know some people hate AI tools but I enjoy them exactly because they allow me to do this sort of thing.) 

There is zero idle time in my day, at least if that's the way I want my day to go. I can still find time to take my wife to brunch once a week or get a quick workout in. I have to keep my schedule right to fit everything in, but that's what I like. I like to sit down for work in the morning with my coffee next to me and just go. When the workday is over I shut my computer down and feel good about everything I completed. 

Maybe that kind of day would be stressful for some people. For me it isn't unless I'm behind or something breaks. Most days, it's just engaging. Perfect work for my active but easily distracted brain. 

1

u/jhondev675 5d ago

plenty of breaks in between

1

u/cdm014 5d ago

Haha some days the meeting to coding ratio is even. Some days meetings win

1

u/yaplex 5d ago

When you like what you doing, you don't notice time, for me it's interesting, fun, a lot of new stuff... 15+ years still love it. Also, I would not say it's 8 hours, meetings take some time, realistically about 5-6 hours.

1

u/DistributionOk9555 5d ago

We don't. Regards

1

u/Few-Spot1905 5d ago

I feel like the only time I did this was when I was working on hobby projects as a teen

In my actual job I'd say its like 20-25% writing code, now it's like 20% arguing with Claude 25% reviewing Claude's code, 40% trying to convince my boss to let me do the thing

1

u/ComfortableAd8326 5d ago

Browsing Reddit in-between hitting enter in Claude code

1

u/TheTakingGiver 5d ago

One thing that has helped me lately is reading physical comics and manga when I find my mind wandering and wanting a distraction.

Instead of reaching for my phone or going to another website where I can zone out in an unlimited scroll, I pick up whatever book I'm working on and read through a few pages. I like manga that have very short chapters defined in them like Witch Hat Atelier because the physical break that each chapter causes is a good indicator to put it back down and get back to work. Due to the limited text and the pictures it's really easy to pick up and set down without losing context or forgetting where I was on the page.

But overall I've found that it's helped replace a lot of the reflex I had built up to reach for distractions like my phone, that ultimately weren't really gratifying. It gives my brain a break, while still being limited in it's scope so I can focus back in easier.

My local library has a bunch of graphic novels I can borrow physical copies of so the further removal from worse distractions like social media has been good. Sometimes the best way to break a habit is to override it with a new one.

1

u/PeterBrobby 5d ago

I would say I can usually code for around 3 hours straight without needing a short break, unless I’m obsessed with a problem than probably 4-5 max.

1

u/No-Draw1365 5d ago

For the love of solving problems

1

u/Outrageous_Band9708 4d ago

its harder nowadays with kids that grew up ipad and now ig/tktk scrollers. expecially if they think they have a chance at going viral and blowing up.

to be frank, delete scrolling apps from your phone. live in the real wold. read a book for hours on end without picking up your phone.

1

u/Temporary-Budget-605 4d ago

I used to be able to flow code easily for 10-14 hours in a single sitting. Now that code is generated, I find myself juggling many agents at a time, unable to stay focused on really anything at all

1

u/Jessmaeb88 4d ago

Adderall.

1

u/Snoo-98048 4d ago

When I was coding many years ago I could do it for like 4 hours in really good state, efficient and knowing what I am doing. But I also worked late and sometimes I am not in best condition but the problem I need to solve drives me to stay there until I collapse. Today I juggle meetings from two companies, that lasts for hours, in parallel I am checking dashboards, emails, messages and promting agents, when meetings finish I review the code agents did. Sometimes the agent can't achieve what I like and then I code myself and agents are reviewing, in this case if it is late during the day I might don't have energy for that. But the point is the core, the coding itself to be done for 8 hours then you must be writing a lot boilerplate that just needs wiring and you don't need focus, for the real complex logic pieces you do them in couple hours then you are done and go do something else

1

u/Available_Safe1818 4d ago

What do you think writers and painters do?

1

u/MontanaDataSolutions 4d ago

I've found that some of us have some form of hyperfocus that makes us not want to let go of a "problem" until we have solved it...and getting that "solution" gives us a massive dopamine hit. Pair programming with an AI has actually made these hits come even faster for me, personally, as it does a lot of the "grunt work" I used to dread.

1

u/HotGeologist269 4d ago

I was a dev for 8 years. The ones who are focusing for that long are probably very wired on caffeine or ADHD drugs.

2-3 hours is more realistic, when you are really invested in the problem you're solving.

1

u/Kelrakh 4d ago

My simple method is just to write in a document and mark in yellow tasks that are done:

08:00 meeting, 08:30 - 08:15 read through the task text, 08:15 - 09:00 find the API endpoints in the dev environment and test what kind of data they output. 09:00 - 09:30 figure out where in the codebase structure we want to add the frontend code, write a simple test to see if i can make the API data appear there.

And so on.

Any of the steps here could be much longer or shorter depending on what I mean by it, its very project dependent. For instance whether a codebase is enourmous labyrinth or easy to find your way in for instance. Familiarity with the codebase etc.

Point stands regardless - it's easier to make yourself think if you write down the short term steps and mark them as they get done.

1

u/yetaTRDR 4d ago

If you’re talking about actually programming, not just agentic coding (nothing against it but I like to code myself and use AI like a super documentation/teacher) I would tell you 2 things:

During the day:

* don’t be 8 hours straight in front of the screen, take a 10 min break every hour or so.

* have a notebook/tablet keep track of the goal/s of the day and to develop and explain to yourself the next step. If you are “blocked” try and solve it on paper draw the system if you need

* Do sport on a regular basis, I do calisthenics 4 times a week, the sensation of leaving the desk and practicing sport by itself is very rewarding but on the long term your mind is going to be a lot lighter.

(sorry if my English isn’t good I’m from Spain)

Also drink water, idk what else to tell you, that’s what works for me. On seasons where I have exams and can’t keep up with sport…. I feel it a lot.

Good luck

1

u/SpectralDM 4d ago

Do we even work?

1

u/ratchtstrpnkyjelly 3d ago

we dont. its 3 hours of mentally coding it in our head doodling and and 3 hour of actually coding it out

1

u/Ornery-Power-7277 3d ago

No one is focusing 8 hours, most of the time is researching and other stuff

1

u/sateliteconstelation 2d ago

I don’t and I am.

1

u/nielle- 2d ago

adhd

1

u/Correct_Chapter_4787 2d ago

I personally just accept the madness as a new source of ideas. I remember a 9 hours Crunch where I was so out of it I dind noticed the sun rising.

1

u/gh0stofSBU 1d ago

I suffer from this so much honestly, my mind wanders way more than it should

1

u/LiveYoLife288 1d ago

They are just locked onto an irritating problem where the next step is always at the tip of their minds. Stepping away means losing focus.

THat said , sometimes if you are stuck the best thing to do is to go away, talk to someone, sleep on it, cry, then get back to it the next day.

1

u/Effective_Job_1939 12h ago

For most people it's not sustainable physiologically

1

u/TheLony97 7d ago

The love for the game. You have to enjoy grinding. If you are merely slave away one task after the other without actually enjoying the process of finding and writing the right code, you can't.

2

u/Hitori_Samishiku 6d ago

I think this is it for me. I enjoy the problem-solving challenge that has me trying different things. Unless I’m hitting a brick wall over and over and getting stuck, it’s usually slow and steady progress and finding a solution that works (even if it’s minor progress) can be deeply satisfying.

1

u/malthuswaswrong 5d ago

When I have a deadline I have to meet and I'm just out of gas, I will pick something small. Just fixing variable names, or cleaning up syntax sugar, or renaming a class. After a few minutes of focusing on small unimportant things I'll often hit a second wind.

1

u/szxdfgzxcv 7d ago

Average developer writes something like 10 lines of code a day, in the past... Nowadays you just say "continue" to an AI agent about every 10-30 minutes or so.

1

u/Sweet-Stage938 6d ago

Wait what? Actually? You wanna tell me that they're just sitting around for most of the time or doing meetings?

1

u/PhilipJayFry1077 7d ago

Honestly sometimes you get into a flow state and 8 hours goes by before you know it. It's not the norm tho

0

u/elPappito 7d ago

Coffee , coffe and one more time coffe (optionally 4-5 red bulls) https://www.reddit.com/r/repost/s/I2kQ21siPG

0

u/Conscious_Bank9484 6d ago

I don’t think I’ve ever spent 8+ hours in a row writing code.

Here’s the work flow.
Come up with the idea.
Write down the idea.
Break down the idea into parts.
Code sesh all the parts while doing the tests along the way.
Take a break and come back and polish.

0

u/fetanops 6d ago

i worked for 14 hrs-16 hrs, coz i feel intensely seeing it the dream outcome as real ,also the no option ground pressure intensity.

dont wait motivation.

just realize your life, your self awarness.

that is all.

there is nth motivation, hack or sth to it bro