Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: I lost my ability to focus for hours on coding. How to regain?
142 points by codesternews on April 18, 2019 | hide | past | favorite | 122 comments
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?

There's a lot of factors that might go into this. If you're hungry, sleepy, undersocialized, unkempt, unfit, depressed, in a loud, messy, and distracting office, with unclear and unexciting goals, large monolithic tasks without clear breakdowns on how to move forward, constrained by slow tools, management, or blocked on dependencies... well, it'd be no wonder you wouldn't want to work!

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.

I just want to add that coffee can make you feel like you are having enough sleep when you are not. If you drink it constantly, you may be just tired but not know it.

I can't tell if this is an endorsement of or warning against using coffee to mitigate a lack of sleep, so I will take it as reinforcement of the former which I am currently (and unfortunately) a practitioner of.

Caffeine has a half-life of about six hours so it can affect your sleep without necessarily knowing it leading to bit of a vicious circle. If you are interested, Dr. Peter Attia has a three part episode with Dr. Matthew Walker on sleep. It changed the way I prioritize getting sleep.

Why not both? It can help, but it does not fix the underlying issues. And those underlying issues may have long term health and energy conseqeunces.

That said, while I've cut back a lot, you can pry my energy drinks out of my cold, dead, caffinated hands.

If you want the best effects of caffeine you have to cycle it. Save it for those special occasions where the real positive benefits of caffeine can work for you and the negative long term effects don't work against you.

> Eat well. Sleep well. Exercise. Dress for success.

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?

It doesn't necessairly need to be "dressing up" per se.

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.

Mayhaps not as necessary as the first two, but having separate wardrobes for work and free time can help trigger you into a work mindset.

That said, it doesn't need to be a 3 part suit.

I have found that if I wake up feeling like crap, I feel just a bit better if I put on a bowtie that day.

This is a common problem. The book Deep Work goes into it in detail, and has some research-based techniques to fix it. Basically it boils down to removing distractions, and determination, gradually building up your brain's ability to focus again.


If I try eliminating distractions, I just end up daydreaming. I spend most days at work just reading the same shit over and over with nothing sticking. I manage to get work done in rare bursts after exhausting my brain with distractions.

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.

Add a decade, subtract the apnea, but otherwise: Welcome to my world, or an exact replica thereof.

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.

Don't medicate but challenge yourself. Learn a new editor while doing your job. Try using Windows instead of using a Mac. Try typing only left handed. There are varioud challenges to overcome boring assignments. Also try a standing desk so if you skive then you must stand up for fifth teen mins.

the worst advice ever.

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.

Yes but the evidence for ADHD is dubious. We have a long way to go when it comes to understanding the human mind. Anyone, not just people with ADD, can increase their performance with narcotic stimulants. Just don't be disingenuous about it.

Just because ADHD is poorly understood and often diagnosed incorrectly does not make it any less debilitating to those who have it and certainly does not imply that they are not in need of medication. Yes the medication can be abused by those who don't need it to get an edge. This is what makes it a controlled substance. Opiates can be abused too and have the same effect on everybody. The difference is that people in server pain need opiates to function at a baseline normal level. People with ADHD need medication to function at a baseline normal level. The fact that some people abuse them to go beyond that is completely irrelevant

> People with ADHD need medication to function at a baseline normal level.

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.

In Adults outside a courtroom, mental health treatment focuses on easing distress because the person seeking out treatment is the patient.

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.

1) have you ever had psychometric testing done? 2) what are you non-medication coping techniques?

Genuinely interested in hearing your story.

1. I might have when I was initially going through a ream of behaviorists, but I'd be lying if I said I recalled, this was around/after 3rd grade.

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 :) )

You are spreading mis-information. Attention, and lack of it, is something humans have understood for thousands of years.

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.

I can say medication has done wonders for my professional life and has made me much happier overall. For anyone on the fence about trying medication, I would say it is certainly worth it.

Do you have any tips on finding a project manager whom you can videochat or email with and ask for help with the project of navigating the healthcare system?

(uk private in my case, though I imagine people in other places would benefit from wider answers.)

that's called a well-connected private GP, or, if you are rich enough - physician in chief of a large hospital/center.

That's bad advice for me. For instance, I was supposed to be working on finalizing a new feature. Instead I was obsessed with writing tool wrappers. I learn things all the time, but they seldom relate to the thing I'm supposed to be doing. I'll bounce around instead of deep diving through the codebase I'm responsible for.

Holy shit, same boat, same age, on CPAP for about a year now, can't remember what was said in the meeting I was just in this morning. And browsing HN while I should be writing tests ;)

Your apnea could be undertreated, or it could be a symptom of a bigger problem. Epiglottic collapse is not uncommon in apnea patinets (10-15% of cases), and is not treatable by positive pressure, as it is an inspiratory valve.

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.

Or simply go to a doctor specializing in it and check with him what they think. If they suggest trying something - try it and see if it works. I was in the same boat. Can't really say it was a miracle, but it definitely helped a bit.

I would add that _almost anything_ that requires focus for a period of time can actually help you out. This book talks about the benefits of learning to memorize a deck of cards - just you and a deck of cards in the morning (no phone, no computer), can help "repair" your ability to focus.

Another suggestion: https://sivers.org/book/PracticingMind

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).

Have you been able to put any of these techniques into practice? It's been a few years since I tried reading it, but I wasn't able to push through the fluff to make it to the practical advice.

Thank you for sharing, this looks like a nice reference (although the irony of obtaining this link via hacker news is not lost on me.)

The real trap is feeling like you need to be focused eight hours a day when it's not strictly needed.

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.

  echo " facebook.com twitter.com ycombinator.com youtube.com" >> /etc/hosts

Windows Edition (admin command prompt):

echo facebook.com twitter.com ycombinator.com youtube.com>>"%WINDIR%\System32\drivers\etc\hosts"


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.

The browser extension named Momentum is also useful for this.

When this happened to me I got a ton of advice (similar to what’s been written by other posters) and it was all great.

But to make any of it to stick I had to stop thinking of my productivity as some intellectual problem and myself as the master of my attention.

You’re not in control of most things. You’re trying to steer an elephant. Accept it, it’s easier and it’s true.

Then — with a slightly more realistic view of yourself set up processes and guardrails to keep your brain in line. Stimulus control sounds like a good first step. Check out StayFocused for Chrome and then delete all other browsers.

Add or remove one thing a week until you’re where you want to be. Good luck.

I came across this discussion and this video recommendation one after the other :) https://www.youtube.com/watch?v=Hu4Yvq-g7_Y

I had that issue two months ago. I digged into my calendar and found out that's when I stopped going to the swimming pool, doing enough physical exercise.

It's old knowledge but : "A Healthy mind needs a healthy body" stays true.

I tried exercise, and now that's all I want to do. Ugh...

I know that feeling; it's addictive, because it feels so good. Make sure to take rest days, otherwise you might injure yourself from not giving the muscles and tendons enough time to repair.

I've had this happen before. For a six-month period I was able to finish my day's work and then head home and spend another 3-4 hours focusing on my own stuff. After having a three-week vacation, I lost this ability. I couldn't focus anymore. I was back to being a regular person.

Things I did to get my focus back:

One is that I introduced sugar/caffeine back into my diet. Drinking a sugary, caffeinated beverage improves my ability to concentrate significantly. While this might not be right for you, you might find that some of your other dietary choices are affecting the supply of glucose to your brain.

Another is routine. If you had the ability before, you can get it back again. One thing that helped me return to my groove was listening to the same music I used to listen to while concentrating. Having an album in the background on repeat can work wonders. Maybe there are some other important concentration triggers that you need to tap into.

Lastly, maybe your work just isn't that interesting. Rediscover what things you actually want to be working on. Get excited about something again.

Use tools such as SelfControl.app, ColdTurkey.app, and Freedom to block websites.

Some people will claim that is a crutch. Thats a great analogy because crutches help you get things done while you heal.

Focus is another one I really like on the Mac - it replaces websites with a different quotation each time:


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.

I have a similar problem which is ruining my life. Not only I cannot focus on my work, I cannot focus on anything. I'm throwing my degree and my life down the toilet.

There's no light at the end of the tunnel right now. It's the worst feeling I've ever experienced. I know what I should do but I can't.

Stress can make it difficult to focus, and being unable to focus can cause stress in our field. So, there's a positive feedback which is horrible to experience.

Having experienced this myself recently (a few months ago, for about a month acutely), the solution that worked for me is to cut the cycle at the "inability to focus causes stress" part. Just accept it - right now, you can't focus, and that's okay. The second part of my solution was to remove all distraction, and for periods of work I allowed myself to not focus on work, but I also agreed (with myself) to not allow myself to focus on other things, either. Eventually, a combination of stress reduction and simple boredom got me working productively again. :)

I've experienced this before, and last time I used medication (Adderol) to fix it. I think that's a valid way to break the cycle too, although I would recommend the above procedure first.

Note: This is a special application of the more general observation that most suffering comes from feeling bad about feeling bad, not the original feeling bad part. So, if you can stop feel bad about feeling bad, you don't have to worry about the first-order feeling - it will go away on it's own quickly, because feelings naturally decay pretty quickly. Also, if you want to talk to someone you can contact me via my profile.

I would suggest looking into Neurofeedback treatment. It is possible to strengthen the focus networks in your brain and that could change everything. The treatment was pioneered by the researcher who runs this center in Canada. http://addcentre.com

Hang in there, you'll figure it out.

what if you try to focus on something that you really want to do and not on something you have to do?. i.e. Plan to visit a new country and work from there a couple of weeks. Something that I did when I felt like that is check all the meetups around town and meet really interesting people that ended up being good friends and help me to see things with a different point of view

FYI, planning a trip to a new country is a pretty Executive Function intensive task. As an immigrant and frequent traveler, I would say this could be a bit Hard Mode.

Changing the color scheme in your editor can make your work seem novel again.

Electronic music also helps me, but this is counterproductive for some.

Yep, good underground techno mixes at 125 or higher bpm can give you the drive and concentration you need for extended periods of time.

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 :)

Do you have a public playlist?

Digitally Imported is pretty great. I've subscribed for years alongside Spotify and prefer it for set and forget playback of a genre of electronic music. Spotify is for specific playback and discovery.

There may be a free trial, and I think there is a free tier with ads if you can tolerate them.

It sounds trivial, but I find a pen and notepad to be helpful.

I write down a list of tasks I want to accomplish that day, and then tick them off as I go. Once I get to the end of the list, I'm done for the day and can have a beer (or go to the gym, depending on the day) :).

Then the next day it's rinse/repeat.

Recognize that your FOMO (fear of missing out) is greatly amplified by social media and that using it only makes the situation far (far) worse, leading to more distraction, leading to more social media use, which feeds right back into the vicious cycle.

Learn to live without social media -> watch your life improve.

It's as simple as that.

Delete your accounts, including Twitter. Find other ways to stay connected to timely information. Treat it as a good challenge that you _can_ succeed at, as something that will make you stronger and healthier in the end.

For me, this means that a) I am not interested in my work, b) I am tired, or c) I am burnt out. All of these can be greatly helped by getting some good sleep, and a + c can be helped by having some fun - especially social or physical activity somewhere new (weekend trip, drinks with friends, etc).

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.

I had a similar issue recently and during one of my many afternoons dicking around on the internet to avoid work I actually found a solution that worked surprisingly well: FocusMate.com

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.

I had to completely clear my mind of the past, and of what others may think of my project/code. It's a brand new day, you're breathing, you can truly work on whatever you want.

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

Could something else trigger your distractions and then spiral you into out of topic behaviours?

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.

The problem is you mixed work with other things and since other things are less boring and less challenging your brain escapes to them semi-automatically.

Quick and dirty hack is change your surroundings. Go to another room, sit at different desk, on different chair, on a different clean computer (with different os?). Don't open any of your usual distractions there. Block them in hosts file (don't even check if you blocked them successfully).

You'll regain bit of your focus. At least till you leatn to slack off there too.

This happened to me.

The void feeling is Depression. Youtube distracts from it, but reliance on distractors is only a symptom.

There are many kinds of depression, distinguished first and foremost by what treatment works on each.

That is the reason that "gold standard" double-blind trials fail to find that anti-depressants work. Imagine if you couldn't distinguish a broken arm from a broken leg, a broken humerus from a broken ankle. Trials of a cast on the left lower leg help only a few people, on the right only a few; left upper arm, right forearm, yada yada. "Casts are ineffective!"

Take the wrong meds, nothing happens. Take the right one, miracle!

There is no shame in medicating a problem: "If you can't make enough of your own serotonin, store-bought is fine."

It is entirely possible that losing 50 pounds, or exercising devotedly, or dropping carbohydrates and alcohol from your diet would also fix it. Medicate first, and then see if those help. There is no end of benefits to these other measures, but you need to get your brain working right first, or you set yourself up to fail.

In my case I was fixed up only two days after getting a sufficient dose of the right thing. A smaller dose had no effect, and other meds had no effect. Some kinds take weeks to build up before anything happens. I had five serious side effects (dry mouth, jaw clenching, ears ringing, dizzy spells, one more I don't recall) that passed after a few months.

You can get past this, with help. Get help!

Use the Pomodoro technique and limit your social media checks (if any) to the scheduled breaks that the technique provides for you. In general, it's also highly desirable to enter a flow state as quickly as possible (this is what "focus" really is, after all) and there are ways to make this more likely, such as starting your session with easier, lower-stress tasks and moving on to harder stuff incrementally.

For me, I find this is more about fear/dread. I don't procrastinate on social media when I'm doing something well.

You'll have to find a way past that fear. You can:

1. Be braver - admit you're afraid and do it anyway.

2. Find the root cause of fear. Maybe you've dealt with too many death marches. Maybe you don't feel like you can meet your expectations. Just admitting it can make it go away.

3. Plan it out in a way that nobody can screw it up, not even you.

I'll probably catch some flak for this, but if this is just a short term hurdle during a single project get your hands on some adderall. If it continues for more than a couple weeks even when you're working on something you are passionate about put the pills away and take some time off away from the keyboard to try to decide if this is an issue of focus and distraction or just burn out.

I would guess that your lack of concentration is due to boredom, maybe because you're working on stuff you don't care about. If circumstances requires you to work on uninteresting things, putting the distractors out of easy reach can help you grind away in the short term. In my own experience, I needed to change industries to work on things I found more interesting.

Talk to your supervisors about how you aren't excited about your tasks at work. If there's nothing they can do about it, quit. Find something that excites you.

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.

Stop all use of these sites for a month.

See if other "distractions" take their place.

If no, then you're just addicted to social media and hopefully that month will cure you.

If yes, you're probably burnt out and need to move to your next exciting new job, or move house, or go on a road trip for a few weeks or whatever it is people to deal with burn out.

I have a hard and fast rule to never use a work computer for anything except work. Also, enforce rationing your use of FB to after 7pm for 15 mins max. You'll find the hours spent wasted can be summarized in a 15 min block. The key for me is hard and unbreakable delimiters.

Regarding the "some void and feeling of losing out(I do not know how to express this)" - "The Willpower Instinct" is a book that covers that exact feelings and how to address it. Unfortunately I am too lazy to find the exact location in the book for you.

Something like this requires dedicated and deliberate behavior modification to fix.

You've essentially developed a habit. Like others have said, this might be caused by various factors, so look at what's lacking in your life and try to fix that, but afterwards you may need to create a plan in writing to correct the behaviors of the habit that has formed, because otherwise, even if you fix the root cause, the habit might still remain.

As for how? That's a good question that I don't yet have the answer to. I'm working on the first part myself. After I fix my root cause, I think I will fix the habit via a combination of lists and daily resets (i.e. no old tabs on the computer the next day).

Social Media Trap -- I installed the Leechblock extension for Firefox which helped me a bit. Also going to special places like silent libraries is helpful for me to concentrate. As final escape, think about going offline. Documentation can be downloaded.

Do it, but something different.

If you are a writer, and you’re stuck writing a book, you write something else for a while. If you’re a painter, you might try using a new medium.

You’re a programmer, so try tackling a completely different small problem. Maybe take the opportunity to try a totally new (to you) language — don’t be afraid to use something radically different. Ever code in assembly? Why not!

Some people work better when they’re “in the spotlight.” Twitch streamers are often known for entertainment, but actually many coders show up there, too. You could try starting a stream, and see if you are more focused when people might be watching.

This may sound stupid or trite, but have you considered moving into a management position?

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.

It might be surprising, but dealing with people still requires focus :) Also, instead of code, you write docs - so many docs. Which, again, needs focus.

I think the comment was more about the fact that social media is more enjoyable and therefore drawing OPs attention. If they moved into management, perhaps that would be more enjoyable and therefore remove the social media draw. They could have used any occupation not just management. Maybe OP just doesn't enjoy coding anymore.

I wrote a blog about this a long time ago here: http://debugreality.blogspot.com/2010/03/hidden-dangers-of-w...

It basically boils down to understanding the negative effects of your work and taking responsibility for your mental well being by countering them which is where work life balance come from.

Previous HN discussion here: https://news.ycombinator.com/item?id=1203696

I found that I do that when I feel I haven't been around enough people. Perhaps upping the priority of talking with people, anyone can help you feel better. Does this seem to resonate with you? It could be any reason

I discovered this about myself too. If I’m spending enough time with actual people I don’t care about my phone or social media.

Watch more porn, or get laid more.

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.

Realize that promiscuity is a disease vector.

Do you mean mental disease, or physical disease? It is a well researched understanding that sex is very important for both mental and physical health, and with the massive amount of money spent on sex education, I'd hope it's clear how to avoid physical disease. And I never mentioned promiscuous behavior. It's quite possible to have sex, with have sex with many different people.

The OP was crude and perhaps hinging on taboo, but there are well established schools of psychology on the topic, namely Freud's psychoanalytic theories come to mind.

I'm actually really curious why you think I was being crude/taboo here. Maybe just a cultural difference? I spent most of my adult formative years in the military, and there's been some cultural friction ever since I ended my service. An explanation of your opinion would be quite welcome!

What? I was defending your comment, seeing the downvotes!

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 understood that you were defending it! The downvotes were a bit confusing to me also, as I felt pretty well founded in my original comment. As I said, I'm more just interested in your reasoning that I was being crude and taboo, because I have a background that seems less common among HN posters. It would help me better understand the downvotes!

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.

Getting laid is crude now? Man, I thought it was 2019, not 1950. Excuse my crude language.

I wrote some things that help me focus here:


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.

Just logged in to say that the tips on your wiki are pretty good and overall all the info in there seems pretty valuable, bookmarked. Thank you for this!

Also, might give me some inspiration to make my own wiki ;)

It’s a vicious cycle.. the more you distract yourself, the more your brain wants quick hits, so you feel the craving for more distractions. There are many ways to help outlined by other comments here, getting exercise probably one of the most effective. However any solution will involve you making a conscious effort to pull out of the cycle and change your habits.

When you are coding, or when you are working? I'm asking because perhaps you just don't enjoy your job. Can you still code for some hours when you're working on side-projects or learning new things?

I have no useful tips to add beyond what's already been mentioned here. The only thing I can suggest is to clarify if your _job_ might be the real problem.

Most programmers don't spend any amount of time on side projects. Maybe the all, like me, weakly aspire to, though.

It's still a valid question to ask though.

And many people do program outside of work. Not necessarily big projects, but things like AoC, ProjectEuler, or just learning a new language/framework.

But yeah - I believe more programmers don't rather than do.

if you are asking it here, I assume you did some online research too and I believe that you already know all the solutions. For most of the people the problem is not sticking with these solutions and not being patient enough to get the result.

I’m married, above 30 with a lot of things going on in my life. And often my co-workers make joke about me going into ZEN mode when working.

Don’t look for a magic tricks. It is as simple as you hear from everyone. You just need to be patient and stick with them long enough for your brain to get use to it.

I’m careful about eating and sleeping. Having enough fun. I put my phone away while working and resting. I use Pomodoro technique to make sure I have enough short breaks and I have a goal. And I know very basic of meditation breathing technique (learned literally in 30mins). I only drink one cup of coffee on the morning and one cup of tea on the afternoon.

I agree. Remove the phone will pay dividends. I started leaving my phone in my car after work and already I'm seeing benefits with my afternoon/evening. I'm able to get more done as well as have a full night's sleep.

There's something about the phone that just keeps me distracted. So, I just don't bother with it.

Heavy metal helps for me. Try Iron Maiden, Metallica, Dream Theater, Moonspell, Therion, etc. all this works for me. And stop visiting those websites of course ;-). Make accessing them harder, you could add the problematic domains to /etc/hosts to resolve to or something like that.

I'm the opposite, I need silence to focus, I find music distracting!

If you are not against some help from technology, then there are software/apps that block internet access for social media web-sites etc e.g. freedom.to

You could also try browser extensions, e.g. for Firefox: Mind the Time -- shows stats of internet usage; LeechBlock NG -- blocks sites.

Recognize what unmet needs your habits are grasping towards.

If you spend too much time on facebook, it could be because that is the lowest-effort way to keep up with friends you value. Message 4 of them and schedule a time for a phone call. Better yet, schedule a recurring phone call.

No you didn't. This is an emotional problem masquerading as a cognitive one.

This happens to me at my three-hour university lectures. Some days I am emotionally tortured and cannot focus at all. Some days I am emotionally healthy and can focus through nearly the whole thing.

Find a good therapist. It may even be free, depending on your health insurance. My therapist has helped me discover the root causes of mental habits that are holding me back. Now I'm making progress on them. The sessions are worth my time and money.

You might be genetically susceptible to distractions. Some people are just better at focusing than others. It's perhaps not where your power is.

The best solution is to simply delete all your social media accounts that you don't use professionally (strategically).

Is the lost focus for the work you do as part of the job you described https://news.ycombinator.com/item?id=18400859 ?

In my experience, only regular meditation sessions and physical activity (i.e. working out) will help.

Also look into your diet, too many carbs / sugars could make you sleepy and are not good for your concentration skills

Self-fulfilling prophecy, probably a reason you want to be in this trap

Uninstall Instagram and Facebook from your phone. Block them and other time-wasting sites on your computer. Start training yourself to not be distracted. This is what has worked best for me.

Same here.

The quicker you distance yourself from social media the healthier you will be. There's literally everything to gain by leaving it behind.

Look to your health. Eat right. Exercise. Clean your workspace. Etc.

I think you answered your own question. Ditch the social media. It only hurts for a bit, and then you start to feel better and wonder why you were so obsessed to begin with.

It happened to me on a job that I hated. Doing something you like might fix it.

Try a side project or some library or module that you’ve always wanted to write.

depression, anxiety, and adhd (inattentive), had me troubling to stay focused. I lost 90 lbs (515 down to 425) since September, started seeing a therapist, and start adhd meds... the crossfit/keto/fitness + adhd meds have had the biggest effect on mood, depression, and focus. I'm taking 50 mg if Vyvanse and it totally keeps me balanced and focused.

Adderall. Truly.

Adderall is good for focus once you break the habit of social media / youtube, otherwise it just makes you really good at focusing on social media / youtube. I know this from experience.

Just treating the symptom, not the problem. It will come back to bite as all amphetamines do.

I lost my ability to focus for ~6 months.

I started working on something that I cared about.

Slowly, over 3-4 months, I regained it.

Maybe the DMAE supplement could help your brain to regain focus.

it sounds like addiction to me. Some people are more sensitive to all kinds of addictions than other.

Work is work

Caveat: I can only speak for myself and don't know if these are extrapolatable to others. I can't say I'm an über-focus person, probably mediocre, but I use tools to help be better. I know co-workers who would be in a deep focus while the house is burning around them, and I'm not at that level.

TL;DR: Reduce cognitive load.

Rule 1. Make your environment conductive to focus.

If you are in an open office, you have a shit sandwich to start with. So isolate yourself from the cognitive "filth and rabble". Long time ago I worked with a guy who built a cardboard wall and then wired a camo net over his cubicle, but maybe one doesn't have to go to such extremes.

Headphones: Use headphones and music to drown out co-workers talking and other noise. I don't play my absolute all-time favorite tracks on repeat, I play something I merely like: noisy stuff like some desert sludge metal or stoner rock -- I sort of tune out the music and the music drowns out all the noise. You'll need to experiment what music works best for you. I use Spotify and try to improve my playlists with new interesting music.

Tune your programming environment to have a look-and-feel that fades to the background. Nicer and duller colors. Learn all the shortcuts to be effective, and learn a powerful editor which gives you macros and regular expressions and whatnot. The less mouse you need the less mini context switch which is better.

Turn off audio notices, turn off all blinking "hey you have mail".

Rule 2. Coffee/tea in moderation.

Too much of too strong coffee within too short time makes my focus become scattered. My mind starts to get racy. The best thing is to dose coffee such that one doesn't go over the limit. A tea in the morning a few hours after waking up works quite well.

Rule 3. Notes and checklists.

It helps to be a compulsive note-taker. Before I start anything, I make sure to have a vague idea of what to do, then I make a checklist. I write down notes and think of next things to do while waiting for something. I do "self-retrospectives": when I'm done with a few hours work, I go through it and make notes and checklists of next things.

The checklist lives all the time, new things get added and old points get marked as red cross (not done, bad idea, didn't work, etc.) or green tick (done, clear, good idea, etc.). I use a program called Zim but you can do it with any editor.

Rule 4. Train your memory.

I've noticed it becomes easier to suppress problems from tiny context switches that way. One is less likely to forget the context prior to the interruption, and the notes help a lot with this, too.

Rule 5. Rest to recover.

When you're not at work, you're not at work and you should not be thinking about work either. Exercise, read, do something else you like.

> I check social media and youtube frequently while doing work.

Well, don't do it then.

> If I do not do that I feel some void and feeling of losing out

This is a minor discomfort. You need learn to cope. You must be young and healthy now, but the reality is that down the line, you are likely to develop some sort of permanent injury/impairment that you will have to cope with for the rest of your life. Start small, learn to cope with that little bit of discomfort.

Not to belittle, it's actually a major and widespread problem. Avoidance of minor discomforts is literally what keeps people smoking until it kills them. It's what holds people back from achieving the best life they can have because they avoid all the little risks that add up to big opportunities.

You have a will, you're not slave to your whims. Take control of your life and earn some self-respect.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact