TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How do you stay focused while programming/working?

83 pointsby flipfloppityover 7 years ago
I often find myself "needing" to take a mini-break after just a few minutes of concerted effort while coding. In particular, this often occurs after I've made a tiny breakthrough, prompting me to reward myself by checking Twitter or HN. This bad habit quickly derails any momentum. What are some tips to increase focus stamina and avoid distraction?

29 comments

gargarplexover 7 years ago
Find something else to reward yourself with. For example, a drink of flavored water or a sip of coffee&#x2F;tea. Also, try coding offline. I always do my best programming when offline– pencil and paper is the best.<p>If you&#x27;ve already implemented a method in pseudocode, you can use StackOverflow&#x2F;documentation&#x2F;Google&#x2F;etc to look up the actual API calls once you&#x27;re translating the program into code.
评论 #15902595 未加载
krylonover 7 years ago
It&#x27;s not exactly new and exciting, but I found that listening to calm, instrumental music helps me focus. Mostly Ambient. If you do not like electronic music, Stars Of The Lid or Bohren &amp; Der Club Of Gore are very much worth checking out.<p>Also, <a href="https:&#x2F;&#x2F;mynoise.net&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mynoise.net&#x2F;</a> has worked wonders for me.<p>In both cases, it seems that unstructured audio input, like, occupies the parts of my mind that would otherwise distract me.
评论 #15902086 未加载
评论 #15907066 未加载
评论 #15903786 未加载
评论 #15906221 未加载
acrooksover 7 years ago
I normally leave everything until the last minute which means I have no choice but to be incredibly focused and motivated to deliver on my commitments.<p>I&#x27;ve always had a reputation for delivering late but this has gotten better over time as I learn to account for unknowns and my definition of &quot;last minute&quot; has gotten more realistic.<p>Over the years I have tried fruitlessly to make myself more proactive and have consistently failed. I do my best work under pressure and am now focused on embracing who I am and finding a way to make that successful instead of trying to change it. There is a name for this - the Eisenhower method - but it&#x27;s not a strategy I do deliberately, it&#x27;s just naturally who I am.<p>So how do I focus? When there&#x27;s no time to waste it just comes naturally. I take mini-breaks too, but then my subconscious very quickly kicks me back into gear.
muzaniover 7 years ago
Mini breaks are fine. Just blacklist certain things from your breaks if you find they&#x27;re bad for you. I find &quot;boring&quot; breaks to be the best - sleep, looking at nature, chatting with a co-worker.<p>Discipline only goes so far. This doesn&#x27;t happen if your motivation is high enough as you&#x27;d just lock back into the project once you&#x27;ve regenerated.<p>Treat motivation as a supplement. You might be looking at HN as your mind craves more motivation.<p>Think of people, not cash rewards. Who will this project help? Users? Stakeholders? If you have to think of cash, think of how you could spend it on making other people happier... donations to the poor, buying mom a gift, taking your child to a theme park.<p>You might also be motivated by creative impulses. Bookmark projects you admire. It can be roadmaps and devlogs. Open them up again when you&#x27;re feeling demotivated or need a break.
yesenadamover 7 years ago
I go for a smoke :-) But you could walk around the house or block. I get so many good ideas while sitting there smoking for a few minutes, in the backyard gazing into the trees. I think when&#x2F;if I stop smoking, I&#x27;ll pick a spot outside to go to and sit for a few minutes. Its pretty amazing, usually the answer to the next problem pops into my head. Probably the vast majority of my good ideas come in those few-minute breaks.
tonteldoosover 7 years ago
I signed up for brain.fm (<a href="http:&#x2F;&#x2F;brain.fm&#x2F;" rel="nofollow">http:&#x2F;&#x2F;brain.fm&#x2F;</a>) after it was posted here a year or so ago. Can absolutely recommend it!
评论 #15903221 未加载
taw-anover 7 years ago
Prescribed stimulants.
评论 #15901690 未加载
segmondyover 7 years ago
you haven&#x27;t demonstrated that you need focus, what you have tho is shown that you have a bad habit. Kill the bad habit, you are aware of it. So new Twitter or HN or any win. Replace it with something else, pump your fist. Have a win book, write down your win and move on to the next. If you have a todo list, cross it off. Best of luck.
评论 #15904114 未加载
chatmastaover 7 years ago
SelfControl.app is still my favorite Mac app ever. Add a list of sites to block, set a timer, go. I have a huge blacklist. I enable a 24 hour every night. This way I don’t even have a chance to start procrastinating the next morning.<p>The crazy thing is how many times you’ll try to go to one of your addicting sites even though it’s blocked. SelfControl acts as a great circuit breaker in this case, and can also show how bad the addiction is.<p>If I want to read HN, I have to do it on my phone. If I’m looking at my phone, I know I’m screwing around, so it doesn’t last long.
评论 #15908983 未加载
评论 #15915877 未加载
egandunningover 7 years ago
Try the pomodoro technique, the concept is 25 minutes of work to 5 minutes of break time.
jdpigeonover 7 years ago
If anyone&#x27;s interested in neuroscience and machine learning, we&#x27;re working on a fun little project to use EEG to track focus and optimize productivity here: <a href="https:&#x2F;&#x2F;github.com&#x2F;neurotechx&#x2F;neurodoro" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;neurotechx&#x2F;neurodoro</a>
评论 #15908262 未加载
glancastover 7 years ago
I&#x27;ve found FocusAtWill invaluable -- it&#x27;s music designed specifically to keep you in flow. I use the timed function to ensure I take breaks at proper intervals, and you rate how focused you were during the session. <a href="http:&#x2F;&#x2F;ssqt.co&#x2F;mQbYXSq" rel="nofollow">http:&#x2F;&#x2F;ssqt.co&#x2F;mQbYXSq</a> (this link gives you $20 bucks off your first bill if you decide to sign up after the trial)<p>paper: <a href="https:&#x2F;&#x2F;arxiv.org&#x2F;abs&#x2F;1610.04255" rel="nofollow">https:&#x2F;&#x2F;arxiv.org&#x2F;abs&#x2F;1610.04255</a><p>&quot;how it works&quot; (with citations): <a href="https:&#x2F;&#x2F;www.focusatwill.com&#x2F;app&#x2F;pages&#x2F;science-of-focus-concentration" rel="nofollow">https:&#x2F;&#x2F;www.focusatwill.com&#x2F;app&#x2F;pages&#x2F;science-of-focus-conce...</a>
dalfonsoover 7 years ago
I use <a href="https:&#x2F;&#x2F;www.focalfilter.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.focalfilter.com&#x2F;</a><p>Its not 100% effective since I can still use my phone, but it helps. Unfortunately I haven&#x27;t found a good Mac alternative that allows you to update your filter list in bulk.
exikyutover 7 years ago
IMO, the specific situation you&#x27;re describing (wanting to check in on HN) does not have a 1:1 relationship with the bigger picture you&#x27;re associating it with (focusing in general).<p>I&#x27;ve discovered that I also periodically want to check HN, imgur, etc periodically.<p>Fundamentally, this is because I really (really...) need to setup an intelligent social tracking system that tells me about interesting things that I will probably want to intervene in RIGHT NOW, whether inconvenient or not, because of some ascribed value (for example being able to comment on a relevant discussion, reach out to someone in the context of some opportunity, etc). I primarily check in on HN for this reason; &quot;is there relevant discussion happening right now.&quot; While I don&#x27;t have the system I just described, I&#x27;m trying to be it myself.<p>Of course this doesn&#x27;t really scale or work, but it&#x27;s incredibly fun to pretend I&#x27;m competently keeping up with everything because the activity of &quot;just making sure&quot; is one of those simple, predictable activities that has statistically low chance of disappointment (or concrete negativity&#x2F;malice) and statistically high chance of low-effort reward (except for those 183 times where it was boring, which I ignore those because superstition is powerful), and... oh hey, there goes my day.<p>When I realized this recently I was able to at least stare the problem in the face. Now I can work on swinging in the direction of closure for this whole... <i>thing</i> of &quot;keeping up&quot; that I&#x27;ve deliberately been cultivating <i>lack</i> of closure of, for the sake of addiction, and hopefully get myself focused and back on track.<p>I guess the &quot;one level up&quot; scope&#x2F;domain from this would be &quot;online distraction&quot;, rather than focusing in general. I said a few related things on the subject a couple months ago: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15418671#15423170" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15418671#15423170</a><p>And I commented on the value of supplements in this thread over here: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15904764" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15904764</a>
Gnarlover 7 years ago
12 minutes of meditation* before starting work. Keeps me laser-focused for longer periods. (*=sit comfortably, eyes closed, focus on breath, gently resist mind wandering)
coder420over 7 years ago
Nobody else goes for a nice sativa?
kqrover 7 years ago
Do try to get evaluated for medical conditions; stuff like sleep apnea, ADD, smoking, depression etc. can all affect this. If you are suffering from something beyond bad habits that&#x27;s very important to know. And I know several of these are cpnsidered to be overdiagnosed so try to see a serious therapist who will see you over multiple longer sessions before coming up with a diagnosis to get rid of you.
apiover 7 years ago
I&#x27;ve actually had a bit of luck with:<p>&quot;brew install sbagen&quot;<p>&quot;sbagen &#x2F;usr&#x2F;local&#x2F;share&#x2F;sbagen&#x2F;examples&#x2F;focus&#x2F;focus-03-a.sbg&quot;<p>(Linux packages exist too.)<p>Don&#x27;t expect anything huge, but the effect that I see with simple binaural beats is a slight calming and improved focus. It seems to quiet the urge to goof off and compulsively check sites like this. No it&#x27;s not on right now.
jeffshekover 7 years ago
Disclaimer - I wrote this <a href="https:&#x2F;&#x2F;betterself.io" rel="nofollow">https:&#x2F;&#x2F;betterself.io</a> to help me out here. It&#x27;s helped me get much better, but certainly isn&#x27;t perfect. It&#x27;s open-sourced at <a href="https:&#x2F;&#x2F;github.com&#x2F;jeffshek&#x2F;betterself&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jeffshek&#x2F;betterself&#x2F;</a>.<p>Someone posted this quote a while back, and it stuck with me. &quot;Think of your mind every morning as a clean desk, and every time you get distracted via social, game, etc, you put something on it. It then gets progressively harder to do work with a messier desk. The best way is to just always have a clean desk.&quot;<p>I logged habits and supplements for over a year. Things that were effective were having a lot of strong routines that pull you in the right direction.<p>So things that helped were<p>X) Have some type of metric you are measuring to. For me it was RescueTime and WakaTime. How productive was I for this week compared to last?<p>1A) Have your phone on DnD or Airplane Mode.<p>1) Start the day off with SelfControl app. Add the timer to lock out all disractions until X PM every day.<p>2) Use a cold shower to wake up<p>3) Meditate<p>4) Eat the same foods that won&#x27;t make you groggy &#x2F; crap. This sounds masochastic in some way, but it&#x27;s much easier than it sounds once you get used to it. For instance, the same oatmeal for breakfast is a great way to set a routine.<p>5) Track what supplements and food you were taking that improved productivity.<p>6) Inversely, see what supplements or diets you might be taking that does the opposite.<p>7) Set up a sleep routine. Melatonin at 3mg is a sweet spot. Getting six hours of sleep every night is the perfect amount for me. Everyone varies. The point is don&#x27;t take &quot;one size fits all advice&quot; for something so crucial to your life. Less than 5 and I was easily distracted. More than 7 and I was groggy. There&#x27;s a lot of information about how to sleep better. The point is to find a way to maximize sleep quality ... six hours in a city is going to be very different from six hours of sleep in a quiet area.<p>8) I&#x27;ve tried a lot of supplements. The most effective ones on productivity were ones that helped me with anxiety (so the opposite of caffeine). I eliminated a lot that didn&#x27;t do anything.<p>9) Have a track &#x2F; music that you listen to that starts you in a groove. For instance, I have a EDM Mixtape that I&#x27;ve probably listened to over a thousand times this year. You&#x27;ll find that a lot of high throughout writers do something similar. The music helps build a habit of &quot;okay, it&#x27;s time to do work now&quot;<p>10) Find the right setting &#x2F; environment that makes you productive. Face a wall. Accept the fact if you can&#x27;t work from home, then don&#x27;t.<p>11) Go for walks when you&#x27;re bored. Admit to yourself when you&#x27;re not being productive and you&#x27;re just spinning your wheels.<p>12) Exercise. Missing gym workouts (even though it was like 1-2 hours) was a sharp drop in total productivity.<p>13) Pomodoros. Start with 25 minutes and keep on going up (I average hour long Pomodoros now). When you get distracted in a Pomodoro, have a note card called &quot;Distractions&quot; and write what you want to to do there. That way your mind can stop obsessing about &quot;New Avengers Trailer&quot; if it knows it&#x27;s going to get there after the break.<p>When you first start with Pomodoros, have a notebook of how many Pomodoros you did. Make it a goal to do just five pomodoros a day. You&#x27;ll be impressed how hard that is initially.<p>14) No lying to yourself. Everytime I&#x27;ve said &quot;this time is different for a YouTube video about anything mildy interesting&quot;, I&#x27;ve regretted it.<p>15) Plan for a social night at least once a week. You do need some rest. Self flagellation about not having earned it is almost a recipe of more anxiety and procrastination. (I&#x27;m not great at following this yet)<p>16) Have a deadline to finish something.<p>To give some backdrop, this has made me really productive throughout the last year without burning out. I&#x27;ve worked 60+ hours before at startups and just BURNED out, whereas now I can definitely push that easily without hitting that same wall. I integrated all these habits one by one when I was certain through quantitive evidence it was working.<p>Can&#x27;t say much about helping social life though. This definitely takes a hit when you try to maximize productivity and flow at the expense of social life.
mattbgatesover 7 years ago
At work, I put on Moby for a few hours. At home, I just keep telling myself I&#x27;m not a millionaire yet, keep going.
linkedlist007over 7 years ago
Take on a more challenging project with deadlines, hopefully with a project manager that calls you at odd hours asking for updates. Your desire for twitter and hn will vaporize :)
评论 #15917182 未加载
MrTortoiseover 7 years ago
Found a new job. Went from funding it hard to work 3-4 hours a day to 60 hour weeks being easy. Don&#x27;t recommend that long as family everything.
mohitmunover 7 years ago
Spotify. Some of the playlists are really good for focus(Deep focus, Mellow beats etc). I generally listen to ambient&#x2F;postrock.
enginebaiover 7 years ago
Use Pomodoro timer to help, give some short break after a long-time focusing.
ianamartinover 7 years ago
I don&#x27;t know if this will help you at all, but perhaps it will.<p>First off, I think there&#x27;s a myth about productivity. That you are only productive when you are writing code. That&#x27;s not true.<p>The way I work is that I need to have a fully formed idea of the solution to a problem before I start writing code. That doesn&#x27;t mean it&#x27;s the correct solution. But I have to start with an idea of how I&#x27;m going to solve the problem.<p>Sometimes that takes 10 seconds, if it&#x27;s a new feature. Sometimes it takes 10 days if it&#x27;s a bug I don&#x27;t understand. Sometimes it&#x27;s 10 hours for a totally new project. Could be anything. But I always start with documenting things in my way: offline. Your notebook and a good pen are your friends.<p>I do my best thinking at this state away from the computer and away from code. I do it best walking around. Once I think I know how to solve the problem (usually wrong for larger projects and bugs; usually right for new features in an existing project), write down what you intend to do on paper. I know Project Management tools exist for this task, but they don&#x27;t have the same connection for me as physically writing something down.<p>As I&#x27;m doing that writing, I&#x27;ll realize a lot of things that are bad about this approach and correct myself. And then my brain will start to organize tasks and group them. While I&#x27;m going through this exercise, I will set checkpoints for myself. If it&#x27;s a ticket for a bug that needs to get fixed today, well, maybe I&#x27;ll get lucky, and it&#x27;s one and done. Other times, not so much.<p>I also try to organize my work segments vs. my thinking segments around my meeting schedules. Because even when my day is broken up by meetings, I&#x27;m still probably thinking about my problem.<p>Building in your checkpoints by planning your work this way has been very helpful for me, not because I need to check facebook or twitter or HN, but because it represents tangible progress.<p>But if you actually look at my workflow, it&#x27;s a constant iteration of think a lot, followed by pounding out some code for a few minutes. Sometimes that ratio is very small on the code side, and sometimes it&#x27;s quite large on the code side.<p>Without making comments as some other people have about medical or mental problems, I would suggest this: that there&#x27;s a lot to be gained from working in very small chunks and that if you&#x27;re worried about momentum, perhaps that&#x27;s the problem you should be trying to address. Momentum is a tremendously overloaded word, and you shouldn&#x27;t be trying to evaluate yourself based on your ability to obtain or maintain it.<p>I have a fairly similar pattern to what you are talking about. Solve a thing; then think about the next thing; then solve that. No one has ever complained about my productivity. On the contrary, people sometimes wonder how I can get so much done when I spend so little time &quot;working.&quot;<p>Different people work in different ways, and I don&#x27;t think that&#x27;s a thing to worry about. I&#x27;ve really never very much experienced what people call the zone in programming. I certainly do as a musician when I&#x27;m practicing my violin. My girlfriend hates when I practice violin because I absolutely cannot be taken out of that mental space.<p>As a developer, I don&#x27;t care about the context switch or the momentum or focus. I can go back and forth. No big deal. So I can understand why this can be problematic. But it might not be.<p>Questions to ask: are you being told that you aren&#x27;t productive enough? Are you feeling like you aren&#x27;t doing good enough work? Or enough good work? Where is this criticism coming from? Is it external or internal? Why do you want to change your patterns?<p>One of the things that technology companies need to realize is that there are more ways to be productive than just by being in your chair.<p>I&#x27;m my most productive when I&#x27;m not writing code. I&#x27;m my most productive when I&#x27;m solving the problem. And then the code is just a translation of what I&#x27;ve figured out.<p>When I follow this path, I find that my thoughts are more often wrong than right, and I don&#x27;t have to worry about getting up and thinking or rewarding until I&#x27;ve fixed my thinking about the problem and proven it to myself through code and tests. And when I get into that mindset, I can&#x27;t stop until I&#x27;ve corrected myself and crossed everything off the list in my notebook.<p>Take that for what&#x27;s it&#x27;s worth. I&#x27;m just one person. And I could be wrong about all of this. But I think I understand a little of what you&#x27;re talking about, and this is how I deal with it.
pizzaover 7 years ago
A short walk and breath of fresh air is one of the more consistently serendipitous things that help creative work. Music helps too, though silence can help too - it depends on your emotive response at the time I guess.<p>&quot;Brain dumps&quot; - the act of transferring mental information to another medium can itself be a great mental relief. eg.:<p>- drawing diagrams w&#x2F; pencil and paper. things are more complicated than we first imagine them, often... remember, &quot;the right perspective is worth 80 IQ points&quot; - alan kay<p>- debugging by talking to yourself out loud<p>- post-it note reminders everywhere -&gt; your short-term&#x2F;working memory doesn&#x27;t feel cramped<p>It is possible, maybe, that you are a bit concerned about enjoying programming&#x2F;working to the fullest extent.. because you expected it to be more enjoyable. All that said... good focus is not just maximum momentum -- what you are <i>really</i> asking about, imo, sounds like a question of laminar vs turbulent flow :) To go &quot;down the rabbit hole&quot; with great momentum, versus a fragmented mind pulled apart in every direction with equal momentum :P Well, we all know how time flies when you&#x27;re having fun, or enjoying good company, right? Yet it almost seems you are asking for tips on how to make time fly when it shouldn&#x27;t, hypothetically kinda like this:<p>&gt;<i>&quot;if -- while I am working on something difficult -- I had the capacity to just make time fly quicker, then I&#x27;d have no problems with stamina or keeping focused, by design. Furthermore, it would be a momentary-enough challenge to &#x2F;become fun&#x2F;. So how do I hasten the passage of time when work is hard?&quot;</i><p>The answer to this is: unimpeded flow = mastery. Extrinsic obstacles are easy to spot but one&#x27;s intrinsic obstacles take much longer to become aware of..<p>Only after intuition replaces the tendency to hesitant deliberation will deliberate action come easily. As you gain experience, you subvocalize less and operate &#x27;fluidly&#x27; at the right mental level of semantics.. With mastery comes the use of &quot;the voice as an object that can be seen as the lever of thought&quot; [0]. Just think of the last time you were amazed by a display of talent or performance by someone that left you so amazed you wished for a few minutes more of their time.<p>imo, to solve your problems, you have a few options:<p>- you could improve to the point that coding gains a new and desiring appeal.<p>- you could find something (or <i>somebody</i>) with exceptionally inspiring talents to code with<p>- or, you could look deeper into yourself, and see if the focuslessness is really just a desirelessness<p>[0] <a href="https:&#x2F;&#x2F;mitpress.mit.edu&#x2F;books&#x2F;voice-and-nothing-more" rel="nofollow">https:&#x2F;&#x2F;mitpress.mit.edu&#x2F;books&#x2F;voice-and-nothing-more</a>
PaulHouleover 7 years ago
pomodoro
ethftwover 7 years ago
I don&#x27;t stay focused. I&#x27;m a human not a code robot.
vector_rotcevover 7 years ago
Pomodoros, and brain.fm