Ask HN: Any scientifically proven techniques to boost concentration?

288 points by amznbyebyebye ↗ HN
I feel like I have to be in a very specific head space to write code. It’s like climbing a big hill but in my head. Sometimes it’s effortless and sometimes it’s a slog.

Are there any proven exercises or techniques I can adopt that are proven to boost my ability to focus and get in that clear headspace to write code?

Edit: adding some tips as I try to figure this out. Note: not scientifically proven (to my knowledge)

1. Music. which type depends on the individual.

2. Timing. Dead of night or early in the morning when the world is quiet. Not this isn’t a muscle you can flex at any time, you have to just capitalize on the right time.

3. Long shower

4. Caffeine

5. Get out of the office/house go somewhere else (like a cafe)

6. Take a walk

7. Have a beer

8. Write thoughts down in a notebook without any phones/laptop in sight and then jump to the laptop to implement

9. Meditate

10. Lift weights / exercise to work the demons out and quiet the mind

187 comments

[ 4.5 ms ] story [ 241 ms ] thread
caffeine + headphones and music
(comment deleted)
No phones in sight (unless you code phone apps I guess). No notifications. And I write down any thoughts that my brain wants me to get into for later.
This (no phones, no notifications) has singlehandedly been the most effective step I have taken for better concentration.
I struggled to find a description of it on the web (everybody gets hung up on secondary details like 'light a candle' and 'read a sacred text') but basically you can

(1) set a timer for some specific time (say 5-10 minutes to start, could be more once you get experienced; it's important to use the timer so you don't need to think about when to stop.)

(2) meditate by closing eyes, focusing on the breath, relaxing, for a short time. (practice this by itself first if you are starting out) eyes closed is important because the point is to get your brain producing alpha waves.

(3) focus on some object (could be a thing in the your environment, could be something you visualize) and whenever your mind wanders from the object you put your attention on the object and tell yourself "that is interesting but this is more interesting". it does not matter if you are eyes open or closed at this point because the concentration state involves the brain producing beta waves.

The most important part is to do it every day.
What you are describing is "mindfulness" exercises; basically a modern take on meditation.

I have the app "Meditation Studio" which consists of some softly-spoken people talking you through breathing exercises and relaxation - would recommend for anyone wanting to try these techniques.

... except I hate the word "mindfulness". There is a specific person I know who talks about "mindfulness" and then walks into an open pit.
I don't think there's much sense in hating it. It has a real and interesting meaning, but it's just rare to hear anyone provide it.

The problem is that understanding it rests on something most people have never even heard of, much less looked into themselves: that experience does not actually work how they think it does. Experience seems panoramic, i.e. continuously seeing, continuously hearing, etc. But that's not the way it actually is. Experience actually consists of a very rapid series of micro-messages from the sense bases, and those are stitched together by the mind to provide the illusion of panoramic awareness.

Once that's understood, you can give the real definition of mindfulness: remembering to know what kind of message the mind is currently knowing. This will be like watching attention flicker between knowing information about touching, seeing, hearing, etc. A person is being mindful when they're watching how mind's attention is moving.

what's the next part? I'm sure I can handle what you described. Am I done, lather rinse repeat?
Exercise (mostly I've seen more intense than walking, but cardio like running, cycling, rowing, etc. - I haven't come across much for resistance training like weightlifting) has been very well studied to improve cognitive ability, as well as mental health (depression/anxiety). Depending on what you mean by proven, it's not gravity, but it's pretty good evidence compared to just about anything in medicine (just look at the numerous citations testing various aspects/study designs/different populations).

Just a few studies (there are countless): https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3951958/ https://pubmed.ncbi.nlm.nih.gov/20065132/ https://pubmed.ncbi.nlm.nih.gov/35153701/ https://ju.se/download/18.4662178a174aa5f82061c573/160103080...

I also read creatine, while used mainly to improve gym perf, helps wirh cognitive ability too.
That's odd. Creatine stores are in muscles. I'm not saying it isn't the case, the body is weird as fuck, but I'd be interested in understanding how that's the case.
It’s because creatine is used by the body to convert sugar into adenosine triphosphate (ATP). ATP is what your body actually uses for energy inside cells for things like contracting muscles and nerve impulses (like in the brain for things such as “thinking”).

ATP can’t be made in the brain, instead it is made by muscles. That’s why exercise and higher levels of creatine are good for cognitive performance and memory.

Wait I don't think this creates the logical connections to validate what he's asking
There are studies on creatine and cognitive performance.
I've been taking creatine monohydrate for years to improve cognitive function. There has been no visible cognitive effect, but it's greatly reduced exercise injuries.
My work performance has increased tremendously since assembling a treadmill desk. The book In Praise of Walking delves into why it works.
Dr Huberman from Stanford has a great weekly podcast where he talks about how to improve all parts of your body/mind for various activities(sleep, exercise etc.). Here’s one on improving productivity: https://youtu.be/Ze2pc6NwsHQ

One of the tips from the video that I really love is called the cathedral effect. It was found that having high ceilings increases your creative capacity when doing an activity.

A few more from Dr. Huberman:

ADHD & How Anyone Can Improve Their Focus - https://www.youtube.com/watch?v=hFL6qRIJZ_Y

How to Focus to Change Your Brain - https://www.youtube.com/watch?v=LG53Vxum0as

I am only 2 mins into the first video but I am hyped - thanks for posting this!
I guess it didn't work then, lol.

/s

Enjoy! I recommend you start from the oldest videos and work your way forward. He often mentions to past videos and some his content builds on top of older content. It is time well spent. His demeanor/cadence & carefulness on choice of words is very clear and appreciated. His videos also have bookmarks so it is easy to find things in the future if you want to refer back to something.
I've tried to listen Huberman so many times but have hard time focusing. He seems to rattle off a list of things without any emotional hooks to keep the user engaged.
His videos are very long. A lot there but I haven't been able to get through one yet. 2.5 hours is long. Could be 3 or 4 videos.
I normally have a hard time watching long "monologue" videos but I feel like Huberman usually does a good job of keeping my attention. He speaks with eloquent intonations and maintains a piercing eye contact with the camera. I admit his videos can be a bit tedious sometimes but I just frame them as "classes", which makes them easier to bear.

He could for sure add in some sugar to help the medicine go down, but it would make the already long videos longer.

Exactly my experience. I have a feeling that he talks way to much and without a pause throwing large number of unconnected points leaving you bamboozeled on what to actually start with, what is the most proven and would give best bang for the buck.
I tried watching the first six minutes of one if the above videos and it was all just fluf or advertising for his sponsors. No actual information. Podcasts in general seem like such a poor and inefficient way to acquire information. A brief article in Wikipedia that can be the jumping board for further explorariob is always so much better for me.
The adverts are at the beginning. Just skip forward if you don’t want to listen to them.

These podcasts are actually very dense with information once you get past the adverts.

Same. Use the time guide provided under the video, makes it easy to skip ads or sections you are not interested in.
Also, you can install Sponserblock so that such segments are automatically skipped on youtube.
Some of the comments here are really nice. I want to add the Endel app with it's soundscapes has helped me concentrating too: https://endel.io/
In a similar vein, there’s one called brain.fm which I’ve used for years now and it gets me in the zone every time.
Another way to boost concentration is by removing distractions.

I use RescueTime to stop myself getting distracted and set focus times. While working I will inadvertently start Google to research something and before I know I am wasting time on news, youtube, twitter and what not. Apps like RescueTime help you avoid such distractions by specifying focus time during which it will block access to distracting websites.

This is a great music source: https://musicforprogramming.net/latest/

Start right when you wake up after a coffee and shower. Don't give your brain any time to get interested in anything else.

Write high level skeleton code / notes to get the juices flowing

I used to avoid music with lyrics, but (for me anyway) I’ve realized I can concentrate just fine when there are lyrics as long as I’m listening to songs I already know. I usually put on a playlist that’s maybe an hour or two long and just let it repeat all day.
Action movie and game soundtracks tend to be great for this.

I suspect it’s because they needs to have an emotive effect without distracting you from the story.

For me its some times music, but mostly comedy channels on low volume, so i have some background noise that filters out surrounding noise.
I've been having trouble focusing as well as I could for very long at a time, so I'm going to take the whole summer and do something about it.

I should be just fine once I've made it through concentration camp . . .

I kinda feel I can code better when mildly sedated - eg late at night, after a beer. If I'm thinking too much I get distracted.

If I know I wont get interrupted is much better than not getting interrupted. eg if no one is in the house I can concentrate more than if they're there.

I used to end up working in the middle of the night as it combined this feeling of exhaustion and solitude. I can't really do it anymore for multiple reasons, but I try to at least get the solitude or physical tiredness through exercise.

I've noticed lately that "not being interrupted" is good, but "knowing deep in your soul that you can't be interupted" is better.

I think Cal Newport or someone was where I originally saw this idea spelled out, and it made a lot of sense of routines that I'd adopted subconciously and allowed me to plan them more explicitly.

I'm currently looking for a way to automate the pause of all incoming comms until the end of a pomodoro period.

I've tried most of the things in your list. By and large they don't really help with concentration. The most effective thing I've found is 20mg of Adderall. Not thrilled about that, but it is what it is.
Is what it is... but in my opinion/worldview: if there are bounds to how much concentrated work you can get done per hour/day/week, then you shouldn't need to chemically enhance/alter that. You're free to choose to, but you make it sound like you feel obliged to for work.

Even if one can get exactly 2 hours of work per week done, well, some people just have a disability and not all disabilities are obvious or visible. Modern societies should make up the difference. If someone is simply unable to, I'd be happy to pay those extra 5% taxes to make it possible that they have a normal life by doing what they can and no more and no less.

I'm not sure if this is the right forum for such opinions as, from a European standard, the US has very little like this, but I guess there's no point only ever preaching to the choir / staying within the bubble. This is just how I see it.

Just joined a Flow Working workshop by Dr. Antoine Larchez and had some interesting results. As a lifelong (functional) procrastinator with diagnosed ADHD, I brought down 2.5h of effortless (once started) work on paper, some of the best in a couple of months if not years.

I have yet to see whether the methods are scaleable and replicable for me, but a lot of the content resonated with me, especially the insight that concentration to flow states is a skill that can be learned and brought down from 20 minutes to just one with training.

It was an interesting mix of fundamentals from Cal Newport (Deep Work), plus mind emptying exercises, concentration meditation, exercise breaks and group work sessions.

I'll probably dig more into it.

What did you do different to get the 2.5 hours of uninterrupted work done?
Basically meditated, emptied my mind by writing down any tasks I'm procrastinating or ruminating on, identified the fears behind them, set a goal, did a quick exercise and then just did it in 50 minute chunks, but with the phone completely off, any windows in single focus and most importantly with the camera on and 10 people watching (== not really watching but doing their own tasks).

Had a pretty sizeable psychological effect though.

I used to do sessions with FocusMate before which worked, but in a bit of a hit & miss. Key differences to this workshop was the length (blocking half a day, uninterrupted) and the guidance through it, taking away brain cycles for managing.

Still a bit unsure how to fully replicate that experience on my own, but just experiening that someone was able to trigger this kind of focus in me, on a dreaded task, on demand, had a profound effect in me to go try it again.

> just experiening that someone was able to trigger this kind of focus in me, on a dreaded task, on demand, had a profound effect in me to go try it again

Thanks. You realized what you're capable of.

As someone who also has adhd and is a functional procrastinator at times saboteur I'm curious if you could elaborate on your "mind emptying exercises"?
Write, in anyway that feels mentally relieving. Whether it’s a journal or a whiteboard.
Looking for something external, trick, app or whatever, and generally relying on science for concentration is conceptually the wrong approach.
Could you please elaborate?
I guess the poster may have meant that concentration is a skill you develop - an internal quality - and any seeker should keep in mind that there are no excuses: you have to "actually do it", not e.g. attempt getting it from the outside while internally remaining alien.

When you learn acrobatics, you may research about the shoes and haircut etc. that hinder the least and facilitate the most, but it will remain an ability, a skill, not a prosthesis, not an externally enabled state.

Moreover, it may have meant that since concentration is also a negative state (to gain concentration avoid its disturbances), you have to declutter, not to add further - to remove elements, not to pose them.

Moreover, it may have meant that to learn riding a bicycle, you "do it" (you climb the bike and attempt action), you do not «rely[] on science». The "science" is inside (natural cybernetics, feedback based skill building), not explicit outside.

L-theanine (present in green tea) shows interesting results in alpha wave brain activity: https://apjcn.nhri.org.tw/server/APJCN/17%20Suppl%201/167.pd...

I think there was a post on hn about l-theanine before.

I have a very subtle yet bad reaction to L-theanine.

I have a noticeably positive response to taking Acytel L-carnitine. One pill at night before bed. Taking half the dosage on an empty stomach gives best results, though makes ones stomach a little queasy.

jack off. after that I'm good at writing code. you can as well use empirical method to proof if this technique works.
Based on consistently feeling as you describe in your opening sentence for over two decades in many different life stages and concept, let me suggest a reframe:

The good news is that "sometimes it's effortless". Consider yourself blessed. For a lot of people that is never true and though they may even achieve some professional success by grinding, it will be joyless and likely not lead to real career satisfaction.

Now in terms of optimizing your coding output, don't focus on minmaxing this as if you were an assembly-line manager trying to squeeze out your next ounce of performance. Instead recognize that coding is a creative craft that depends hugely on your state of mind. Focus on finding ways to recognize and harness the energy overall, but recognize you can't force it. This comes in two parts:

First, if you are procrastinating diagnose that by practicing self-awareness at all levels. For me it can range from something as simple as eating the wrong lunch all the way up to existential crisis about how I'm living my life, and everything in between. This is obviously non-trivial, but it can be hugely important. A lot of folks mention exercise here—and I agree—but I would broaden it to include ones overall physical and mental health. By addressing those things holistically one establishes the conditions to allow inspiration to strike.

Once that is established then you need to recognize and harness the energy when it comes to you. It might be on a schedule, it might not. You might have an understanding boss who gives you carte blanche to organize your own deliverable schedule, or you might need to some stakeholder jiujitsu (up to and including finding a new job) in order to carve out space to make your process work for whoever is putting money in your pocket. The point though, is not to adopt some external productivity narrative (I was brought up with the puritan work ethic) but to instead recognize and optimize for the tao of your own abilities.

Meditation works well for me.

I have a cushion next to my desk and whenever I can't focus or don't know what to do next, I sit for ~5-10 min with eyes closed and usually the next best task becomes apparent. I then visualize it clearly and think about the sequence of steps needed to accomplish it.

If I don't do that, I usually find myself wasting extra time before I arrive at the next task, or I feel more low-energy / unfocused that I would have otherwise.

Regular exercise pairs well with this to keep your baseline energy up.

Wellbutrin. Similar to Adderall but a lot easier to get legitimately and isn't fleeting with time.
For me I have noticed that either one hemisphere is ready to create or the other. Example: if my mind is cold for writing. Then drawing is hot. But if sketching is cold, then writing is hot. And yes. Caffine helps everything.
Note: often you can work in the same problem either visually or with text.