Ask HN: I lost my ability to focus for hours on coding. How to regain?
I lost my ability to focus. I check social media and youtube frequently while doing work. If I do not do that I feel some void and feeling of losing out(I do not know how to express this).
How to regain my focus and avoid this trap?
126 comments
[ 3.6 ms ] story [ 185 ms ] threadIt's old knowledge but : "A Healthy mind needs a healthy body" stays true.
Social media and Youtube may be stealing your attention because you simply enjoy them more. If coding was more enjoyable, you'd be doing more coding at the expense of those distractions.
But maybe you just don't enjoy coding your current project. A lot of projects are not intellectually or morally stimulating, and it's hard to stay excited about them, particularly if your work culture is the least bit toxic.
Being a manager means dealing with people, and a lot of experienced coders actually get more out of that than out of JIRA-code-Git-repeat.
Some people will claim that is a crutch. Thats a great analogy because crutches help you get things done while you heal.
https://heyfocus.com/
On Windows, I add websites to the hosts file as others have suggested: HN and Google News are the main ones, I gave up FB long ago.
Doing this still doesn't get you back on track coding / focusing, but it helps. The idea is to break your habit of visiting distracting sites - where these apps help - but also build a habit of work. The more you make it a habit, the easier it becomes over time.
echo 127.0.0.1 facebook.com twitter.com ycombinator.com youtube.com>>"%WINDIR%\System32\drivers\etc\hosts"
There's an occasional crunch where I have to heads down get something done, but in that case there is actual motivation to be heads down and get things done.
I find a due date way more motivating than a mere thought of "I should be working...".
Overall, if I'm not already focused in, it's because it's something not as important as other things in my life.
I was having focus issues, because coding is fascinating but not inherently sexy to me. After working on a problem for a while, the enjoyment of the problem would become overshadowed by my sex drive, and I would start to find anything else more interesting. Ended up being my body's way of reminding me that I should make some babies before I died, so I was subconsciously distracting myself away from anything fascinating that wasn't the opposite sex.
Crude, well... to be honest, because of the slang words, eg. 'getting laid' and your argument could have been framed better to be more intellectually stimulating. Taboo, well.. because I don't see anyone else talk about this, yet it's such an important topic of human psychology / sociology.
I definitely could've swapped out "getting laid" with something more elegant sounding, such as "engaging in intercourse" or "stimulating a release of oxytocin", but I assumed that "getting laid" is both socially acceptable and has a well understood definition. Apparently HN disagrees!
I don't consider sex as a subject to be taboo, especially from a health standpoint. People get degrees from major universities that are entirely sex-related. So I guess I'm just a little confused by all responses, especially the one from hi41. Thanks for explaining your reasoning, it's good to hear the process behind these differences in opinion.
https://www.amazon.com/dp/B00X47ZVXM
Fwiw, I'm in my mid 40s and have less than a year of treating my sleep apnea. I'm pretty sure I've had ADHD my whole life but blamed other things until recently. I'm trying to resist getting medicated, but I think I might it to get me focused enough to work on CBT and meditation.
If you have medical issues - take care of medical issues in the best way possible.
Challenging yourself = denying yourself treatment.
Challenging yourself is not a treatment for something like sleep apnea.
This statement is so out of line I had to chime in. I was diagnosed with ADHD as a child. I was medicated for a few years, before I stopped taking the pills without telling my parents (they were being pressured by the private school I was in to medicate, I was kicked out shortly after they found out I had stopped.)
Those years are a complete empty window in my memory, and left me with physical ticks that _decades_ later I still have to suppress, alongside no actual tools for dealing with the symptoms.
Medication is not a silver bullet. Not all ADHD cases need to be medicated. Find what works for you, whatever the hell that is, and don't listen to dogma. For me that was coping mechanisms combined with a realization that much of the "attention deficit" was because I _didn't want to pay attention to the shit I was supposed to_ and _that's completely reasonable._ To insinuate that I haven't tractably found success ("baseline normal") with a non-medicative approach in my life is frankly insulting.
Parenting is stressful and imposes a powerful incentive to reduce that stress. Consequently, too often in children, mental health treatment focuses on controlling behaviors because the person seeking treatment is the parent.
The first is a person seeking greater agency for themselves over a problem. The latter is a denial of agency of the child. I’m hearing you express your pain at having your agency suppressed and expressing skepticism at the tools used to suppress your agency.
But those same tools also grant some adults an agency they are desperately drowningly seeking for themselves.
Genuinely interested in hearing your story.
2. In large part, reminders. Notes, lists, alarms (calendar/phone alarms for _everything_, watering plants to finishing work shit), behaviorally trained prompts, anything to disrupt the "mental feedback loops" where I can find myself "unconciously" falling into something like tearing at my fingernails, reading HN, playing video games, or really any of the infinite things I'll come up with to not do what I should be doing.
e.g. even right now writing this, I'm being pinged to go back to reading PRs: after years of having automated browser alerts going "hey you shouldn't spend time in this video game/on hn, it's been 20 minutes and you have nothing to show." my brain has picked that up and is able to do it on its own. I found that hard blocking didn't work since I'd just find ways around it, but if I can remind myself this is something I _want_ in any way from pragmatism (mortgage) or emotional (getting wife nice things) whereas the games/Hn are actually _unwanted_ (despite what the dopamine might say) it's easier to force myself to focus on something I don't want, even in bursts. (getting myself to internalize and BELIEVE those facts took years and I still fight with sometimes when willpower is low.)
This was a bit of a ramble, and I'd be remiss to mention that the motivation to use the prompts would be missing without the philosophical context I assign to the things I do. (Disclaimer: I recognize not all people can use this technique, I simply use the fact that I have strong long-term motivations against my bad short-term focus) I mentioned it in passing (mortgage, wife, etc) but really finding things I _WANT_ and using my brain's likelihood to fixate on those, especially in periods of distraction, I can tie those things back to what I SHOULD be doing and create a virtuous cycle. Contrivedly: Distracted looking out a window at garden. Fuck, I can't afford this garden if I don't go back to coding. (Dang, this HN post is getting long. Better get back to work so I don't work late today and can spend time with the wife when she gets home :) )
1) stimulants and narcotics are two very different things, with diametrically opposite effects.
2) Not everyone can improve performance, due to U-shaped response curve. Those that are functioning optimally will actually see their performance decline.
3) ADHD is one of the best understood disorders. Impaired working memory (i.e. ability to concentrate) can be easily diagnosed quite definitively with CPT: https://en.wikipedia.org/wiki/Continuous_performance_task
It is of course personal choice in the end to decide on treatment, but if the ability to concentrate is in the bottom 1-5% - it is going to be painfully obvious to any half-decent paediatrician.
(uk private in my case, though I imagine people in other places would benefit from wider answers.)
CPAP only works on the expiratory valve - which is your soft palate.
If you are having a large number of arousals, despite optimal CPAP pressure, and your respiratory waveform is jagged in certain ways (hard to describe in text) - you are very likely having epiglottic collapses.
However, epiglottic collapse can only be definitively diagnosed by sleep endoscopy.
Epiglottic collapse can only be treated surgicially.
The thing is, I can focus on stuff I really want to do, but I can't fake the want. So - my personal pet projects are doing fine. As for work, my life has improved tremendously since I sort of gave up careerwise. These days I drive a bus and actually have some mental energy left over for my sparetime. No medication. I don't like the idea.
In my experience: its hard to get started, but when I'm in the flow I know that I can do this. Start with simpler tasks (small wins).
It's kind of like chat roulette (before it got weird) for study buddies. I'll admit the premise is a bit odd butt don't knock it until you've tried it. Essentially, you're paired with a random partner for a 50 minute mostly-silent video chat. You spend the first minute or two saying a quick hello and each definitively stating what you're going to accomplish in the hour and then you get to work (separately - they're very clear it's not for collaboration). When time is up you both report back on whether you did what you set out to do. And while you get to work the corner of your screen has a little live stream of your partner diligently working.
Not only does it help keep me "accountable" and working pretty efficiently for the full 50 minutes but it's also made me so much better/more realistic about estimating what can be accomplished in that time.
In my case, that's a chatty coworker. Every time he yanks me out of my flow, I get the urge to check social networks and have a really hard time going back to deep work.
A family friend of mine used to play violin in a traveling rock band. He slept in the van and loved every minute of it. Later, when he had a family, he settled down and became a contracted fundraiser for non-profits. One day he came across a particular non-profit that he loved, identified with, and felt excited by. He took a 50% pay cut and settled into a permanent position with that company because "it felt like being back in the van again"
If you're the kind of intrinsically-motivated person who can trick their head into being excited about 12 hours of being immersed in a problem, then you'd be an incredible asset to any company that gets you excited.
If you have an idea of what company, industry, or problem that might be (good news: people usually do), pursue it like hell.
At least for me, productivity requires momentum and being at a standstill feels like quite a hurdle. So at least at first, work on something you're really excited about. Something that won't feel like work. It could be a small project you couldn't otherwise really justify spending time on, but do it anyway. Visualize the end result, get yourself excited, and finish it.
Once you've gained some speed you should be able to tackle other tasks and projects. Social media will start to seem less compelling than it does now.
When I'm hot on a new video game, I can't wait to fill the most immediate next hours on doing it. What was that for you at some point? I enjoyed QBasic in gradeschool and revisiting after years in the field was really fun.
Whatever that code is, I suggest pursuing it even if it's not
a) something everybody on here says we need to be doing
b) related to your dayjob
c) related to that "big project" that you need to do perfectly
I wish you the best.
P.S. strike perfectionism out of your mind
P.P.S: Practically look into using the Pomodoro Method
P.P.P.S: Either start or stop doing drugs. Or see a board-certified medical professional if you think that would be dope. It is.
edit: formatting as always
You can try and force yourself to focus with tools and mental tricks, but that always seems to make me feel worse. Better to get at the root cause, which is almost always stress or physical exhaustion.
The quicker you distance yourself from social media the healthier you will be. There's literally everything to gain by leaving it behind.
Electronic music also helps me, but this is counterproductive for some.
My coworkers usually get a slight shock when they learn what kind of music I have in my headphones during work, being a 50 year old guy :)
There may be a free trial, and I think there is a free tier with ads if you can tolerate them.
Eat well. Sleep well. Exercise. Dress for success. Socialize, integrate with the team, find the goals that will motivate you - be that helping out your work buddies, or building that sweet new piece of technology.
You want to have energy, health, mood, and motivation. When any of these suffer, your work suffers too.
Don't be afraid to use whatever tools you have at your disposal to cut out distractions and inhibit bad habits, but don't tyrannize yourself either. Working 8 hours straight isn't necessarily your most productive option. Consider scheduling breaks - but use your tools to limit your distractions outside of said breaks. Find a balance that will let you keep your mood up while also getting good work done.
That said, while I've cut back a lot, you can pry my energy drinks out of my cold, dead, caffinated hands.
One of these is not like the others. I can understand emphasis on dressing up in contexts that involve selling -- a product, an idea or even yourself. But what does it have to do with focus?
That said, it doesn't need to be a 3 part suit.
But if you're showing up to work poorly shaven, wearing stained sweatpants - you're going to be at least a little more self concious, a little less self confident. Nobody's going to lift your mood with "hey, looking sharp!". It's going to reflect in your body language, and the body language in your peers, even if it's largely on a subconcious level.
It's potentially the difference between being ready to walk to lunch, or a meeting, or an interview at a moment's notice - ready to actually tackle the work and the day - vs being ready to go to bed at a moment's notice.
https://wiki.nikitavoloboev.xyz/focusing
Mostly it’s about practicing mindfulness throughout the day, setting goals, GTD approach of task management and using tools like Focus for automated Focus sessions throughout the day with breaks in which I am allowed to read news and relax.
Also, might give me some inspiration to make my own wiki ;)