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
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...
Binaural beats [3,4] are also worth a try.
[1] https://bandcamp.com/tag/video-game
[2] https://bandcamp.com/tag/video-game-music
[3] https://en.wikipedia.org/wiki/Beat_(acoustics)#Binaural_beat...
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.
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.
Go to bed early - 9-10pm and wake up when your body feels like it for a change. If it’s 4-5 am, you get more hours of dark and focus time and your brain is at peak executive thinking, so you can see the bigger picture and write much wiser code.
Fasting for a bit may keep your focus as well for a while. If you wake up and are distracted from hunger, drink a cup of plain while milk or plain yogurt. The protein and fat will be an instant boost to your brain and you will stay focused until you get hungry again. If you keep to meat, dairy, or sugar-free protein and fat you kan keep your focus all day. Carbs will crash you.
When you feel tired or unfocused, or ready to go to social media, take a nap instead. You can eat some carbs now as they can help you fall asleep faster. When you wake, apply the same principles.
I had to work for my own startup for a while and a squeezed a whole bunch of top quality code out of my brain. Without enough sleep or quality fatty protein, the brain gets distracted more easily or operates only at lower levels of abstraction.
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
You could do a scientific study on yourself, though. Figure out some objective way to measure your own concentration, and then try various interventions one at a time to see which intervention correlates with the best concentration. You could also try combinations of interventions—having a beer while taking a shower?—to see if you can get an even stronger effect.
I’ve never done such an experiment on myself, as planning and implementing the experiment would distract me so much that I wouldn’t be able to concentrate. So I just exercise for a while every morning. That seems to work—for me.
The other thing is to notice when I am no longer able to concentrate any more, as it is no longer productive to keep going. When that happens, any of the above might be helpful, but that list is missing the most important one: get enough sleep.
Your list is mostly of solitary (or not explicitly social) activities, but socializing is also helpful for me.
I can't find relevant studies, but there's a few scientists who say that reading improves focus: https://www.ncu.edu/blog/reading-improves-memory-concentrati...
First of all it kinda puts you in this “survival” state where while not feeling hungry per say, you’re on high alert and can concentrate like crazy.
And after you finish you feel rejuvenated and excited. Amazing experience and can’t recommend it enough. Done it several times already (4 days fasts) and still having the same initial effect.
After listening through all of the science in Lifespan (the book and the podcast) have started the “only eat in the evening” routine. Like I skip breakfast and lunch.
Still in my first week so its kinda hard, but after another week or two my glucose levels are supposed to stabilize and I would not be feeling the pangs of hunger and highs and lows of sugar spikes after a meal and brain fog after the insulin response has sucked all of the sugar from my blood (and brain).
Its that what I’m really after - steady brain performance throughout the whole day. Will see if I adapt and that actually happens!
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.
https://news.ycombinator.com/item?id=24696601 https://www.healthline.com/nutrition/7-supplements-for-vegan...
One of the most effective strategies I've learned isn't necessarily cheap, but it works: Get two computers. One is your work computer. You only work on it. One is your play computer. You only play on it. If you struggle with self-control, use extensions to block or limit your time on sites like HN, Reddit, Twitter, and others on the work computer.
For me, physically moving between the two computers helps reinforce the separation. If visiting HN is an alt-tab away, it's easy to drift off when there's a lull in work or I have to wait for a compile. If I have to actually get up and move to waste time, I will put deliberate thought into it and, most of the time, not do it.
If you have the space, creating a separate home office that is in a different room from your play computer is golden. That's a lot to ask, obviously.
For a more accessible alternative, consider isolating your distracting activities to only your phone. That's what I do most of the time. I only use the phone distractions while I'm walking, which helps wake me up in the process.
I’ve had a subscription to Brain.fm for a bit over a year now. Supposedly it doesn’t work for everyone but I find the act of picking a 60 minute Deep Focus block, probably just as much as the music itself, really helps me keep my head down.
To help achieve this effect while working remotely, I’ve used https://www.flow.club/ and recommend it
It helps you: (1) actually block time off in your calendar to do focused work (2) set your intention for that chunk of time (3) create an accountability mechanism by telling the people in your session your goals (4) creates cognitive dissonance if you let yourself get distracted (since you told people what you would be doing, and have to tell them at the end of the session what progress you made)
To go beyond that, a daily routine of 2x20min meditation is somewhat proven to increase your mental capabilities slowly over time.
Also background Music (like Trance or game soundtracks) have some instant effect, I personally have great results with Endel.io - highly recommend!
HealthyGamerGG YouTube channel has videos on it.
Apparently the yogis have been doing it for 1000s of years.
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.
-excercise,
-removing distractions ie a clean room.
- Caffeine.
- optimized by vitamins b6 b12 magnesium and c . Have Tested levels prior to correct dosage vitamin intake
- being relaxed / ie having a weekend of doing nothing
- good nutrition ie not McDonald’s
- Red Bull but only in extreme situations and very seldom
- good sex
-avoid alcohol and anything similar such as cigarettes etc
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
Also having people code on a second monitor is somehow inspiring, like Andreas Kling :)
Discipline/schedule helps! But don't let the schedule prevent you from taking advantage of when you're feeling creative.
I also posted advice elsewhere in this thread.
I'm even a bit too concentrated, working too long and hard.
(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.
Unsure if it's scientifically proven. But there is abundance of literature if you Google for it.
I've seen the results in myself. From being a very passive in meetings, drowsy, and almost ADHD like behavior to being able to hold my focus and concentration till end of business and past. Key is doing it in the morning, evenings didn't work well.
I also noticed that I can write good code only 3-4 hours a day at most and not every single day. Luckily for me, I am not a developer, but the highest concentration and productivity can be achieved and maintained for relatively short periods of time, not 8x5.
Alcohol does not work well. It helps disconnect, but constant alcohol intake leads to even more alcohol and health problems.
Caution: adverse effects.
I know OP asked for scientifically proven data, but I think for a question like this we are all different and learning about yourself and your body counts just as much as science.
have you tried logging when you are fit and less fit («effortless and [...] slog»), and attempt logging potential external factors - sleep (time, quality, duration etc.), nutrition (dishes, hydration, sugar etc.), internal states (emotional, mental concern, generic feedback etc.), etc. - and see what seem to be more and less correlated?
You may realize what is facilitating you and what is hindering you - that you may work better after a good night sleep, or by having disposed of some class of preoccupations etc.
You should probably just keep yourself in an optimal working state, as the general rule. (And work in a fitting environment.)
Spend time focused, build more of that ability. Spend time clicking from news headline to news headline while receiving notifications of everything under the sun, build more of that.
All the things people list either make you physically better (like exercise and good sleep), make you focus, or make you do without the constant distractions for a while.
It will improve your sleep quality tremendously which will then improve your concentration naturally. A rested mind has an easier time getting into the zone.
Buddhism and Zen can also help. No need to become a master, simply understanding and applying some of the basic concepts can help mind state significantly. This can also boost concentration by quieting the mind.
Also check out:
TMS Therapy or Transcranial Magnetic Stimulation. It is brain stimulation technology. Very interesting and lots of research behind it on pubmed.
During that hour my mind drifted to the code it wanted to write. I’d begin to think about the classes and methods I wanted to make progress on.
Now when I’m blocked I take an hour, play with my kids and after find myself very productive.
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.
Is this something that you need to "fix"? Maybe it's your body telling you that you're dedicating too much time/mental resources to work and not enough time to the other aspects of your life.
You can't "push through" burnout; only recognise the early warning signs and back off.
> A goal of the technique is to reduce the effect of internal and external interruptions on focus and flow.
I think there was a post on hn about l-theanine before.
Maybe a good handful of nutropics, but most are anecdotal or don't work for everyone.
Good vitamin regime ie D if you don't get enough sun, C if you don't get enough fruit and veg and so on ...
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.
Try to decrease inflamation in the body if you have any.
Ps. I know its easier said than done and requires quite a bit pf self-discipline.
I listen to music all day. But when I really need to concentrate, the music has to go off.
If you sit still for a moment and try to concentrate on something either internal (the sensation of your breath, the tip of your finger) or something external (something in your visual field, a sound) you'll notice you get lost in thoughts almost immediately. There is a strong habit of wandering in your mind. But you can train the opposite habit through meditation.
Most people can't concentrate for more than a few seconds before getting uprooted by their wandering minds. In the Tibetan Buddhist tradition they compare the mind to a stampeding elephant pulling you around wildly in every direction. You can imagine what is possible with being able to concentrate as long as you want on whatever you want.
In concentration meditation, you keep bringing the mind back to the object of concentration whenever you notice your mind wandering. You also focus more deeply on the object, getting more absorbed in its details while avoiding dullness. Doing this even 5 minutes a day for a week should pretty noticeably start changing your experience.
2. Practising interrupting distractions: if you open HN, try to make your first act closing it
On Exercise:
I did 'exercise' wrong for years.
Exercise produces 2 types of pain, 'good pain' (panting, muscle fatigue), and 'bad pain' (injury or achy joints). How much 'good pain' you experience is completely up to you, but it is absolutely essential that you minimise 'bad pain'. Simple reason: it is incredibly distracting when you're trying work!
To minimise 'bad pain'; 1. take 3-10 minutes to gently warm up the entire body before working out, 2. take 5-30 minutes to 'warm down' the entire body after working out (this will reduce delayed onset muscle soreness and joint aches). 3. take some protein and water 0-30 minutes after a workout.
TL;DR if you are sore from exercise it will distract you, negating some/all of the cognitive benefits of exercise, so be strict about ensuring that doesn't happen.
On Ice Baths:
One other huge tip, do an ice-bath once per 14 days, at a minimum. You don't have to go super cold: 10, even 15 degrees celsius is fine. How? If you don't have a bath (I don't) search amazon for 'portable bath' (there'll be heaps for under $50), use a $2 kitchen thermometer to take the temperature as you add ice (grocers, bottle shops, any markets will sell large bags of ice - buy 2 or 3). 10 minutes in a cold bath can give you a sense of incredible calm and concentration for the whole day. It also relaxes them muscles.
On Sleep:
I feel like 'everybody's different' is kinda true here, but learn your body and be very objective about how much your cognition drops when you're tired. If you're making mistakes while working tired, you're creating more work that you or someone else will have to fix. So trading off 1 hour of work for 1 more hour sleep is often extremely economical.
meditate instead.
its like a free lunch for building concentration.
---
By analogy, say you're a manager at a scientific-lab. You're already behind on deadlines for publishing papers; you're getting flack for it. You need the folks in lab-coats to write those papers, but they keep procrastinating... no matter what you freakin' do, no matter how many times you physically drag them to the computer to type their papers, every time you walk away for 10 minutes and come back, the scientists are back at their labs doing experiments and whatnot. How do you get them to stop it with the distractions and do their work?
As crazy as it may sound, maybe you should let the scientists do their experiments. Because, maybe, those experiments are somehow more conducive to writing papers than typing the papers is.
And it is weird, right? I mean, if you want papers, you type them! Obviously, right?! Everything else is just a distraction.. and maybe that's okay when you're not behind-schedule, but right now they should really be writing instead of experimenting.
---
You're a scientist in a lab. You're trying to do your work, but your manager's freaking out about missed publication deadlines. Every time you're trying to get some data to write about, they keep demanding that you just get to writing!
They don't understand. You try to tell them that you need to do other things before writing, and they ask why: you explain how the significant of the quadrangle isn't 7-epsilon beta invariant boson electric guitar, but they act like you're saying gibberish. Stressed, they impress upon you the fact that they need you to write stuff up and quit it with the distractions.
What do you do?
Your manager, frustrated, asks other managers what to do to make you work. The other managers suggest that your manager go exercise, have a beer, or take a vacation. Your manager doesn't see exactly how those things might help, but they try it. ...conveniently, they're not bugging you anymore and now you can work!
---
Point: You're not doing all of the work. Much of it's being done by, e.g., subconscious parts of your brain. And sometimes there's more to it than you might consciously experience.
If you want to be a good manager, there's some learning how to help the rest of yourself work. And perhaps even to realize that you might not even know how to do your own work.. sometimes you're leaning on other intelligences, even if they're within your own brain, and sometimes the work you'd want them to do might be more involved than you may appreciate.
So don't Ctrl+Alt+Del the OS-updates, disk-defrags, virus-scans, garbage-collector, backup-transfers, etc. -- at least, not as a standard practice. But also try to avoid stressing the same already-stressed processes while you're waiting; don't have the scientists fix the fax-machine, nor start moving a lot of big files around while the drive's defragging.
And if it helps, imagine that your brain is a country, and you're a non-authoritarian top-level executive (like a US president). Sometimes raising/lowering all taxes might help a bit, but those are rather blunt, unrefined tools to address some specific performance-concern. Instead, if you want to be an effective-leader -- whether if it's of a country or of your own mind -- you've got to grow your awareness of what's going on inside and apply more nuanced tactics to help things along.
Because even when it's "you", it's not all just the conscious-you doing the work -- you're more akin to a manager than a laborer, if you're an executive of your own mind.
---
Bonus analogy: You've bought a self-driving car from, say, Tesla. You told it to be nearby, so that it can pick you up when your meeting finishes. However, it's now late. Should you, say, take remote-control of it and hit the gas? Because, surely, it should just drive to you -- and if it's not doing that itself, then it's buggy and you should hit the gas. Not like it could be delayed due to something beyond your awareness, like it being stuck in traffic, and what's the harm in hitting the gas when it's going too slow?
---
In short, sometimes working means doing things that might not seem like work to your conscious-mind, or at least letting your brain do those things while you support it, like a good manager supports their employees.
Generally speaking, the more advanced/involved a process is, the more non-deterministic the run-time will tend to be. Constant-time operation might be more plausible for the simplest tasks, and a manager might more reasonably try to get employees to keep doing their job when it's a simple task, like pulling a lever in a factory. But just like complex distributed optimizations can be far more variable (and even unpredictable) in their run-times compared to, say, adding two primitive-integers, more complex creative/involved work can be more non-deterministic in its run-times.
- Breathing
- Cardio