r/learnprogramming • u/Used-Persimmon7962 • Oct 06 '26
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.
400
Upvotes
565
u/throwaaway788 Oct 06 '26
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.
227
u/BranchLatter4294 Oct 06 '26 •
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.
53
u/psyduckpikachu Oct 06 '26
I have adhd so hyperfocus is just my thing
17
u/_curious_man Oct 06 '26
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
15
u/5eeso Oct 06 '26
I don’t code for eight hours straight and I don’t recommend you do either.
47
u/desrtfx Oct 06 '26 edited Oct 06 '26
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.
25
u/InfectedShadow Oct 06 '26
That's the neat part. We don't!
8
u/Cool-Bus-6028 Oct 07 '26
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.
7
u/ThatLaw6894 Oct 07 '26
Working on something "interesting" that's really challenging
12
u/zoddy-ngc2244 Oct 06 '26
You have to work in a sustainable manner.
6
u/TheSneederOfSeethe Oct 07 '26
I have in fact lost my mind and it’s how I stay in the zone.
5
u/BaNyaaNyaa Oct 06 '26
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.
5
u/sylvant_ph Oct 07 '26
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 Oct 06 '26
I have adhd and hyper focus on it. Hope this helps.
4
u/royaltheman Oct 06 '26
Adderall used to be real popular with programmers
7
u/Stainlessray Oct 06 '26
Mostly you try something and poof eight hours is gone.
7
u/Br3ttl3y Oct 06 '26
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.
6
u/lil_natemushi Oct 06 '26
Devs are already nuts, no sound mind to lose.
6
u/Thykon Oct 06 '26
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.
6
u/Hayyner Oct 06 '26
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 Oct 06 '26
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.
3
u/fuckunjustrules Oct 06 '26
we don't
3
u/WandSoul20 Oct 06 '26
Stimulants
3
u/Lichcrow Oct 06 '26
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 Oct 06 '26
Adderall
3
u/chhuang Oct 07 '26
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
3
u/WangHotmanFire Oct 07 '26
Classical music. I really love rock and metal but it’s way too distracting, classical always does the trick
4
u/Positive_Passion4817 Oct 06 '26
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 Oct 06 '26
2
u/the_other_Scaevitas Oct 06 '26
Lots of breaks in between
2
u/atgaskins Oct 06 '26
you enjoy problem solving with your trade
2
u/darcygravan Oct 06 '26
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 Oct 06 '26
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_ Oct 07 '26
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 Oct 07 '26
Dude I watched a 12 episode Anime today at work
Edit: and I still finished my work
2
u/Holiday-Medicine4168 Oct 07 '26
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 Oct 07 '26
no one works for 8 straight hours. That's the myth AI is helping debunk and it's driving CS holders mad.
2
u/BachiNoHito Oct 09 '26
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/sricho93 Oct 24 '26
An 8 hour work day is the cost required to achieve 1-4 real good hours of work. That does not mean the other 7-4 hours are wasted....just that they do not look like the 'focused' or 'locked in' sprints of energy you may be imagining.
There are outliers of course. Obsessive workaholics and/pr people working under crunch time.
1
u/Certain_Blueberry554 Oct 25 '26
Taking 20 minutes break in between after about 3 hours and a recahrge..Also im always plugged in with soft music
1
u/rosensjs195 24d ago
more or less we are not responders but the FBI related workplace peer support text is pretty interesting because it talks a lot about like working too much, sleep disorders, stressors, all sorts of shit.
1
u/Trick-Maybe-7783 20d ago
Did AI increase the number of distractions from other departments in your companies? In our company we increased the speed of shipping features as well as breaking things and now engineers are just fire-fighting or handling requests from marketing, data, seo teams.
1
u/Winter_Weekend8883 20d ago
I usually have music or something playing in the background.
1
u/vegan_antitheist Oct 06 '26
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 Oct 06 '26
Caffeine bro
1
u/Mediocre-Brain9051 Oct 06 '26
Not 8 hours straight. There's always more stuff to do than only programming
1
u/SnugglyCoderGuy Oct 06 '26
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/High_Quality_Bean Oct 06 '26
Practice, flow state.
Surgeons can stay in flow state for even longer than we can
1
u/HowardBateman Oct 06 '26
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 Oct 06 '26
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 Oct 06 '26
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/marrsd Oct 06 '26
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 Oct 06 '26
Amphetamines
1
u/coffeebeezneez Oct 06 '26
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 Oct 06 '26
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 Oct 06 '26
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 Oct 06 '26
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/fasta_guy88 Oct 06 '26
Reddit
1
u/Jhamilton02 Oct 06 '26
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 Oct 06 '26
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 Oct 06 '26
2 hours at a time....
1
u/pieeatingchamp Oct 06 '26
I feel like I spend more time in meeting than coding now. Sucks
1
u/Shadonic1 Oct 06 '26
Locking in and getting pissed off at not understanding a bug.
1
u/Esseratecades Oct 06 '26
We don't. Every half hour or so our manager interrupts for some meeting that we don't care about.
1
u/ruat_caelum Oct 07 '26
https://xkcd.com/303/
1
u/Pale_Height_1251 Oct 07 '26
We rarely do. Most of us are working a few hours a day really.
1
u/Wartz Oct 07 '26
They dont code for 8 hours straight. Unless on well balanced cocaine drip.
1
u/Electromasta Oct 07 '26
because its fun
1
u/Zhunix Oct 07 '26
Good music
1
u/pirhana1997 Oct 07 '26
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 Oct 07 '26
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 Oct 07 '26
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 Oct 07 '26
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 Oct 07 '26
Hard problems keep me motivated. Routine stuff is a real chore though.
1
u/ZealousidealHeight15 Oct 07 '26
same way any other job does…
1
u/CornPop747 Oct 07 '26
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 Oct 07 '26
They stop commenting their code and writing out long descriptive function and variable names.
1
u/CosmicDevGuy Oct 07 '26
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 Oct 07 '26
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 Oct 07 '26
We don't... we have lots of meetings nowadays
1
u/warriorofjustice Oct 07 '26
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 Oct 07 '26
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 Oct 07 '26
We don’t. All crazy. 🤪
1
u/Zestyclose_Paint3922 Oct 07 '26
They don't. Are you insane?
1
u/KickedMeHeight Oct 07 '26
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 Oct 07 '26
Oh, they don't.
1
u/ZealousidealMajor320 Oct 07 '26
We are not human!
1
u/cheezballs Oct 07 '26
Focused?
1
u/Marteein Oct 07 '26
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 Oct 07 '26
I cant
1
u/silver_splash Oct 07 '26
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 Oct 07 '26
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 Oct 07 '26
1
u/Far_Programmer_5724 Oct 07 '26
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 Oct 07 '26
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 Oct 08 '26
because when you are in the zone you don't realize time passing. Haven't been there in a long time.
1
u/cumwuatto Oct 08 '26
That’s the neat part. We don’t.
1
u/turrboenvy Oct 08 '26
Caffeine
1
u/Abled_Gaming1357 Oct 08 '26
Who said we don't lose our mind?
We lost it the moment we got into corporate mate.
1
u/LosttMutaliskk Oct 08 '26
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 Oct 08 '26 edited Oct 08 '26
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 Oct 08 '26
Who said we haven’t lost our minds? 😂
1
u/Flat-Performance-478 Oct 08 '26
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 Oct 08 '26
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 Oct 08 '26
Because it is genuninely fun to build things.
1
u/SprinklesFresh5693 Oct 08 '26
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 Oct 08 '26
Wet don't
1
u/amnion Oct 08 '26
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 Oct 08 '26
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/cdm014 Oct 08 '26
Haha some days the meeting to coding ratio is even. Some days meetings win
1
u/yaplex Oct 08 '26
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/Ok_Assistance9872 Oct 08 '26
drugs
1
u/DistributionOk9555 Oct 08 '26
We don't. Regards
1
u/Few-Spot1905 Oct 08 '26
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 Oct 08 '26
Browsing Reddit in-between hitting enter in Claude code
1
u/TheTakingGiver Oct 08 '26
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 Oct 08 '26
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 Oct 08 '26
For the love of solving problems
1
u/Outrageous_Band9708 Oct 08 '26
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 Oct 08 '26
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 Oct 09 '26
Adderall.
1
u/Snoo-98048 Oct 09 '26
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 Oct 09 '26
What do you think writers and painters do?
1
u/MontanaDataSolutions Oct 09 '26
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 Oct 09 '26
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 Oct 09 '26
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 Oct 09 '26
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 Oct 09 '26
Do we even work?
1
u/ratchtstrpnkyjelly Oct 10 '26
we dont. its 3 hours of mentally coding it in our head doodling and and 3 hour of actually coding it out
1
u/RadziCicinasMinedas Oct 10 '26
Drugs
1
u/Ornery-Power-7277 Oct 10 '26
No one is focusing 8 hours, most of the time is researching and other stuff
1
u/sateliteconstelation Oct 10 '26
I don’t and I am.
1
u/nielle- Oct 11 '26
adhd
1
u/Correct_Chapter_4787 Oct 11 '26
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 Oct 12 '26
I suffer from this so much honestly, my mind wanders way more than it should
1
u/LiveYoLife288 Oct 12 '26
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 Oct 13 '26
For most people it's not sustainable physiologically
1
u/Existing_Put6385 Oct 16 '26
Most of us don't focus for 8 hours straight, it's more like 3-4 real hours and the rest is meetings, emails and half-focus. What helps is cutting the stuff that breaks focus: phone in another room, notifications off, one clear task written down before you start. Work in blocks of 50-90 min then actually get up for 10, and get some sleep and a walk in, those matter more than any app. Also focus is a muscle, so start with 25 min and build up, don't try to jump to 8 hours.
1
u/TheLony97 Oct 06 '26
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.
1
u/szxdfgzxcv Oct 06 '26
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/PhilipJayFry1077 Oct 06 '26
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 Oct 06 '26
Coffee , coffe and one more time coffe (optionally 4-5 red bulls) https://www.reddit.com/r/repost/s/I2kQ21siPG
0
u/Conscious_Bank9484 Oct 07 '26
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/Super-Award-2244 Oct 06 '26
I think it's partly a ADHD thing. "OK, I think this was the last bug" But then you find another one and another one and you are physically obligated to solve everything until you can't physically bear it anymore
0
u/MikeIsBoi Oct 09 '26
I personally just get into a flow state. It's like you keep thinking of ideas. If they don't work you brainstorm new ideas. But of course you have to enjoy the process, seeing each brainstorm idea bring you closer to the solution, it's kind of addicting.
0
u/_Madsen Oct 13 '26
I don't think it's realistic for most people to stay fully focused for hours.
One thing that helps me is working in 45-minute blocks with a short break in between. The short break may just be to refill a water bottle, get some coffee, or reading some news. Avoid task switching directly.
I've been doing it since university, and it's still one of the best ways I've found to stay productive on tough days. It's not a strict approach, I only do it when necessary.
1
u/lellamaronmachete Oct 06 '26
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.