Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: I'm 40 and feel my mental ability declining. Programming seems harder.
596 points by Buttons840 on Jan 10, 2023 | hide | past | favorite | 510 comments
I'm around 40 and recently I have been asked to port an API from one language to another. The code I'm porting is average code, not terrible, but plenty of little things to complain about.

I feel like my past self could have handled this task, but I am really struggling. Porting this API will require a deep understanding of the existing API, which, of course, has several layers of abstraction.

I can't seem to hold more than about 2 levels of call stack in my head. There's the entry point function which calls other functions, which call other functions, which call other functions, etc. You know how it is, code calls other code, and logically it forms a tree of calls and return values that often goes several layers deep. I struggle to hold more than about 2 levels of this call stack in my head. By the time I'm down in the weeds I've forgotten what I'm doing, what the purpose of the actual API call is.

I don't know how to break this into small enough chunks that I can understand it or make progress on. Imagine I gave you the code for the sha512 algorithm, and a hash, and asked you to find the pre-image (the input). This is how I feel. Where do I even get started? How do I find even a single chunk of manageable work to break off.

The hard part is, several other developers are making progress on porting this API. Why can't I? What happened?

I don't know if this task is just an especially bad fit for me, or if my mental abilities are declining?




I don't know you personally but I doubt cognitive decline has anything to do with this.

As we age, we usually end up with more and more life responsibilities, beyond just the work we are doing. All of that is input to the brain and requires energy in response. The brain is not infinite.

I often feel as you do, but then I have periods where I am as light and agile in my productivity as 20 years ago, maybe even more so, and usually it is my life circumstances that are the culprit.

I remember once about 13 years ago I was working on a mobile game and had a similar problem as you describe; there was one day where the technical work seemed to overwhelm me and I felt inadequate. But I was just a young chap, and it was a passing moment -- I had indeed just taken on some enormous new life responsibilities at that time, which were the likely explanation.

Burnout is real, too, and giving yourself space (if you can) to relax and not think about work for a break can be quite useful to recharge.


I'll second this. Based on my own experience (I'm 50) it's all about energy levels. When my energy is high, I can code like I did two decades ago. Probably better. I guess the difference is that in your twenties, energy is almost for free. As you get older, you've got to be smarter about it - all the usual things - diet, exercise, avoiding stress...

Not that I'm good about those things - I do OK but not great. Sometimes (rarely, thankfully) my energy is so low I can't really code at all, sometimes I'm flying. I'd say by far the biggest factor is my overall state of positivity and optimism. And yeah, life definitely gets more complicated as you get older.


> Based on my own experience (I'm 50) it's all about energy levels. When my energy is high, I can code like I did two decades ago. Probably better. I guess the difference is that in your twenties, energy is almost for free. As you get older, you've got to be smarter about it - all the usual things - diet, exercise, avoiding stress...

This is an amazing insight. I’m almost 46 and feel like I’m at the top of my game, programming-wise, but also, I’m probably at my healthiest. And that’s worked-for health, not the kind that comes for free in your 20s (generally). And I think about and pay attention to energy levels during the day, and just know when I’m toast for the day and time is better spent elsewhere. I take a brief afternoon nap before coffee most days. I pay attention to when my mind is receptive to new information. I let some things bubble away in my subconscious and sometimes make new insights on walks, in the shower, or while making coffee.


Energy yes, and focus. When an interest is lost, it's harder to focus. Like why the hell would I still have to write this algorithm, it would be exciting when I was younger, now it's meh lets find out if there's a lib for this. And then every piece of software is garbage through lens of experience .. why would I write software at all .. of course because I need a job and money. Now I may think I'm not sharp as my young self.


Diet and physical activity play a huge role in mental clarity and energy level. The diet part of that we're only beginning to really understand in the last 10-15 years after some research breakthroughs in looking at our gut.

Western diets (e.g. the standard american diet... what we actually eat) is fairly bad for our health which impacts our abilities.

I would recommend folks look into the Blue Zones. Where people live the longest and thrive for the longest. Look at their eating and lifestyles. One of those zones is in the US where people have work/life balances similar to folks here.

In my case, changing my diet and activity level caused my energy to go up and mental clarity to improve.


Me too, I'm 37, and I did a radical diet change -- No sugar, no carbs, no dairy, no gluten. Only meat and vegetables and fish and some fruit.

After a year of this I've dropped 20kg, and my mental clarity is back where it was when I was early 20's.

I think it was mostly the no sugar that did it.

Exercise too - I walk 2-5 km a day

Oh and cutting down what I eat too -- I only have 1 meal a day, and a smoothie in the afternoon


That's pretty radical on the diet. Was it difficult to adjust? I'm pretty thin as it is so I'd be worried I'd waste away!


I did a radical diet change, too. I'm wired where I can just do that. I've read most people can't and trying often leads people to failure. If you aren't wired to just pivot on a dime you might try a system that works for you.

My major diet change was to eat like the healthiest of the Blue Zone folks. I wanted great energy now and longevity of it and my life. A diet that gives me energy now but leads to heart disease wouldn't cut it.

For that, I went plant based whole grain.

How much you eat matters, too.

A good technical book on diet is The Proof is in the Plants [1]. It covers what we need in our diets and why. For example, how much selenium do we need and what are sources of it. Despite the book title talking about plants it also covers meat and dairy. Everything covered in the book is based on the latest scientific research. It's written by a dietitian who can reference the studies.

[1] https://www.amazon.com/Proof-Plants-science-plant-based-plan...


Yes it was difficult - giving up sugar was very tough, everything has sugar in it and the cravings were strong.

After a month though my taste buds changed, and I really enjoy the taste of meat and vegetables now.

Yesterday I had the opportunity to eat some vegan ice cream, and I thought I would treat myself to a couple of scoops in a cup thing, and after just 2 bites it was sickly sweet, the amount of sugar made me feel really ill, and it felt like I was eating poison, so I threw it away.

Quite interesting. I do miss some foods (pizza :( ) but the mental clarity alone is worth it.


Vegan processed foods are often just as bad as regular processed foods. So sweet. The vegan label may mean there's no meat or dairy but it doesn't mean it's good for you. Most processed food isn't.

Plant based whole grain is usually a diet of the real foods themselves. Take a bean burrito that someone makes fresh. Or a stir fry using fresh veggies. So different from processed foods.

I still eat pizza. Love them carbs :)


Similar results for me. Was basically stuck in bed most of the day. Finally went AIP diet, which is roughly the same diet. Few months later I was kayaking a couple times a week.


I'm 33 and this describes me perfectly too. Some days are clear and sunny while others are dark and cloudy.


>I guess the difference is that in your twenties, energy is almost for free.

Where can I obtain this for free energy?


I had unlimited energy till about 40 and then I hit some sort of cliff. This coincided with covid and being indoors using high velocity media like reddit/insta. I am not sure how much is age and how much is habits that caused this.


My energy levels drop drastically when I'm doing too much "high velocity media" or bottomless wells, be it Reddit, regular news, tv shows, movies, games, etc.

I think it fries your dopamine and other neurological circuits. I don't know the science in depth but I have seen enough anecdotal evidence on myself and others to be persuaded that the relationship is huge.

Do a screen fast for a couple of weeks and check out what happens.


This is turning into a great thread and this comment is the most impactful one for me. I'm going to give it a go. My daughter is 18 and at least half her peer group are in a dreadful state in terms of mental health. You have to wonder if the impact of the modern media environment is way worse than we've comprehended. Of course that's totally unempirical but is the funding there for the studies we need? In any case it's easy to run the personal experiment, as you've suggested.


Recent studies suggest that counter to popular belief our metabolism doesn't change from age 20 to age 60. There are individual factors that can certainly account for your change of energy and I would certainly look for culprits.

I recently did a big change in myself - adjusted sleep, took specific supplements which I was suspect was deficient in and have found my energy to be much fuller. Do not ignore what your body is telling you.


My ex worked on a study that involved testing people's short-term memory. She mentioned a clear and abrupt change around the age of 45, though that wasn't what they studied and of course was not included in the study results. This issue is highly politically charged.


I heard that was related to memory strategy (i.e. the brain focusing on more important methods and information) and not ability. I'd be curious on the results - clearly they aren't published though.


That's right when your eyes change, too. It's so predictable, optometrists can tell you what age you are.


A study https://directorsblog.nih.gov/2019/12/17/aging-research-plas... found some blood protein changes at ages 34, 60 & 78.


I think your last sentence is the crucial one. Up until 40, I could pretty much push through whatever tasks I needed to do regardless of how poor my sleep habits or diet had been. Now, as I approach 50, I really feel it on days where I haven't been taking proper care of myself.


Our metabolism doesn't change in the technical sense, but in the popular sense of the word "metabolism" people absolutely slow down. At 20, missing a night's sleep wasn't even that big a deal. At 50 it is essentially impossible. I don't know what the underlying mechanisms are, but that's what people mean when they (incorrectly, it seems) say "metabolism".


Sleep quality pretty steadily declines with age - your 8 hours of sleep simply count for less than it used to, and you're actually consistently operating on decreased sleep


And that's even without factoring in children!


Out of curiosity how scientific or not of an approach did you take on the supplements. For instance I can't imagine you did double blinds on single supplements but did you start taking a bunch of stuff at once and assess later you felt ok? Tweak one thing at a time? something else?


I used to be able to work 36hrs straight (random work crunch every few years). Hit 40, launched into such a session, 2am hit a wall... "Can't. do. this..." Laid my head down on my desk and slept for 2hrs. Haven't been able to pull an all-nighter since.


It's a feature not a bug.


Easy enough to test, get off the high velocity media and do normal things like socialize / get out of the house (if you're aren't already) for 2-3 months and see if things change.


yes!! . I am in colorado for a 3 month work/ski trip hoping to ski 3 days/week. I don't use my phone on the slow ski lifts. Its amazing to be phone free for the whole day out in the mountains.


If you're male, you might want to check with your physician to see what your testosterone levels are like. You're at the age where it starts declining and it can have a really fatiguing effect.


I've gotten it tested. I am indeed on the lower end of the range. But there is nothing that can be done about it right? I do workout 6 times a week with 3 weight training, eat very decent diet. My weight, bodyfat and muscle tone are in good standing too. All That really hasn't raised my testosterone. I don't want to get on TRT.


Just curious why you don't want to get on TRT?


Even worse: high velocity work distractions, Teams, Slack, etc.


Personal anecdote: I'm around the same age as OP and until recently also felt like my thinking was slowing down over the years.

I went for many years without an exercise habit. About 5 months ago I started lifting weights. The transformation has defied all my expectations and the biggest unexpected benefit is that my mind has become sharper, faster and more focused. I essentially feel like I've reversed a decade's worth of brain and body aging by going into the gym and lugging some iron around a couple times a week.

Around the same time I started cutting back on alcohol intake and cleaned up my diet a bit. So it could be any of these factors but I think it's a combination of all of them, as you get older, you need to maintain your body or it'll deteriorate and take your mind with it.


> lifting weights.

In this recent survey of nootropics [1], weightlifting was better than dozens of chemicals. In fact, it was third only to Dexedrine and Adderall. It scored better than Ritalin! And its variance is tighter than most substances, meaning it's one of the most likely means to improve results for anyone who takes it on.

Personally, I agree. After covid sapped some of my energy, it took about 2-3 months to get back to my average gym sessions and now I feel so much better. Happier, tougher, etc. When I am in shape, the geometry of the world around me changes. A distance or effort I might consider looks, feels, and is more in reach after a few weeks of rows, lunges, pushups, hanging, swinging, light cardio, biking, etc.

[1] https://astralcodexten.substack.com/p/link-troof-on-nootropi...


Sharing my own anecdata: my Oura ring shows that on days I drink, RHR is 10bpm higher and HRV about 15ms lower. Exercise has a huge impact on sleep quality too.

My theory is that when you're young, your body has a much wider margin for error. A few drinks or sloppy exercise routines never seemed to impact my work. As I've aged, the margin has shrunk, and now there's a measurable effect that I can no longer ignore. Aging is in itself a handicap, but now after too many drinks, the next day both my cognitive sharpness and motivation to even care about shoveling bits around a network have declined.

Now I need to actively stack the deck in my favor, rather that engaging in behaviors that further handicap myself. So that means exercise, a sleep routine, zero alcohol most days of the week, reducing stress, all that goddamn stuff I never had to worry about ;)

Another way to think of it is this: at 40 or 50, can you afford to be lugging around a 20% RHR penalty all day? That will surely come home to roost, probably in the form of atherosclerosis. Remember the most common clinical presentation for a heart attack sufferer is not chest pain, but being dead on arrival.

I bring this up because it's worth nothing that our bodies and minds are remarkably good at covering up problems until far too late. When you get those early warning signals (high RHR, feeling of cognitive decline, etc) trust your body, be proactive, and employ countermeasures.


My having an Apple Watch opened my eyes on how much alcohol affects my sleep, and thus everything else. Even as little as a single drink can have a disruptive effect that night. A real bender might take a couple of days for the effects to completely wear off.

Last year for unrelated reasons I wound up not drinking at all for a few weeks. All of my heart & sleep metrics were improved by large amounts. When I zoom out for the full year view it's obvious immediately when that was in the aggregate data.

In terms of how this knowledge affects my behavior? I'll still tie one on at about the same frequency. But the casual "sure why not, I'll have a beer" is gone. Whenever I'm about to consume alcohol I think about if the amount of enjoyment I'll be receiving is worth the downside & act accordingly.


Yeah that's a great point, the data really makes you pause and say "is this worth the cost?"

The other wearable that has had an extreme impact on my lifestyle has been a Dexcom CGM through Levels. I could write pages about this, but in some ways it has been more impactful than anything else. Knowing how your body reacts to particular foods, and seeing the immediate feedback is super eye opening.

And it extends into sleep as well, looking at what your blood glucose does overnight based on stress, exercise, what you ate, when you ate it, it's quite amazing to see how this subsystem in your body is reacting.

I'll never forget the first time I ate sushi (which mentally I thought of as a "light" food, even a snack) only to see my blood glucose rocket past 200 mg/dLf.

You can also see the effect of alcohol here. Not just with carbohydrate heavy beers, but with the fact alcohol itself suppresses your blood glucose levels, since it causes your pancreas to spike insulin, which disposes of glucose. So it's yet another way alcohol causes a disturbance in your body's attempts at homeostasis.

Alas, a CGM through levels is quite pricey because of US healthcare bullshit about giving CGMs to people without a diabetes diagnosis, but doing a month or two of CGM once per year I think it's a great investment (approx $200 for three sensors which last a total of 30 days)


Is the Oura a good purchase? I've been really eyeing the health benefits of the Apple watch but there's no way I want a portal into the digital world that's a flick of the wrist away. It's bad enough with the phone pickups.


In terms of wearables, it's quite unobtrusive because it's literally just a ring. There is no display to become distracted with. The inside of the ring will glow when it's taking measurements (red for blood oxygen, green for heart rate) so that might surprise you when the lights are out, but that's about the extent of how "intrusive" it is.

The battery life is very good, I typically get several days to a single charge, which is far better than the Apple Watch. But most importantly it's comfortable to wear during sleep - indeed it takes the majority of its measurements only while you're sleeping. YMMV but there's no way I can wear an Apple Watch to sleep, while the Oura ring works perfectly. I've worn the last two generations of Oura ring and would definitely recommend.


100% recommended as a non-obtrusive sleep tracker. But it's a bit bulky as a ring (and... it's a ring) so I can't recommend it to the same degree for day-time wear.


> Dexcom CGM

Gen3 app without premium subsciption is very limitied https://youtu.be/c4AVLGwkJHo?t=193


My girlfriend got sick and now I have a part time caring responsibility that’s mostly about doing chores and errands. I’m in better physical shape now and oddly feel more capable at my engineering job.


This happened to me with kids. I've always been a lazy slob who plays video games in their spare time. By my late 30s I was starting to feel like a bag of garbage.

But when I had kids it forced me to move and do things. Now I feel better in my '40s than I did in my '30s.


While the chores isn't as fun as a hike, active rest is better than passive rest. Helps that it seems like you have a positive attitude to the chores.


I've never had an issue doing small chores but in the past i'd basically organized my life such that i avoided having to do as much ancillary stuff as possible. Now, whatever reservations i had before about repetitive shit like washing dishes by hand or running errands are gone because its for an immediate, greater purpose. And she really appreciates it :)


This. My thinking was getting so bad that I went to a neurologist. At the same time I started walking daily. A month or two later and I feel like a totally different person. Mental clarity has sharply increased. Haven’t even fixed my sleep yet either. Can’t wait to see how much more improvement I can get.


Would you mind sharing the routine, or a general outline of how you approached weight lifting from “zero” to “one”? I’m approaching 36 and haven’t lifted anything in 10+ years. But reading sentiments like this is motivating me to start again. I’m just scared honestly - my body has atrophied quite a bit the last 4-5 years at minimum


Sure! As someone who failed for decades at establishing an exercise habit, a few things were key.

* I hired a personal trainer. Actually, two of them, scheduled on different days, to reduce the chance that I would saddle myself with a bad one and not know it. After 2 months I let go of the least effective trainer. The trainer(s) were huge at first because having an appointment with someone helped me actually get off my ass and show up, my own willpower alone was always insufficient in the past. They also exposed me to a variety of exercises which is how I learned that I really enjoyed weight lifting (and some other exercises, not so much). Nowadays I just have the one guy once a week doing form checks.

* I joined a very nice gym near my office, again as a motivator. It's easier to attach one habit to another habit, and the habit of going to work is pretty ingrained, so "walk across the street for one more appointment" turned getting into the gym from something hard to something that was basically automatic. My workout is my favorite part of the week now because my gym also has a great jacuzzi and afterwards I get to plop into the jacuzzi, veg out and catch up on podcasts.

* In terms of the "technology" around weight lifting specifically. I'll triple emphasize just hiring a good trainer and just following their instructions at first. But once I started engaging my own brain, I found A) Correct protein/macro intake was bigger than everything else in terms of getting results. Get your daily protein to where it needs to be (which is freakishly high) and same goes for calories (depends on your current body type and intake). B) You don't have to push hard on increasing weight at the beginning at all, nor worry much about how many reps you do, just do what is fun and safe and do it regularly. C) For further education the book Starting Strength and the Fitness Wiki maintained by Reddit's r/fitness are really good. They recommend similar beginner workouts and as an out of shape guy, you can basically start on these immediately as long as you're getting regular form checks and sticking to low weights. (I actually was so weak I had to start with just the bar or even dumbbell variants... once I started pigging out on chicken and whey, that changed very fast, increasing how much I was lifting got easier, and within a couple months I had muscles everywhere.)


Typical good advice is to do some simple barbell compound lifts like Rippetoe’s Starting Strength. Deadlift, squat, pull-ups, hard to go wrong with that base.

Make sure you ramp load gradually if you have lifted in the past, your muscle memory can return faster than your connective tissue strength leading to injury risk if you stack the weight aggressively.


Make sure you ramp load gradually if you have lifted in the past, your muscle memory can return faster than your connective tissue strength leading to injury risk if you stack the weight aggressively.

This! Dealing with this right now :(


I am 34. Start HIIT (high intensity interval training) 10 weeks ago. First time in my life I am in a gym. I also notice the transformative effects.

The way I am managing to build my habit: Only do group sessions. If you want to go fast you go alone, but if you want to go far you go together. I know that group sessions are the only thing that give me enough structure to continue.

So maybe it will help you get started as it did for me? Personally I went to a fairly expensive gym so the groups are small. This to minimise risk of injury. Try it if you can afford it.


I'm not who you asked, but I'll share my experience escaping sedentarism in advice form:

Start with push-ups. They're fast and require nothing but a flat surface. You can always transition to lifting weights later.

Start today, ideally right now. Seriously. It's your only chance. Tomorrow there'll be an even better reason not to.

Don't worry about initial quantity. You can start with two push-ups, that's fine. It'll take ten seconds if as much.

Repeat every day.

When you feel it got too easy, increment by one starting the following day, not at the moment.


This. For me the secret to actually going from total couch-potato to fit was to exercise every. single. day but Sundays.

I tried 3 times a week or whatever, and every day you'll find some excuse to push exercising to the morrow.

But doing exactly the same routine every day was key. Then the routine evolves with time, but it's almost always the same routine. I started with a few pushups, then added burpees, then I bought some weights and added a few movements, then I started running 300m a day the first week, and augmented gradually until I ran 42 km every single week.


You might look into a trainer for a few sessions. I'm in a similar situation, and just getting back into lifting with a set of at-home weights. Thankfully, one of my company benefits is an in-house trainer who you can sign up with for a few remote sessions. She's putting together a plan for me, then will do a few zoom calls to make sure I'm doing the exercises right, and hopefully that'll take care of things.

Years ago, I used a trainer in a gym to kickstart a plan, and I found it very useful.


+1, I highly recommend getting a personal trainer for a few sessions. They can even do remote video sessions outside of signing up for a gym. A good trainer can recommend exercises that provide just the right amount of challenge - not too low that benefits aren't there, and not too high that the difficulty makes you quit (this is a problem with gym group classes).


I’ve had a very successful similar experience with regard to excercise.


Hmm. Do you think we will ever get a pill to replace exercise?


Maybe centuries from now we will be able to replace movement with a bunch of chemicals that confuse the muscles to think they moved, but movement actually causes a lot of hydraulic pumping effects throughout the lymphatic system that physically diffuses toxins into a waste stream.

It’s probably not possible from a physics standpoint to replace motion induced pumping/diffusion with pure chemistry.


You don't necessarily want to mimick muscles moving, but rather the brain effects of said muscles moving

Its possibly people may isolate the two effects separately


I suspect the brain alone cannot do it. At a some point the chemistry needs to happen, and it has to be in the right place (so the physics of moving liquids inside your body is also required).


Maybe not a pill but hopefully we'll have advanced technology that can determine what kind of exercise is exactly right for your goals, take into account any injuries, and tailor your Travelator(tm) Mech Suit to provide you enough resistance for maximum gain with lowest effort as you complete your daily outdoor cobalt mining gathering allotment for LikeCoins.


Exercise is a source of enjoyment, why would you want to replace that?


I exercise on a strict schedule, both weight lifting and cardio. It is never enjoyable for me. I don’t get runners high, or pleasure from the exertion. I just make myself tired, sweaty, and add on temporary pain to my muscles.

It’s worth it for the global effect on my energy levels and health. But it remains true that for some of us, exercise is never a source of enjoyment, and I understand why many people can’t get through that to do it anyway.


> I don’t get runners high, or pleasure from the exertion. I just make myself tired, sweaty, and add on temporary pain to my muscles

I feel the same way with exercise. People tell me that you feel good after and I never do. People tell me that you feel a "good" soreness in your body and I never do. I just feel sore.

I wonder what's different about people like you and me where we don't enjoy this process the way some other people do? Do you think it's been studied?


I used to struggle to build muscle the same way, until I switched to a paleo diet.


I’m in the same boat. Sports is a great shortcut but it’s just a lot of mental effort to meet new people.


Perhaps the pill we'd need is one to make everyone enjoy exercise at some minimum base level. Plenty of people I've talked to were either not enjoying exercise at all, or did enjoy it while they were doing it, but have a lot of resistance to getting started every time they plan to do something.


Love this idea. As I’m on the couch in my running outfit, avoiding running, I clearly need to pop a Motimove.


The trick is it's not a source of enjoyment for everyone; if it were there probably wouldn't be such an obesity/heart disease problem in this country.

This is kind of where I always have been, I find exercise to be a loathsome and boring chore, a necessary evil that gets in the way of things I would rather be doing.


Same for me, I hate exercise for exercises sake. I always have to make it a side effect of something necessary or fun I'd rather be doing - commuting by bike, mountain biking, standup paddling or windsurfing etc.


> Exercise is a source of enjoyment, why would you want to replace that?

I wish I felt like this. Exercise is tolerable when I'm doing something at the same time (walking, chatting, listening to music) but that's enjoyment despite the exercise, not because of it.


Most of it's less enjoyable than several other things I could do with that time instead. Focused cardio, especially, is miserable enough that I'd rather do a bunch of other things I find unpleasant instead (IMO). The parts I find enjoyable enough that I'd choose to do them over other not-unpleasant things mostly require a bunch of other people (sports) and are hard to schedule, and then become another thing to schedule around for other activities or things that come up. Weight lifting's fun as far as such things go, but takes up space or requires trips to the gym.

The feeling after's nice, though. Would take that in a pill form, for sure.


Yeah, nothing is going to replace eyes, ears, memory muscle experience. Imagine something would replace table tennis sensing experience?


Probably not to replace excercise, although who can say with gene editing.

Reducing, stopping, counteracting mental decline is a holy grail in medicine. I think there has been some progress here.

And on the general mental acuity note there are things like modafinil.

The best things known work are do what you need to do to get good sleep, and find some way to exercise routinely.


While we don't have this we do have two simple technologies which massively amplify the benefits of whatever exercise you do: whey protein and creatine (plus a whole host of others where the risk/reward profile is less straightforward)


I like the joke "If exercise were a pill, every doctor would prescribe to everyone."


We already have many, the side effects however are... problematic.


Anyone have experience comparing weight lifting vs other forms of exercise? Curious of how cardio vs weightlifting compares for example. I have heard a lot of podcasts talking about some psychological benefits from low heart rate cardio that are difficult to replace with other forms of exercise, for example.

Call me a wimp but I find DOMS can be a little distracting haha.


I find DOMS kicks in after taking a week off from my lifting routine or when I switch the routine altogether. As long as I keep a week between working the muscle group, DOMS isn't a thing.

When I do expect DOMS to kick in, I drop weights to 50% my max sets (usually dropping weight vs reps). This makes me "somewhat sore" the following day but no more than that. I also put an emphasis on sleep, "clean" nutrition and supplement with electrolytes. Works really well for me.

As for low intensity cardio, I feel it's good for me, but I have to say it can be a struggle to keep it low. The feeling of "I want to push harder" can sometimes be overwhelming.


Also, our standards improve as we age. I wrote a lot of high-energy seemingly clever code when I was younger, but it was nonsense and terrible to read. Now I would not allow myself such indulgence, and so I work differently, maybe at times more slowly, and it might seem this is due to less abilities, but actually it is due to wiser experience.


It turns out the same dynamic is at play with songwriting - your standards get higher, what seemed novel when you were 20 now seems boring. I’m sure it is the same across disciplines. The irony is, it kills creativity.


That definitely matches my experience. I spend so much more time re-writing existing songs than I did when I was younger. It used to be almost entirely creating new material and moving on to create more. I wonder how much is my standards have gone up or lack of novelty in general as opposed to how much I've become attached to some of what I've created and feel it is worth polishing. Some of both I think.


Does it though? I often find it's fun to find new and novel ways to create things that are both clear and efficient. Creative problem solving can be leveraged anytime.


I think the problem is you start saying "no" to more things (literally and metaphorically) before you've even worked the idea or given it a shot. This is purely supposition.


I like to think of creativity as out of the box thinking, and as we get older and more experienced, the box grows.


That is a great way to phrase it.


That is the gist of it, yeah. You get discouraged because you can't come up with anything interesting, whereas when you were 20 everything you came up with seemed interesting. I'm just generalizing my own experience of course, and there are more things at play than just this - like I think not yet knowing all the rules has something to do with it. I try to be aware of it, and take some advice I heard once at an artist-in-residence talk: sometimes quantity is better than quality. That is, treat making like sports: practice.


> You get discouraged because you can't come up with anything interesting, whereas when you were 20 everything you came up with seemed interesting.

This is so true. I'm 37 now, and I'm struggling with that - I'll come up with a project idea, only to second-guess myself whether it's ambitious or innovative enough, and really worth spending the limited time I have available. I end up questioning whether it would really count, or just serve as frivolous self-entertainment.

When I was younger, it was good enough that ideas were interesting or would help me achieve mastery. Once you have a bunch of well-worn skills under your belt and have plenty of options and the ability to make commitments, everything becomes just a function of effort/time and choosing what to do next becomes the biggest challenge.

I'm trying to cut myself some slack and allow myself some amount of time to pursue frivolous ideas. At least you can intentionally combine them with e.g. new implementation technologies (e.g. a new tech stack or new tools) to get important first-hand experience and maintain relevant skills (and therefore decision freedom).

I'm also hoping that some day, having kids might help me with some of these anxieties :-). If I revisit/retread older ground then perhaps to make it accessible to them at home or teach them by doing little projects together and give them a boost and allow the next generation to take it further. I.e., even doing non-innovative stuff could count, as a fundamentals teaching moment for someone else. Hope they take an interest!


I have not heard this take but it does seem plausible. What to do about it ?


Give yourself credit for working at a higher level of quality.


Yes. Also, don't think you are too good to fail, we still learn by failing even at 50. I've said some more in another part of the thread.


If you're not failing, you're not learning!


I returned to the first project I made as a software developer after being about ten years away from it. Never do that. Haha. But it was quite educational to see how my problem solving had changed. Fortunately I didn't need to refactor everything because if I did that would have been a nightmare.


Yeah old code of ours, reminds me of a now old comic ...

http://notinventedhe.re/on/2011-11-9


When I was 40, I think my cognitive capacity and coding ability was pretty good - possibly peak. By the time I was 60, I found learning new stuff (especially languages and frameworks) hard; but that was partly or wholly because I didn't regard learning new tricks at that age to be a good investment of my time and effort, since I'd soon be retiring.

Since I retired, I have suffered a cognitive decline; everything takes longer. But, you know, I'm retired, and work expands to fill the time available.


I'm 53, I'm feeling similar. I see the 7th package manger or the 4th pipeline manager or the 17th linux disto or the 52nd video game where you can craft shit...

and it just makes me tired. While I'd like to retire and think I'll financially get there sooner or later, I'm afraid that there's an underlying structure to work that I'll miss.


Another thing is simply that we have lower tolerance as we age for things that are boring. It's hard to get motivated and concentrate on something you don't enjoy. When I was young, I could bend over backwards for stuff I thought was meaningless but now I just shrug and try to avoid the kinds of problems you describe -- and if I had to do one, I'd probably procrastinate and feel lots of negative emotions.


As a 45 year old lead developer, this is the answer that I most align with. Not only are job expectations a bit higher than 20 years ago (ie, back then you could just say "I'm still workin on it" but today you generally have to give progress reports at least daily and have your velocity tracked), but at this age, my time can be strictly regimented (exercise, chores, caring for the animals, appointments, helping in the kitchen, doing actual paid work...) from before-sunrise until almost midnight. I'm not quite sure what happened to the days that seemed like I had a whole ocean of time, but even writing this reply is a bit much. Give yourself some grace. Afternoon siestas are a great idea if you can sneak them in.


> you generally have to give progress reports at least daily

This trend seems genuinely goofy to me. If you have daily reports, standups, or whatever, you're going to be spending a lot of your time prepping for those. That's time that you're not spending writing actual code (or whatever you're nominally supposed to be doing).


Came here to say much the same. I'm older (51), and have felt I was losing my ability to think over the last few years, and also to express myself clearly in conversation. But a great deal of this is to do with a number of huge problems that have happened with my step-children and the near-constant onslaught of having to deal with a variety of agencies and not just run off into the sunset. Plus I decided I could self-build an extension to my home.

It may well be that the OP has other load that has crept up on him; until you take a step back it's often difficult to see what's happened over a period of years.

But burnout is a thing, and sometimes you need to take stock, take a break, and maybe even make some big changes. You're only here once, so it's a good idea to give it your best shot, IMO.

As far as anyone can tell.


I agree - I think cognitive decline is very gradual over life until older age. And experience makes up for it. Some abilities even improve. [1]

Responsibilities seem to multiply. And as you age you sometimes find you're not only caring for kids potentially but aging parents. It's a lot.

1 - https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4015335/#:~:tex....


I have my problems with burnout and depression and this usually leads to phases where I am hyper productive and can effortlessly take on any challenge, and then the opposite phase where I feel completely incapable and end up overthinking everything.

Even without burnout, sometimes a problem doesn’t motivate you and therefore you don’t really feel like solving it when there are other things that seem more interesting or more practical.

Either case, once the down period starts it’s a good signal to take some time off and get your head out of it.


I concur with a lot of what other people are saying here. Late 50s, programming professionally for around 25 years. But recently switched to management. Really hard for me to focus on details of the companies code anymore.

But... when I get on some personal project, I'm on fire. I can learn new languages and concepts and systems and build pretty complex things that people are amazed at.

I think it's more job burn out after years of writing code for other people. You write the code and you work towards the deadline like the world is going to end if you don't make it. Then that code is in production for a year or two. Maybe more if you're lucky, and then it's gone, replaced by some new thing. You stop caring quite as much. But you see these new young kids on fire and working all night and you get imposter syndrome and you try to care and you beat yourself up and think you're losing your touch. tmi?


big +1 to all this. Also if OP had COVID, check for long COVID symptoms of other kinds, incl cognitive issues with non-programming tasks.


I'm 50 and can confirm this. E.g., I'm currently much more concerned about how politicians seemingly driving the country I'm living in and the world as a whole downhills in all regards. These worries are of course a waste of my personal energy.

On the other hand: When structuring my day with Pomodoros (https://en.wikipedia.org/wiki/Pomodoro_Technique - especially doing the rest properly, meaning just lying down doing some relaxation technique) and resisting all other harmful stuff like (to much) news or (any) social media, I feel like I'm even sharper than in my younger years. Even remembering stuff better.

So, I think those problems are to be spotted in our changing environment and internal setup more than in an aging process. At least not at 40, 50 or 60.


For someone who has been forced to try countless substances / diet regimens / health strategies due to a pervasive chronic disease, I beg to differ. There's so many things that you can personally do that will alter your cognitive abilities, sometimes to an incredible extent. The tricky bit is that there is indeed no silver bullet, and what works for someone might do nothing or create harm for another. So in my opinion, understanding that there are alternatives to resignation is really the critical component.


I think this is quite true, and I've noticed that my son can remember virtually every pokemon card and football player he's interested in whereas I've started to have to write things down. His world is quite small and now with the Internet etc our focus is very wide. It takes serious discipline to focus on something low level exclusively and not be subject to outside interference.


Yes, let’s not spread around some idea that mental ability declines at 40. That’s just ridiculous and not backed by science. It sure is backed by ageism though.


thank you for adding "(if you can)" to suggesting they relax...that is real


i think that's perfectly said, and i'm 55.

in short, that assignment sounds de-motivating, so you're predisposed to notice momentum is hard to establish.

and getting coherent blocks of time, to get in a flow as they say, is the challenge that hits me all the time, and which i didn't have when going to an office 20-35 years earlier (including in college i mean).


> As we age, we usually end up with more and more life responsibilities

As somebody who far away from 40, how is one supposed to "look forward" to getting older given this likelihood?


More life responsibilities isn't a bad thing. Life is (or should be) made of intentional decisions by the user (you). And the culmination of these intentional decisions can fill your life with meaning, purpose, and fulfillment.

You don't have to take Responsibility A if you don't want to, but you have to live with the consequences of your decision (good or bad). It's a trade off. I want a house. I make that decision for that responsibility. I now own that responsibility knowing the duties that come with home ownership will take a portion of my time and therefore will reduce the availability of time once given to a different responsibility.

Of course, mistakes will be made, but the best part is you can most often correct mistakes in healthy and meaningful ways.


Pretty sure nobody looks forward to getting older except for the young.

People plan towards retirement which is usually just looking forwards to not having to work anymore.

People look forward to having children and grand children.

I don't know anyone who looks forward to getting older except for the young.


Everyone says "I'm not as quick as I was when I was younger, but I have more experience."

But that's a very sad kind of survivor bias. You were born with your quickness, but you have to earn the experience. Not everyone ends up middle-aged with useful experience. You hear only from the ones who do. And nobody has a time machine.

So look forward to reaping the benefit of experience, but let that be a warning that experience doesn't happen for free. Use your youth to acquire as many lifelong skills as possible. Use those skills in challenging ways to develop judgment. Use your skills and judgment to develop meaningful relationships with people who have chosen similar strategies.

Being able to offer solid skills, judgment, and relationships, rather than the ability to work consecutive 18-hour days, is what you'll have to look forward to.


Without responsibilities your life has no stakes, and no rewards.


Those life responsibilities are not mandatory unavoidable things. They're choices.

Such as: owning property, owning car(s), having children, getting married, getting a mortgage, etc.

You can chose to not do any of those things and basically live like you're 20 when you're 80 (in terms of responsibilities).


As someone who has done all the things you listed, my experience is that the grass is always greener on the other side.


By enjoying today, tomorrow will come regardless of whether you want to avoid getting older. Best you can do is prepare for tomorrow, health and finances.


Life is more fulfilling, but with more responsibility comes more things to worry about.


They are first world problems and if you read carefully everyone who has gotten responsibilities chose them and they are very happy for it.

It's just the mind's way of coming up with problems when there aren't any.


It just feels like you gradually "give up" a life that was once yours (less responsibilities) and are "slowly forced" into a life that isn't as much yours (get married, buy a house, have children).


Doesn't "slowly forced" imply lack of agency?


> sense of agency refers to the feeling of control over actions and their consequences.

You're damned if you do (give up control) damned if you don't (walk through life unmarried with no kids in an apartment wondering what could've been)


I've experienced this periodically since my early 20's - generally in hindsight I realise it was: real life getting in the way, burnout, lack of interest (I was interested in the idea, but on some fundamental level - not the activity) - also occasionally just a feeling of Groundhog Day (ie. Some code tasks can just feel a little too familiar - even if novel, and that saps my joy)

Either way, at the time it was quite worrying - even disturbing - especially when there was work to be done, so think I can relate

Generally I was able to reverse it by working on something which really stimulated me - even hacking away on some goofy personal project after hours - and that kind of bootstrapped me back into a place where I could easily attain flow for "harder" tasks. Can't recommend that highly enough, that and realising that I had different stimulus needs to previously - changing up my coding music, or even foregoing it and switching to mynoise.net yielded some excellent results, or reducing distractions (try periodically disabling system notifications)

That said, if you're really concerned probably see a doc just to rule out any funny business

Ps. Best of luck with it, crossing fingers for you


It could also be attention span problems caused by social media.


And technology in general. There is a video by HealthyGamerGG that explains how using smartphones or computers turns off a crucial part of the brain that knows what is important and you should focus on.

The longer you're in front of a screen, the more you lose awareness of yourself and what you enjoy. Taking frequent breaks away from screens is important to stay motivated and restore that drive towards meaningful things.

It's sounds wishy-washy how I explained it here, but the video has a more scientific explanation of this phenomenon.

https://youtu.be/zBgCRJluWTc


This is totally killing every focus there is for me. My IQ drops to at least 50% when there is a smartphone close by. Eliminating all source of distraction that I can, is essential to get anything done.


Smartphones don't just reduce your IQ; if you use one while walking, it removes all your situational awareness. I constantly have to step out of the way of some zombie walking along the footway, oblivious to the existence of other pedestrians.

My smartphone stays at home, on permanent charge (the battery life is severely depleted). I use it only to collect SMS 2FA codes from those organizations that assume that everyone has a smartphone. We call them "mobile phones", but that doesn't mean you have to move if you're using one.

That zombie effect applies equally if you're behind the wheel of a vehicle. Please don't ever do that. Of all tasks, driving is the task that requires the greatest situational awareness.


Or ADHD


Thank you. Good advice about hacking on some personal projects/experiments. I'm worried that wont rebuild my confidence and abilities fast enough though. I want to make progress on this task today, not next week. Other developers seem to be succeeding, and I'm worried about how I'll look if it takes me weeks do to what others are doing in hours. (This isn't meant to dismiss your advice, to but to give feedback and solicit even more advice.)


In addition to the GP, I'll add there's a certain level of naïveté of being young that makes one feel like they were better than they were. I'm mid-40s and am probably the best I've ever been at writing good code, but sometimes I can get vapor locked knowing all the things I need to account to for. When I was younger I just coded because I didn't know any better.

So when I get stuck now, I just start writing code like I would have when I was early 20s.


Not in my mid-40s yet, but vapor lock is a great term. I also try to do the same, just write crufty code that works, hopefully clean it up some as I go.


> I also try to do the same, just write crufty code that works, hopefully clean it up some as I go.

I account for this in planning. POC -> POC validation -> Finalv2ForReal -> Finalv2ForReal validation

It gives two shakes at a decent solution with some built-in learning. If this looks like too much for business then well I tried I guess I'll do less work for the same amount of money (inevitably the stupid shit that got prioritized goes away). And I documented what I would have done and can point at it when POC as a service is ermmmm ... less than performant.


This. I feel this basically every day now. I really miss the naivete, and I struggle mightily to "just start writing code like I would have".


I second GP's recommendations. You stopped working out. Muscles atrophied. A bit more sweat time and you'll be buff again.

"even more advice": Issue is likely mental focus (since you have a finite daily mental, emotional stress budget)

https://www.goodtherapy.org/blog/breaking-the-chains-finding...

- (let go of) mental re(re)view. "This too shall pass".

+ (embrace) "just do it" && "Don't worry, be happy".

! (remember) chemical dependencies, if any, must be brought under control.


> Other developers seem to be succeeding, and I'm worried about how I'll look if it takes me weeks do to what others are doing in hours.

That one exact thought is compounding your problem. It's pure anxiety and it makes problem worse, I know from experience. When you think that, try to calm yourself with "yeah, it's just anxiety speaking, it will be fine". Maybe also try magnesium supplements, magnesium citrate helps me (but it typically takes up to a week of supplementation, minimum 2 days).


Often the "hack on something personal" just flicks a switch for me, I'm talking within an hour or two - but sounds like you're feeling a bigger sense of urgency than even that would help.

.. which honestly sounds an awful lot like the stress of the situation (or concern about cognitive decline) - which isn't going to do your focus any favours!

Any kind of reset can help with that: go for a short walk, chuck some binaural beats on headphones and close your eyes for 5 mins, drink a warm (non-caffeinated) beverage and think about something else.

Above all else: probably good to just remember everyone has off days, other engineers aren't going to judge you for a day of lower productivity

Aside from reducing your internal stress, One key ingredient of finding "flow" is a sense of immediate feedback, perhaps allocate 20 mins to some short tasks which give rapid reward; write a couple tests, draw a diagram, etc..

Binaural beats (use "relaxed"): https://mynoise.net/NoiseMachines/binauralBrainwaveGenerator...

Going for a walk is kind of a lightweight "shower effect", random article link: https://buffer.com/resources/shower-thoughts-science-of-crea...

(Sorry, time zone mismatch slowed my response)

Link dump (for reading some other time)

- stress and brain function: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6504531/ - flow state https://en.wikipedia.org/wiki/Flow_(psychology)


> I'm worried that wont rebuild my confidence and abilities fast enough though. I want to make progress on this task today, not next week.

I’ve experienced this a bunch of times too. I’m sorry to say this, but burnout for me never goes away on a convenient schedule. The more I make myself wrong for feeling overwhelmed, distracted and unmotivated, the worse it gets. Or in other terms, problems are rarely solved with the same thinking that created them.

For me, I have to really give myself permission to step back, take stock of myself, get some sleep and good food and often take a break from “work” programming tasks for a few weeks. (And I know exactly how inconvenient that last part is).

The more I push myself to feel better already, the longer it takes.


That is just unrealistic ?

Some days you just feel down and are barely able to function, others you have seemingly unlimited energy, and this can come from a whole host of factors : how did you sleep, what did you eat, what is the weather, how is your personal life going...

And of course things get worse as you age (with quite a lot of variation and personal responsibility in staying healthy).


Your mind will eventually be back at peak performance, but meanwhile you can use pen & paper to help you with this.

Write down what are the big challenges/problems, try to break them down and write about it, keep dividing it until you start to see that you can tackle the indidual pieces.

I'm 42 and I've been in a mental place similar to yours, but a little more drastic due to a hard time in my life, and it took a while to get back into top shape, but the effort to break down my problems on paper helped me tackle some immediate tasks I had to accomplish.


I don't think there is anything sustainable that will work this fast.

Good habits and lifestyle changes take time.

The only other option that has worked for me would be drugs like Adderall.


47 years old here, programming daily.

I think what we have to deal with is not just cognitive decline, but more importantly cognitive overload. People in their 40s usually juggle lots of responsibilities, especially if they have a family. At this age you normally also have earned some money, and if you start buying things like a summer house or an apartment for renting out, those things come with maintenance tasks. This can accumulate quickly.

Whatever the reasons are, my approach was to get used to it and work differently. I am terrible at doing multiple things at a time and my short-term memory is bad, so I learned to concentrate on one task at a time and eliminate distractions. I buy large monitors, so that I can have multiple things on the screen at the same time and avoid having to remember (I can easily forget an IP address when switching windows!). I spend money on Apple hardware, because of 5K displays: 5K makes a huge difference, because I can comfortably have THREE columns of code in my fullscreen Emacs instead of two. That means I often have 5 different pieces of code visible, which does wonders for things like APIs, which you mentioned — I can follow the entire path of a call and keep it all on screen.

I also noticed that there are positives that come with age and experience! I find that I'm much better at seeing the "big picture", analytical thinking, design, and predicting potential problems. Most importantly, I'm now much better at knowing what not to do. These skills are invaluable when running your own business.


> if you start buying things like a summer house or an apartment for renting out, those things come with maintenance tasks. This can accumulate quickly.

This is a really good point. I feel like I'm dealing with way more responsibilities now that I have a house and a family, I'm no longer the center of my own universe.


> I can follow the entire path of a call and keep it all on screen.

This seems like a particularly helpful suggestion, both for the original context of the question, but also something I'm likely to use myself. Thanks.


BIG +1 on cognitive overload.

I can still bang out code like nobody's business, even in my late 40's... when I can find 4 uninterrupted hours to get into it. Which is rarely.

It's more about depth of focus, which was so easily available for 10+ hours a day when I was younger.


I can relate so well with the "4 uninterrupted hours to get into it" part.

With family+house responsibilities, I rarely (if ever) have that anymore.


Sounds like you've identified your problem with the task - you can't hold the entire state of the problem in your head all at once, but maybe you would have been able to in the past.

This seems like something you can overcome. Have you tried writing these function calls out as a flow on a piece of paper, or in a flow chart, document, something like that? A reference which you draw to be able to tell where you are the stack and where you came from.

It sounds like a very crusty task and I doubt I could maintain that many levels of calls in many different contexts. The important thing is finding a mechanism which works for you.

edit: I'd note that it's possible your development environment is older than your colleagues, too. Many modern ones (VS Code, etc) can jump around a codebase automatically - find callers to a function, jump to where the next function is defined, etc. Maybe check their setup and see if it's worth adopting.


Charles Simonyi said:

"It’s probably just that aging changes your mode of thinking. Right now, I have to really concentrate and I might even get a headache just trying to imagine something clearly and distinctly with twenty or thirty components. When I was young, I could imagine a castle with twenty rooms with each room having ten different objects in it. I would have no problem. I can’t do that anymore. Now I think more in terms of earlier experiences. I see a network of inchoate clouds, instead of the picture-postcard clearness. But I do write better programs."[0]

I can believe the part about better programs. Can you imagine working with somebody who can clearly visualize software with 200 sub-components in it? I once worked with software written by someone who had similar powers. He was a hardware designer. His software had very little organization; he wrote imperatively and remembered where everything was. Six months after he handed a program off to me, I spoke with him and told him I was currently trying to figure out where a particular component was initialized, and he told me exactly where, in what part of what file. IIRC, some hardware registers were being initialized in a procedure that was allocating working space for a numerical part of the program, because that's here he happened to open the log file for the first time, and he wanted the logging from the hardware registers to be the first thing in the log file, before he logged the fact that the memory had been allocated successfully. He remembered this with no hesitation, more than six months after he last touched the code, possibly two years after he made the decision to initialize the hardware in that spot.

Someone with less mental horsepower, like me, has to organize their code into modules with clear names and responsibilities.

[0] https://programmersatwork.wordpress.com/programmers-at-work-...


Thanks in part to ADHD, I'm sure, I have severe tunnel vision while reading and writing code. I need to constantly diagram, take notes, and walk through call stacks (and re-walk) just to maintain my mental model.

I am insanely jealous of people who can keep everything in their head. Maybe there's a silver lining in that my methods are more resistant to brain-busting situations, depression, cognitive decline, etc., but I'm not sure that I'm convinced.


The flip side of that is people who can keep everything in their head often write code which reflects exactly that, and that code is very hard for others to scrutinize.

I try to lean into just such a silver lining. I like to write my code for worst-case future-me: what would it take for my sleep-deprived, Monday morning, uncaffeinated brain to make sense of? It definitely helps, especially even considering that approach, I often find I overestimate my future ability to understand past code.


> some hardware registers were being initialized in a procedure that was allocating working space for a numerical part of the program, because that's here he happened to open the log file for the first time, and he wanted the logging from the hardware registers to be the first thing in the log file, before he logged the fact that the memory had been allocated successfully.

To be fair (haha) I went from writing super organized code with loads of concise, well-documented files to writing code just as you describe when I started designing hardware and writing more complicated embedded firmwares. For whatever reason, hardware initialization boilerplate doesn't like to be spread out or organized. As soon as you try your code ends up breaking outright or becoming a vastly more complicated, gigantic mess.

It's because the hardware is soooo specific and we as software developers want to make interfaces that are as generic, high-level, and re-usable as possible. Example: You can't just write a function that takes two pin numbers and initializes I2C on them so you can talk with some module. You usually have to know--ahead of time--which two pins you're going to be passing to that function (so the types match; because each pin has its own special type haha) so the function can initialize the correct I2C bus on the chip (in the right way)... Which immediately makes such a function non-generic and kinda pointless since you'll never be able to re-use it in anything else for any other purpose. You quickly get into the habit of saying to yourself, "Why am I making this a separate function again?"

Also, the order of operations matters so much more in embedded stuff than it does in regular software. I could totally see the situation where you want to initialize logging immediately after initializing some hardware because you want the logs to reflect values that you only happen to have available during initialization... You don't need them after initialization so why waste precious memory keeping variables around just so you can log them later? Just setup the logger in the same code, write your variables, and be done with it!

Makes sense, right? Hah! Only in the world of embedded firmware!


This is good advice. Just a few days ago I randomly stumbled upon a youtube video where someone was using — blast from the past, here — a hunk of green bar line printer paper as a big scratch pad to write on. It made me wonder how I ever got out of that habit. That stuff, when it was ubiquitous, was the best scratch paper ever, and I used to do it all the time when I was young and, one would think, at my cognitive peak. Maybe falling out of that habit is part of my percieved decline.


I would want one of these Etch'n'Sketch but with a pen and some higher resolution. The variant where you pull a lever to reset it.

Whiteboard markers are too wide and I am left handed so I erase as a write.

And using paper makes it feel like I am wasting paper.


Does that really work out, with regards to waste? I mean, does something with a circuit board, a battery, an LCD screen, a case, a stylus, and a limited lifespan really end up being greener than renewable, recyclable, compostable plant fiber?


Etch'n'Sketch doesn't have batteries right? Or am I remembering wrong.


Those things exist. You press a button instead of pulling a lever. Search for "drawing tablet" or "writing tablet". I've got a 20" one by Xiaomi, but there are lots to choose from, very inexpensive too.


Yesterday's top post linked to this tool: https://www.knotend.com It's a super fast/light flowchart editor. Might be useful!


Use graphviz[0], forget manual graphing. While many tools can generate a call graph, confidence rolling your own is a good superpower to have.

For example, write a quick script to add a panic (nonexistantFunction()) as the first line of each function. Then, call each function in turn. Save the panic's function stack trace, then process them as a combined graphviz file.

This simple and efficient hack will get you all the most important edges in most cases for most languages. It won't get you the internal links, for those you need a more effective parser or more exotic means of obtaining branched call stacks.

[0] http://graphviz.org/


IDE code intelligence can help a lot. Anything that makes reduces the cognitive load of navigating within the codebase helps increase the mental capacity you have to keep the context loaded.

When tracing deep call stacks I can find it helpful to write out the question I am looking for the answer to in a comment. Then I can retrace my thoughts back up the callstack using the very handy shortcut to go back to the previous curson position.


I second the idea to draw out in a simplified flow chart like visio or excel boxes or graph paper. Nothing fancy, no ISO standard schematic, just journal sketches. The context being not the entire system design but for a single call what is the flow. That helps me in the weeds and out of the editor thinking. Also it may be 2h to do it for a simple case but I’ve found spending that drafting time helps think about the problem in entirety and saves time in the editor.


I do this. I was burning through a lot of paper and ended up going with a reMarkable tablet which is perfect for that sort of thing.


I know the feeling. I'm 62 and I can't go as long or as deep as I once could, but I've changed my strategy over the years and although I'm not as fast as I once was I'm still pretty productive.

What I do is log virtually everything I'm doing in an editor window that I keep open all the time (one file per project/task). If I get disturbed by a call or a colleague, I can do a quick recap and get back to where I was. Likewise if I lose the plot several levels down my stack. It also helps if I need to switch projects for a while, or overnight.

It's like a running log of my thought processes:

- Need to add feature x to module y

- What docs have I got?

  - How to file in d:\projects\docs...

  - Log file from 13/03/2021
- What routines are involved?

- a,b,c...

- Looking at A

   - I'm thinking of adding a new parameter

     - Who else calls this?

       - Routine F

         - The mod would be straight forward there.

       - Routine H

         - This is called by S

           - This needs more thought, it might be chewy

     - What SPs are involved?

       - UpdateCustomerTable(CustName, Address1...)

   - I've backed up the database to ADB_20230110_1501.BAK so I can test.
What it does for me is offload the requirement to remember the previous levels and lets me concentrate on just the one or two things I'm looking at. As I come back up my stack I re-read what I was planning to do next. I use an editor (UltraEdit) which allows me to collapse things I've dealt with so I can see the wood from the trees.

I keep the log files, which go back over 20 years and can be invaluable next time I have to look at the same project months later. Reading the code AND my notes helps me re-build my mental stack much quicker. It also helps with any bugs that I introduce.

Good luck. It is possible to be productive at an advanced age, and still enjoy it too.


I got severely dinged for saying in a standup that I had forgotten what I was doing the previous day.

So I bought an A4 hardback notebook, and started logging everything I did. I wish I had been doing that since I started in this business; it's a really good work habit.


I wish more programmers knew about this!

I keep a lot of journals. Bullet journals for my daily tasks/planning. Long form journals for deep subject matter: maths, graphics, algorithms, etc. Combined with my writing it's definitely been a useful way to see how I've evolved my thinking over time, etc.

Keep at it!


Isn't this what Jira, Azure Boards, sticky notes are for? You reference the sticky note when talking about what you did. If there's no note for it then your planning was probably bad.


I tried paper and log books for a long time (I've got half a filing cabinets worth), but no matter what system I used I couldn't always find what I wanted. (When did I last modify routine xyz, and why?).

Moving to flat ascii files meant it's searchable and has longevity as it doesn't need any specific tool or app. I can also carry the lot around with me - very useful on site.

Cheers.


Well, I never used my log books as an information retrieval system; the prime purpose was to help me remember what I did an hour ago, a day ago, a week ago.

Of course, I have a digital file of timestamped and commented code snippets and pieces of config. But that's just about the activity of coding; I now think a handwritten log is a good idea for anyone, whatever their trade.

The reason I recommend a hardback notebook, is because it offers the best CYA protection (I was caned as a child). It's sorta symbolic - hard evidence, if you like.

[Edit] You can also scribble in your notebook in meetings, while glancing furtively over your spectacle rims, to intimidate the speaker. Hard copy is power.


How do you organize the files? One per day? Task? Project?


I use a heirarchy of folders and within them I create a text file for each main task:

\work\customername\StockSystem

MyCust001 - Interface not updating PickStatus.txt

MyCust002 - Add Stock Check Flag to ScanPullStock.txt

MyCust003 - Look at enhancing Batch Split screen.txt

I use the numbers as a quick reference within all my documents.

\personal\Diving

Diving book recommendations.txt

Diving gas tables.txt

\personal\DIY

Standard screw sizes.txt

Choosing new security lights.txt

Getting new consumer unit fitted.txt

I add the date and time to a line whenever I start, or after a break. (Pressing F7 on UltraEdit does this automatically). I can use this retrospectively to see how long things took.


I'm 46, and while I do think my cognitive speed has declined a tiny bit, my abstract thinking has improved throughout life. The one change I have noticed though is that programming has become insanely complex during the 37 years I have been programming, but more especially during the last 10-15 years. It's at the point now where you can't even create a basic website, to modern standards, without spending months of work to develop it, or without spending 95% of your time on StackOverflow wrestling with bugs and complexities of 7 different pieces of framework that you're trying to get working together. It's utter insanity.

What I suggest for your current situation is to diagram everything. Just buy some big sheets of butcher paper, and draw out the entire nested API structure. Rely on your visual sense so that you don't have to do as many mental gymnastics. Your visual processing center is the GPU of your brain, it has vastly more parallel processing power than the language processing centers of your brain.

Also remember that everyone has different aptitudes. You might not be decreasing cognitively at all, it might just be that this problem doesn't click with you like it does with the other developers.


Don't compare web development with "normal" software development. Writing code for the web is 10,000 layers of added complexity far above and beyond literally any other kind of programming.

"Normal" programming involves writing code that will run on one specific thing with (usually) one specific use case using tools (and often whole languages) made for that purpose. Web programming involves writing code that will run on any number of servers/devices/containers in any number of locations/networks using any number of architectures with arbitrary resources of wildly varying quantities and qualities that serves other servers, desktops, mobile devices, embedded things, and who-knows-what else; also of wildly varying quality/resources and quantities with wildly varying and unpredictable workloads/traffic intensity.

In other words, web development is about 100 orders of magnitude greater complexity than "normal" software development. It has become so bad that "premature optimization" is the norm; because the cost of re-doing things later to support a new feature/device/endpoint or fix an issue (e.g. lacking screen reader support) can be so great that adding a dozen layers of complexity to writing and deploying your code at the start can feel like a bargain in comparison.


> Writing code for the web is 10,000 layers of added complexity far above and beyond literally any other kind of programming.

Video games? Mission-critical real-time embedded code? Operating system development?

I don't want to knock anyone down, but web programming is not the most complex or challenging thing going, it's just software development.

True, it's made more difficult and annoying than it should be, because you need to deal with a jenga-like stack of badly-designed and poorly-documented APIs, forced to use languages and systems with inherent flaws, and have your targets constantly shifting due to the latest fad. But then, that's not unique to web dev, it's just worse.


I agree that web development is complex. I disagree that abstraction layers add complexity. Abstraction layers solve problems. If you don't have the problems that these abstraction layers solve, then you might perceive that as complex, but most people actually do experience these problems.

The web is not just for websites anymore, it's a universal platform for app distribution. This means web apps can instantly be made available to billions of users. You noticed that yourself. This brings all kinds of complexity that these layers solve. They absorb complexity, not add it. So I don't understand why you would say things have gotten "bad". Things were way worse, but individial contributors never noticed.


> I agree that web development is complex. I disagree that abstraction layers add complexity. Abstraction layers solve problems.

True, until there's a bug in abstraction level 6 caused by an upstream change in proprietary abstraction level 3 that's been patched in abstraction level 8, but not for your specific case. Then it becomes complex.


Yes, but in my experience this doesn't actually happen that often as long as you don't rely on external dependencies too much. This happens in any ecosystem btw.


> as long as you don't rely on external dependencies too much. This happens in any ecosystem btw.

I can't think of many 'modern' projects in the web world that do not rely heavily on an often very large number of external dependencies.


> It's at the point now where you can't even create a basic website, to modern standards, without spending months of work to develop it, or without spending 95% of your time on StackOverflow wrestling with bugs and complexities of 7 different pieces of framework that you're trying to get working together. It's utter insanity.

I am interested in your experience and why you think this? It's not true at all from my experience. In the past, making a basic message board would have been pretty difficult. Now it can be done in days. Same with Twitter clones etc.

What type of basic website takes months to develop?


Is the current API under test?

Your number #1 priority with any port or major refactor is getting the current implementation defined and under test, so any replacement can be tested against the same tests.

Once you've done that you should have a solid foundation and understanding of what the API actually does.

In getting it under test, you'll also build up better mental models of which parts are actually separate and easily testable and which parts aren't.

Then you can get to work replacing and testing each unit, then build them back up on the other side.


You're right, that would make me feel a lot better about this task. Adding tests around the existing API is something I believe I could make progress on, this is a chunk I can break off.


Is the current API testable? So many times I've taken ownership of code that requires an active connection to a database to even be up and running. Changing the code so it's testable usually changes the code so much it is very hard to have confidence it works the same way as the original implementation.

My old company lived and died by its instrumentation of DAU (daily active users). We would try to refactor the code to an IoC pattern with DI but invariably we'd get blamed for a downturn in the numbers - but never lauded if the reverse was true. It was a losing game - we finally had to get management to commit to the modernization (never, ever say "rewrite") and power through the days of low DAU.


How would DI impact DAU?


Adding to this:

> By the time I'm down in the weeds I've forgotten what I'm doing, what the purpose of the actual API call is.

If I can craft tests up front in terms of the higher level goals then when I finish a subcomponent or get distracted by something else the higher level test is there for me to fall back on to figure out what to do next.


Great advice, I was going to suggest the same. You shouldn't have to memorize what each layer of a project does, that's what the unit tests and integration tests are supposed to prove.


I am 40 now and a better programmer/developer than I ever was before. I still encounter similar situations as you but I think you make a mistake by thinking your younger self would have handled this (easily).

The difference is that our younger selves were maybe more optimistic and naive and probably would have just produced a new mess for the next one to scratch his/her head about.

Abstraction is hard and we usually have to much of it in our code bases. You have to break it down and isolate smaller tasks to get started with. Start with some endpoint of the API and try to understand what it exactly does. Usually there also should be an API spec where the ins and outs are defined. Maybe it is easier for you to write this code by adhering to the spec and/or fulfilling existing tests than reading the old convoluted code?!

Probably you know all this and maybe you just hate your task. If this is the case.. sometimes a change is what you need.


I'm 38 and just wanted to comment my experience matches your comment here. I'm probably 20x or more productive now than I was when I first started. Experience does indeed help productivity (to a point).


>The difference is that our younger selves were maybe more optimistic and naive and probably would have just produced a new mess for the next one to scratch his/her head about.

This needs to be highlighted!


Could be burnout, could be ME/CFS, could be Long Covid… could be something else. Have you noticed a limited working memory or loss of enthusiasm? You might notice things like forgetting why you walked into a room, or abandoning hobbies and activities you no longer enjoy. I have ME/CFS from hEDS (far more common than people think, especially here on HN, and double especially those here on HN with ADHD) so I ended up taking a bunch of pharmaceuticals which got me back to work and sharper than ever. One of the core combos I take is a low dose of Modafinil in the morning and Amitriptyline at night, together these act a bit like a triple monoamine reuptake inhibitor but with better timing of action. It’s a reasonably common treatment for depression.

The point is, even if you live a perfectly healthy life with the perfect diet, exercise, and rest, it’s possible that something else is out of kilter and may need serious intervention.

Maybe try a max exertion test for post exertional malaise.


These treatments are legally unavailable to many Americans, due to bullshit moral panics.


They are Rx in the US which makes them harder to get. I’ve not gone down that path so I don’t know how hard, but I’ve read of many Americans using them so it is at least not impossible.

I do think they should be OTC. When I faced the roadblock of not being able to get the medicine I wanted I did go to black market and would do it again in a heartbeat.


I honestly don't think I can, but it might be the best option:

   1. Illegal drugs

   2. Being a head trapped in a jar, hated by all

   3. A bullet
The psychs practically beg you to do it. I was just told to give up ever having a professional career.

Why is nobody talking about this outrageous conduct?

If you mention these concerns, they will suddenly discharge you, and/or treat you like garbage.

All we're doing is creating pipelines to prison. The industry has no problem sending ill people to prison forever. Not only that but droves of people are dying because of these policies.

I'm shopping for a new one, but their initial intake forms are immediately confrontational, and this is someone that seems to have good reviews... I went through several that seemed to have good reputations, and none were taking patients.


I hear you. I've gone on many of rants here and elsewhere on the egregious deficiencies of doctors and medical science. I had plenty of experience with doctors that were unable to diagnose my condition despite it being incredibly obvious so I didn't trust them to treat it from the start.

I just looked it up, Modafinil and Amitriptyline are both Schedule IV drugs for what is OTC in many places, that is pretty extreme.

Marijuana is Schedule I though and plenty of people smoke pot. While it isn't legal the odds are probably in your favor.


I've been thrown to the wolves many times before, having to absorb and trace huge commercial codebases and be productive the same week on making updates and answering questions. Over abstraction is a real thing - real smart developers seem to pride themselves on how much juice they can squeeze out of dependency injection frameworks such as Structure Map and leverage the syntactic sugar of these tools until the solution is almost crystallized with hyper engineering.

I'm telling you this because I don't think it's you necessarily, but that more and more there are codebases that are dense with this kind of thick obfuscating abstraction.

I dropped out of IT when I was 52. I'm 55 now and don't think I could keep up with the constant myriad changes in literally all aspects of tech. Change for change sake is a scourge that lots of companies fall prey to in the name of keeping up which feels to older developers like chasing the rainbow that is just over the next hill...


"the solution is almost crystallized with hyper engineering"

Reminds me of "The grug brained developer" :)

https://grugbrain.dev


42 and I feel the same. If I dig more into what led to this, I can identify two events:

1. Covid. My number came up in September 2022. The mental fog is real and is not what generally people think it is. For me it surfaced as diminished short term memory (example, write down a phone number you see one a website. Before covid, it’d take one or two looks. After covid 3-4 looks back and forth. Hand in hand with this - affected executive functioning. In other words, you just feel dumber lol

2. Burn out. It starts with lack of energy, low executive functioning and progresses into depression and/or anxiety. If this applies to you - get help. Make changes. This one you can fix.

Somewhat related, 41 was the age I realized I don’t want to drink again. Some people have this moment earlier, some never. 1.5years later, the feeling is freeing and awesome. I was not a heavy drinker before but lately I was less and less enjoyable with more hangover (and irritability) the next day.


Programming requires deep thought and concentration. Are you sure the issue isn't simple distraction? I'm 62 and I feel like the major thing that has changed in 35 years for me is the crazy amount of unrelated things (youtube, HN, phone notifications, you name it) constantly competing for my attention. When I was in my 20's I would literally sit in near-silence working for 10-12 hours at a time. Nothing would interrupt or distract me. Of course the Internet has also tremendously empowered engineers by putting a wealth of information at our fingertips, so it's a prototypical dual-edged bladed weapon.


Thats a really good point. In a similar way the number of available technologies gets bigger and bigger as we age, more choices, more to know and more things to fiddle with.

Decades ago the whole MSDOS machine was mine and my tools were an editor, C compiler and linker. Now you need to know a much larger number tools, frameworks and environments before you write a single line of code.


I agree: I'm 58, and I'm not as sharp as the twenty-year-olds, thirty-year-olds, and even forty-year-olds that I pair-program with. To be more specific, the younger developers seem to have a certain mental elasticity that is now beyond me: they can store more in their short-term memory, and they grok code faster than I do.

My brother, who's 18 months my junior and a developer like me, shares the same sentiment: "It's like I used to have 20 registers, and now I'm down to 12".

It's comforting to believe that age hasn't diminished us, but working directly with my juniors has disabused me of that notion.

I feel that Tennyson put it best when he said, "Though we are not now the strength which in old days moved earth and heaven, that which we are, we are."


> can't seem to hold more than about 2 levels of call stack in my head. There's the entry point function which calls other functions, which call other functions, which call other functions, etc.

Couple of solutions:

- Wider screen (I use 50' oled), and the VS Code pin feature, you basically order the tabs to follow the code.

- Note taking support by using nested bullet points, a.k.a outliners, it could be a simple markdown file, Notion, Roam Research, Obsidian ... Then you write what calls what for what reason, and make it kind of nested story.

- Favourite panel in VS Code, rather than seeing the whole tree of files, you can favourite the same files you are pinning, to come back later on, you can have favourite groups by feature if IRC, this might be an extension and not built in.

On the health side, disclaimer: I'm not a Physician!:

- Do you have old injuries that hurt? I'm using my injuries to know when my diet is causing inflammation, I try eating in different ways until the pain goes away, I bet it affects cognitive performance too.

- Mentally having "too many windows open" like the computer decreases our performance, this is worries, fears, stress. Try to unburden those by talking to someone, or find what other healthy needs your are ignoring, like walking, moving, exercise, contact with nature, playing music, doing something creative, laughing ... sometimes we become one dimensional and that's not good for us.

A way to test if you have lost ability or is just crappy code that does not motivate you to follow, is to talk to someone that speaks a lot with side stories, and then see if you can follow all the branches of the conversation and help them coming back to the original branch, if you are able to do so, might give you more confidence. This of course requires to be present, really listening, which is a skill in itself.

And the last advice, would be to implement some kind of meditative practice, and walk long distances while you listen to Andrew Huberman podcast.


Good call! Better tools make a job easier. Improve your work environment.

Look at your IDE, desktop, editor, OS, monitor, chair, etc. and see how you could improve it with new options. Tech or otherwise...

Is your desk a space of zen? Got a plant on your desk?


I often notice that people rarely remember properly the capabilities of themselves 5 years ago, much less 20. We often think we were better or worse than we actually were. Sometimes I think, oh boy am I rusty today, then I look at my old stuff and realize that I'm so far beyond that it's sad.

To me, it sounds like you are placing too high an expectation on your own cognitive ability, and not spending enough time sleeping. Any project that requires someone to do 4D chess in their heads to complete it is too complicated and no one will be able to maintain it. Start writing stuff down and making diagrams until the design is easier to understand. You are trying to build a city in your head without creating a plan.

Even a back of the napkin drawing can be enough really. Sometimes flaws become obvious when we do this. The value of older developers is they have the patience to do stuff like this, while all the young'uns go winging off on wild projects that they have to re-write in a month.


40 has nothing to do with it. Every other day I see a Ask HN post from younger people bringing up depression, burnout, and apathy.

Listen, there are 60 year olds that look like our long held image of a 60 year that can barely walk or do anything.

And then there are 60 year olds that go to the gym everyday.

How do you want to play this? I don’t accept your premise that 40 has anything to do with it.

Being a miserable fuck is age-agnostic. Trust me, I’m a professional malcontent.


There's a lot of biology in the mix here to that must not be dismissed.

But I like your take. Do everything reasonable to continue forward and maintain your body and mind.

Just don't completly ignore your genetics and biology and be open that they might speak-up and have a say too.


I’m a “biological optimist” and think a lot of what we consider “bad” can be and often is at least somewhat adaptive. Even things like aging and death; there are ways to age and die adaptively to give room to the next generation, to allow societal renewal/avoid sclerosis, etc. My understanding is that aging is thought to be in part an evolutionary adaptation against cancer, and a kind of pattern of creative destruction we see all over the place in both nature and society. There are also maladaptive tragic ways to age without remembering/learning how to live in your context, and maladaptive things like premature aging, disease, etc.

All adaptation is contextual. This picture is probably familiar to a lot of people, and is a perfect illustration of what I’m talking about: https://www.boredpanda.com/athlete-body-types-comparison-how...

There is no universal “better”. At any age, in any environment, in any physical condition, there are contextually appropriate optimums, and always two categories of direction: 1) using whatever tools are at your disposal to adapt as much as you can while accepting (and testing) limitations 2) ignoring what tools you do and don’t have and either giving up or trying to get the world to adapt to you.

The first direction is always better.


I mean we have good evidence that athleticism at the competitive level has a drop off at a certain age, and even that is mostly only a factor at elite levels. There’s nothing stopping you from being a great basketball player in casual terms at any age.

But cognition constantly being under ageist assault has little to no basis when you consider so many knowledge driven professions employ people well past middle age (academia, doctor, lawyers, scientists, writers, artists). They also do their best work much later in life.


> Just don't completly ignore your genetics and biology and be open that they might speak-up and have a say too.

They may have a say, but ultimately you can only try to deal with the cards you’ve been dealt. At least I wouldn’t just accept that I’m genetically predisposed to misery with no way out.


Just be mindful that the flip side of this perspective is to blame sick people for their condition.


The optimum middle is to try to figure out the most achievable pathway to help people to as much health as possible regardless of where they’re at, while accepting where they’re at, and encouraging persistence in searching for achievable steps out of sickness if none are available.

There’s an incredibly sad but inspiring documentary called “The Boy Whose Skin Fell Off” about a man named John Kennedy that died of a genetic skin condition called EB at 36. He did everything within his power to make the most of his life, and was brilliantly dedicated to squeezing as much meaning and good as possible out of his horrible situation.

Failure to attempt moving away from and transcending sickness is itself possibly the worst form of sickness, and something that can be easily cured by just having someone genuinely loyal and rooting for you, even if only your inner self. What sick people need most, more than simple compassion and accommodations for their problems, are people genuinely rooting for health/trying to find solutions or grieving the difficulty in finding any.


Ah, yeah, that would suck. I guess it’s really only something you should apply to your own condition, never someone elses.


Do you have a family? I find that with a family + a young kid, a lot of my mental capacity/ability to focus for longer periods has diminished.

Maybe you can pair with one of the other developers? If they are junior, they could benefit from your experience and insight and you could benefit from their focus and ability to navigate the massive codebase.

Other things you can try (work for me): getting comfy in a small and cozy room, turning the lights off or putting in noise cancelling headphones. Move the phone away and turn off any notifications. Better yet, have a dedicated machine for coding with no logged in accounts.

Ome last thing, you may have undiagnosed ADHD. Mine became progressively worse in early 30s. Self medicating through caffeine no longer worked for me. The doses that were effective were making me severely anxious and sometimes nauseous. ADHD meds have removed the negative side effects of caffeine and helped me feel a little more normal.

Sorry about the long comment: there’s a lot I can share from my perspective, but I don’t know if any of it helps. Feel free to comment back if you’re interested in touching base.


Here is a concrete thing to try. Maybe it won't be useful, but it's helped me in the past.

Get a blank sheet of paper and a writing utensil. Not a text editor.

Start at the top of your call stack and start making a diagram that resembles a directory tree:

    application_code_function(string arg)
      library_function()
        std_lib_func()
Use arrows, add notes on the side. Whatever helps. Try to get one API call stack.

I don't do this often, but it helps especially when I'm not familiar with the patterns used in the project, or I'm having a groggy day and having trouble thinking "deep". It seems to help to me to try and reason about it away from the distractions of the IDE and the OS.


I came here to say essentially the same thing. It seems like this helps students learn programming, and, in some sense, we're all students of whatever new piece of code we're working with today. Some teachers have worked out a fairly comprehensive diagramming scheme for code [0], if you want to take it that far.

[0] "Memory Diagrams: A Consistent Approach Across Concepts and Languages", Toby Dragon and Paul E. Dickson


At around 40 my interest in actually writing code declined sharply. That was after doing it for 30 years, and after it hadn’t really been challenging for quite some time. At the same time, my interest in the “big picture” increased at least as much.

I found that I was much more interested in how the work impacted customers, how we could work more effectively as a team, building relationships across the company I am at, etc.

At 48 I switched from programming to managing. It was a good move for me. I don’t love managing the way I once loved programming, but I periodically reassess and realize that although it’s fun to take a day and write some code here and there, I would be pretty miserable if I were to go back to it full time. I would constantly have to find ways to motivate myself to get anything done.

I do still take those days sometimes and write code for our product, but keep myself off the critical path at all times.

Management may or may not be for you, but it’s something you may want to consider. I wish I had moved over sooner.

As an aside, I had read in my twenties about a theory that claimed something happens physically in our brains as we age that explains this phenomenon of greater interest in the big picture and less interest in detail-oriented work but I have never gone back and tried to confirm or learn more about that theory.


Same boat but for different reasons. I'm 40 and have a 2.25 yr kid. I was doing fine before the kid was born but my mental capacity deteriorated a lot since then. It's a combination of depression, loss of sleep and increased pressure from work.

That said, I still managed to pull out a few nights of programming (the Synacor Challenge) and debugging, occasionally till 2AM while I barely get much sleep because we are trying to ditch the pacifier.

I have a feeling that humans can still burn extra mental energy when really driven, to certain limit. But in 40s we are driven by far fewer things than in 20s, and we need more rest for these burns. The up side is I know ourselves better now than in our 20s so I can at least achieve something. Back when I was in my 20s I spent most of the time playing games and failed to learn anything properly.


I am 50, (been programming since I was 12) and I know the feeling, I used to get like a brain fog but have found some solutions that helped me to get rid of that feeling most days. What worked for me:

D-Vitamin supplements, ZMA (Zinc, Magnesium), Enough sleep, No coffeein after 3-4, lifting weights and endurance training (crossfit), eat whole food which you prepare yourself with focus on proteins and fats from animals.


I am about 15 years older than you and I understand the worry. Things do take a little but longer to sink in and a little bit longer to hold in your head (I need to be a little more intentional about remembering and I love having a notebook or random piece of paper nearby to scribble in).

But I think the biggest difference comes when I care about something or not. The other day I was reading through the material for the Full ham radio license in the UK because it's about bloody time I got the Full one rather than the lower level. And because I was interested I easily recalled the next day that the impedance of coax used by hams is typically 50 ohm, television feeds typically uses 75 ohm and ladder line is 450 ohm.

If you're doing something that doesn't interest you don't be surprised that your brain isn't interested either! Also, if you have a life then tiredness, worries, stress, etc. all kill your coding vibe.


Your brain is constantly trying to make itself more powerful and better oriented in your environment. It does this by seeking new and stimulating information, information that adds to your understanding of the world. As you get older, your work becomes a less and less rich source of novelty and stimulation. That means your brain doesn't engage automatically the way it used to. It refuses to allocate cycles to the problem. It reduces the mental resources you're working with to a trickle.

Like you, I'm faced with a couple of APIs that I have to understand. In my case, they are third-party SAAS APIs that I need to evaluate as integration targets for a product I work on.

The odds are very low that I'm going to learn anything of lasting technical value from these APIs. Two years from now, I will probably have to wrack my brain to remember if I ever worked with them directly or just heard about them second-hand.

The same is true of most of the programming I do, especially if I do it well. The alternative is to become one of those toxic senior developers who feel entitled to novelty at work and find ways to make simple problems technically stimulating for themselves, and simultaneously unapproachable for many of their teammates.

How do you stay engaged? You have to remember that you can always solve these problems better than you ever have before. Your solution can be more transparent, cheaper to operate, approachable for new devs, easier to hack on without breaking it, better-documented. You can challenge yourself to finish it quickly or to involve junior devs in its development in a way that is constructive to their growth.

If you don't care about making your solution better in those ways, if you only care about solving little puzzles in code, then you will get bored, because you will look at new projects and know that you can solve all the little puzzles in them, and you won't learn anything fundamentally new in the process.


This sounds like terribly boring developer work to do and requires no creativity at all. Is that what's missing when comparing to other types of developer work that might keep you more engaged and focused? I'm not suggesting to push back about why it needs porting, I assume that bridge has been crossed already.

The other thought is that maybe it was poorly written, having multiple layers of abstraction, etc. that are unnecessary? Most API's are CRUD operations on data or calling deeper internal things, like payment processing, in which case you are calling other API's essentially.

I would suggest writing external tests that hit the existing API and in small chunks port features over and incrementally get those tests to pass calling NewAPI. Internal/unit test coverage can help to ensure each module or logical grouping is working the same as the prior work too.


I would second this - as I've got older, my capacity to do boring things has decreased.

Younger me didn't find coding boring - I was still learning things.

Older me, has done a lot of things multiple times. I'm often not learning anything (or, I don't believe I'm going to learn anything).

To be honest, things like Copilot have really helped with this - auto generating boiler plate code removes a lot of the tedium.


I've hit the same walls as you have described and found that it's less about cognitive function and more about a combination of burnout, imposter syndrome, and some quirks of my ADHD. I still love to program but when I get the chance to I largely can't organize my thoughts well enough to make much progress, but its because I left a job about 7 months ago where I had been repeatedly hitting burnout in a really nasty several-year long cycle. Now when I sit down to do it I have a thousand things in my brain and I can't stay focused on it. I switched to managing individuals as well over the last few years since I have some natural giftings there but it's made it so that my skills at just zoning in and coding for hours is effectively atrophied since I am so interrupt-driven as a manager (constant emails/IMs and being mindful of my team who I should be supporting rather than my own personal technical goals)..

I've found I need to stop comparing myself to my late twenties self and understand that my burdens are different and I need to set different expectations of myself. As my responsibilities and noise/interference have grown, my ability to do complex design/development has been inversely effected and waned significantly and _that's ok_. I need better tools and to be better at managing my time and energies to be more targeted/specific and I am much more effective than I was all those years ago. I just have to be more intentional and forgiving of myself.


It took me 2-3 years to fully heal from my burnout. Allow yourself more time if it's only 7 months since you quit your burnout-inducing job. The improvement of my energy, my mental abilities and memory is breathtaking, mentally I feel like 18 again (though I am 35 now).


When you were 25 you lacked the experience to see Porting this API will require a deep understanding of the existing API and, ignoring that obvious complexity, allowed you to move really fast.

Also you get those nagging feelings of futility about doing a mechanical task (translating an API) when you know you (or anything else) will 1) make mistakes and 2) have to do it again in five years anyway.

There are two times you buy a motorcycle - First when you know you can't die and Second when you don't care if you do. Sucks to be in the middle (aged).


I just have to reply to this to tell you this comment changed my perspective on my own perceived productivity in exactly this context, thank you.


1. You're getting old. Start writing everything down on paper.

2. Some people decline mentally faster then others, sometimes in their 40-50. Don't freak out, but do pay attention, ask others you know to pay attention to you.

3. Take it one layer at a time, and again, write everything down, best on paper.

And keep smiling when it is hard.


Was just going to write this but with a minor modification. It might not be getting old part but rather the boring nature of a mundane task, anyway writing things on pen and paper is best and works wonders to help iteratively understand problem and build a solution.


I am closer to 50 and didn’t notice much decline yet, however to pre-empt it, I started journaling. I write down what I did per day, tech solutions, how I got to them, links to git repos, what I cooked with ingredients etc. It is fun to be able to say what I cooked Tuesday 3 September if someone asks ‘that Thai dish you made somewhere in December’ or ‘how did you fix that weird nodejs issue’? And it is inspiration for blog posts, tweets etc.

For me it works wonders. Wish I started it when I was 17.


WTF, AM I ALREADY DEAD AT 42?


:)

No, but we mortals age our brain ability does tend to decline.


Bear in mind that the world has been really ratcheting up the "everything's fucked" factor for the last several years. This might not be "I'm 40", it might be "I'm dealing with living in the current state of the world."


You're up in your own head, and are sensitizing yourself to frustrations you would have brushed off in your (heh) youth. The cortisol isn't helping either. It's also possible that you're just burnt out.

You're going to have stretches where you look back and feel like you're doing the best work of your career, and stretches where you worry that you're done for. It's all normal.

If this project isn't clicking with you, but you have to do it anyways, use this as an opportunity to build some "compensatory" habits. A similar situation (I'm older than you, but this happened in my late 30s) got me big-time into note taking, which has been a long-term win.


43 year old software engineer here.

- If you drink, curtail it. - Diet is everything. - Get more sleep. - Get quality exercise. - Find another hobby that is interesting but relaxing, but don't try to turn it into a side hustle. (I restore old guitars)


Doubtful you are declining mentally but should speak to your doctor if concerned. For me at 43 I noticed that my ability to focus has declined. I have so many things competing for my attention that I can't focus on anything. Essentially context switching is killing my ability to get things done. Too many people at work constantly pinging me. Im in a strange position at work where so many random projects are dumped on me, usually all of them are handed to me behind schedule. I have a report I have to generate each week that takes a full day to create. I have a team of contract developers I lead that are just not very good. All day long I get pinged on email, teams, and slack. I start the day with ~15 emails from offshore teams. Constant meetings. Plus my kids get home at 2 from school. Context switching has completely burned me out. I feel guilty ignoring my family and working late but I think I am really going to have to work until at least 7 several times a week just to stay ahead. That or start working from 5am to 6:30am to get a jump on work before my kids get up.


Burnout happens when you're forced to work without motivation. For me (same age as you), two kids and a "life" often soak up most of the motivation. I look at challenging problems in a different way: time travel. When I get fully absorbed into a tech/coding challenge I find that the entire day will slip away. For me, this used to be fun and now it's frightening because I know that a challenge will eat days of my life. For what upside? We already live comfortably. So maybe there's a part of you that doesn't want to go too deep because it's feeling like a waste of precious time.

My recommendation? Focus on tooling. See if you can create a better test infrastructure, a better developer experience for the others. Do you see another way the code can be organized to make it easier to reason about? Is documentation/code-comments lacking? Perhaps your time can be leveraged to help the others. Maybe that perspective shift can unlock your super-powers.


Motivation comes and goes and is unreliable, it's better to be self disciplined and well organized.


> I don't know if this task is just an especially bad fit for me, or if my mental abilities are declining?

There could be so many possibilities I'd explore before cognitive decline (at 40??)

1. You are not communicating well enough with team lead / members to get ahead on the task. Maybe they have good advice/feedback that you're not getting because communication is off.

2. You are a bit burned out

3. You ran into some difficulty with this hard task and drove yourself into a state of panic. This panic can feed onto itself and prohibit you from making any progress in a reinforcing loop. Now you're in such anxiety you can barely focus on anything.

4. You're not attacking the problem right. Maybe you can use debug messages, or a debugger, or write diagrams, or a small POC, whatever it is you're doing now maybe you can make some adjustment on how you're trying to solve it.

5. You're not taking care of the basics - sleep, nutrition, exercise. This will basically harm you in countless ways, don't do this.


I'm a little bit older than you and have been in the industry for almost 30 years. I have a different perspective than mental decline. I think it's that after seeing code and patterns for so long, you might be defaulting to generalization of ideas. I know that I do that.

For example, one of the best developers on my team (a little bit older than me) is "on the spectrum". We've worked together for nearly 20 years, starting at about the same time. Early in our career, we would dig into the details of APIs and patterns and be able to rattle off the details of the changes when a new dot release of an library came out.

As the years have gone on, I've "lost interest" in the details knowing that I can look them up when I need to and have naturally defaulted to generalizing ideas. That is, rather than knowing that we need to change the third parameter in the function call in FOOBAR 3.2 when we upgrade from FOOBAR 2.9 because the details of the memory management changed, I just know that we use the FOOBAR function because it does a specific task that we need.

The reason I bring up my friend/coworker is that he never generalizes, he gets stuck in the details. He can't design his way out of a paper bag, but he can write thousands of lines of code over the weekend with full unit tests and there's never any bugs. So we make a great team, he's one that has focused and has every detail at the tip of his tongue. But he never sees the big picture.

So I view getting older in software as (over) training AI. My brain works in the generalization route and the more I see, the more connections I make, but I need to "make room" in my brain by not encoding the details. My friend's brain works differently. He encodes details and can keep a deep call stack but at the expense of ever being able to see the big picture.

I guess that's a long way of saying that maybe you shouldn't be so quick to think it's cognitive decline. It could be just that your brain is encoding things differently after seeing so many examples in your career.

I know I'd fail miserably at porting an API now (I've done that when I was younger very efficiently). But I also know that I can bring a much higher level of design and ideas to the team than I could have 20 years ago.


Interesting perspective, thank you.

Code is the author's though processes made concrete (in a sense), and some people just think differently, some people are just incompatible. Over the years I've seen some codebases considered good that are easy to follow and I like them, and other codebases considered good that just seem to grind my mental gears even though I can't put my finger on any specific problems with the code.


I'm also turning 40 this year! You may want to look up crystallized intelligence (wisdom) vs. fluid intelligence ("raw" power) (https://psychcentral.com/lib/what-is-emotional-intelligence-...) and let those concepts process for a bit. We tend to move towards crystallized intelligence as we age, which has many advantages that folks are alluding to here. The key could be to recognize the difference and where your current strengths lie without wishing for the past (probably fictionalized) you. You are who you are now, not what you were. Be mindful and appreciate the experience and strengths you have now that you didn't as a younger person. You might try to organize your work, and maybe eventually change your job/position/title, so that your current strengths are aligned with the expectations. In other words, you don't have to keep trying to be a great programmer, but you might become a great mentor, manager, author, oyster diver, etc. It's the reason many move from engineer to manager or musician to producer. You can actually be much more effective and valuable if your experience can help inform many people's code rather than just your own. You may also want to think about how great it could be not to even try being the "best" programmer. What a relief! Now you can focus on what you care about in your field and perhaps turn your focus outward towards helping other people instead of simply building your own resume.

Good luck and get the sleep you need.


I started to notice somewhat similar earlier in my life, around being 37 years old. I am 51 years old now.

I have an advice: walk daily as much as you can, but no more than two hours, ruminating what is bothering and/or factinates you in your work. Thinking around the exercise time can be very helpful. And walking allows you to think while doing some exercise, which is even more benefitial.

More than two hours of walking may result in more than 12 km of walk, which can be taxing. 5-6 km of walk is OK.

Personally, I also do resistance training and intermittent fasting, but my primary tool is walking and was for a long time.

Right now I am closing the bug that was introduced more than 10 years ago into the system I work with. I have more than four thousands of lines in changeset in more than four hundreds of files, in two unrelated repositories. So I think I am not all that bad at figuring things out.

PS And sleep well! ;)


38 here, I've definitely noticed a bit of a decline in overall power a year ago.

Have you looked into what you're eating and doing for exercise? You definitely cant power through brainfog with caffeine anymore.

try the following to get yourself back on track 1. first meal of the day should be a filet of fatty fish like salmon with skin. if you can't afford this, use a high quality fish oil pill like nordic naturals. keep it refrigerated. omega3 fatty acids are prone to oxidation at roon temperature and there are no official stadards for it in america)

2. limit carbs to whole foods like sweet potatoes, yucca, potatos

3. cut out all sugar outside of whole unprocessed fruit. (juice doesn't count)

4. have a side of greens with each meal

5. start lifting weights, (triggers release of HGH)

6. choose one day per week to do a 24 hour fast.

after 2 weeks, you'll start to feel your brain come back


> first meal of the day should be a filet of fatty fish like salmon with skin.

Kippers!

I don't know if they ever had them in the USA. They seem to be seriously out of fashion in the UK; in the seventies, supermarkets used to sell them in plastic sachets, but nowadays it seems the only way to get them is online (or maybe you live in a town with a real fishmongers).

I don't generally like fish, but I'd eat kippers if I could get them.


> 3. cut out all sugar outside of whole unprocessed fruit. (juice doesn't count)

Juice might as well be soda when it comes to sugar.


I agree,

in retrospect i realize that paren could be read two ways. to be clear, I want to iterate that juice doesn't count as an unprocessed fruit.

Avoid juice like the plague!


Nah, I think your expectations are wrong.

No matter how good you are, nobody is good enough to port an API like you are saying it, by memorising or thinking 9 levels deep. Humans aren't designed for this kind of tasks.

Instead, you should take steps to understand the parts that compromise the abstractions that make up that API and implement it.

Also have good test coverage from both sides, so you make sure you are implemented something that resembles more like a spec.


There's a lot of good, generic advice in this thread, but this is I think the right answer. I specifically scanned for one like this.

What OP is trying to do is quite literally impossible. Not even the best chess players in the world can hold such a big (decision) tree in their heads _at once_. And they might be the most extreme data point we have on this matter.

The way we humans compute needs to be supported by breaking stuff apart and focus on few things at a time on one side, and by abstraction on the other side. Iterating on smaller problems and generalizing the big picture along the way.

Think forest & trees metaphor, or the 7 +/- 2 problem.

Of course as we get older our ability to completely emerge into one task and put all our energy into it generally weakens for a variety of reasons. But there's enough evidence to support the idea that regularly challenging our cognitive ability keeps us sharp and maintains or improves our ability to learn and tackle new things.

What we can't do however is fight our natural limitations and OP seems to try just that.

Additionally, and this might be just as important, this seems to be a very tedious and boring task. The worst tasks are the ones that require a lot of mental effort while also being incredibly boring. It's hard to find a high state of motivation and focus, which contributes to the issue.


I second that. Without taking notes/diagramming no mere mortal can handle nested 9 levels just in the brain. And somehow I doubt that the OP colleagues are doing just that either. The diff between people being stuck and progressing is often how much and how smart they writings things down.

My suggestion would be to try to tackle the low hanging fruits first: find the parts of the lowest complexity, try to understand these and get the simplest things done first. This will also restore your confidence.


I don't know much about your physical state. So, let me just put out some generic advice.

1. Enough quality sleep. 2. Exercises that involves your legs. Somehow leg muscles help the heart to pump the blood back up, keep enough pressure and circulation in your brain.

I'm 35 and I've already experienced the benefit of those 2 and the negative impact of lack of those 2.

Maybe you could be just rusty about that kind of code?


Was going to post this. I become a foggy-headed moron when I don't do these things, and I'm plenty sharp when I do.

My area is blessed with parks and cool places to go for a walk, I hope you and OP have something similar.


I would add that, if both sleep and exercise don’t seem to solve it, then sleep quality (e.g., sleep apnea) could be an issue, especially if a person is overweight or has other health issues (e.g., bad allergies).


If you are worried about cognitive decline, I recommend starting weight training. I have found after weight training for under a year now my memory and mental capacity has increased. It’s likely that any consistent physical training will have the same effect. Not sure how active you are. This wouldn’t be a quick fix though.


I highly recommend lap swimming as a general physical/mental sharpening exercise you can do with virtually zero joint or other injury risk your whole life.

I had the good fortune of being coached for a brief period by this guy: https://magazine.wsu.edu/2009/08/11/channel-swimmer/ Having that kind of an example was awesome.

The downside of swimming is trekking out to a pool and finding a time when lap swim lanes are open, and climbing the learning barrier if you’re completely new. In my experience, a lot swimmers also tend to be instinctually quiet, standoffish and very competitive, which can be very intimidating if you’re going for a lap swim as a newbie. Especially if it’s crowded and someone wants to lane share.

But there’s almost always a time slot somewhere when it’s virtually empty, or a friendly lane sharing buddy who’s relatively new/not doing flip turns and stuff, or a friendly expert who’s casual and happy to give learners a wide berth. A local YMCA or one in a neighboring area is usually the most friendly place to start swimming, but I think a decent number of big commercial gyms have pools too, and universities/schools sometimes have public lap swim times as well. And if you’re completely new/never learned to swim, lesson instructors often LOVE private adult lessons because they actually listen/you don’t have to additionally do baby sitting/kid wrangling. I lifeguarded for a bit and taught swimming, and liked teaching kids too, but adults were so much more relaxing.

It’s absolutely worth climbing those barriers. Especially if you get one of these: https://www.underwateraudio.com/products/waterproof-ipod-shu...

I haven’t really checked the landscape post covid, though. I’m guessing a lot of places with pools got hit really hard. All the more reason to get out and find/support one, they’re a really awesome community resource.

Speaking of which, I’ve turned into a stressed out couch potato/haven’t been to a pool since covid, I should take my own advice and get back out there.


I would take a moment to consider what kind of "progress" the other developers are actually having. Deep layers in api calls indicate to me that the original author was either 1. too "clever" or 2. not good at their job. The number of programmers who do way, way too much vastly outnumber the number of programmers who get the job done correctly and succinctly in my experience.

Give yourself some breathing room and try to move the code towards something simpler. Find some business logic level mental hooks upon which you can take bites out of the existing implementation.


Are you serious by trying to call person who wrote that as good or bad just by that short description?

Thats crazy, context matters.

Sometimes software does complex stuff and no, you cannot infinitely simplify and abstract stuff. Complexity needs to be somewhere


complexity can be closer to the top level IMO. I saw codebases where functions are called inside functions for no reason other than it grew organically. Of course, it is not enough information to know it, but it might as well be.


I noticed a stronger urge to not waste my time by reading bullshit. It got much worse now that I am closer to 40.

For pure coding, I am writing simple functions and precise data types only, and actively avoid all the clever abstractions I used to push for in the past. I won’t argue about any styling or naming conventions - configure an on-save linter and done.

And for APIs I‘ll look exclusively at the given spec/schema/whatever - and only grep through legacy implementation code if I suspect edgecase handling there.

It’s not being unable, more like extremely unwilling to immerse in just another messy code pile.


It's hard to give an answer without knowing other variables - namely, what else is happening in your life.

I can relate to this sentiment over the past few years. The other variables, for me, are that the demands of raising a young family have grown, my day job has shifted into more of a maintenance mode with less latitude for creative development, and my family has recently suffered a tragic loss. During this time, I've been astounded how much more difficult it has seemed to accomplish fairly straightforward tasks compared to just three years ago. So I've also wondered if my mental ability has been on the decline.

Yet, this past year I've had two new interests spring up - one possibly a new career path, the other an avocation - and despite having precious little time to devote to them, I have been finding that I'm learning at a rate that I might never have achieved before - even in my 20s. I've somehow found myself with a "beginner mind" again, and at times I feel like I'm on fire. And I'm in my mid 40s. I can't explain where any of it came from (one path quite literally took off after reading a post on HN!) - it all seems spontaneous.

My little piece of advice is to be aware of these kind of nagging thoughts that take hold in your mind. Ask yourself if they are provably true and, whether true or not, they could cause harm. You never know what's around the corner, so it may behoove you to stay open and keep these nagging thoughts out of the way!


I would doubt the code first. If it is built on layers of indirection that's a sign there's an abstraction that's not being made which could simplify that code. We write code first, and foremost, for other humans to understand. If it's too hard to understand due to all the indirection that's a problem with the way the code is written, not you!

A big difference I find between myself as an engineer now (40s) vs myself in my 20s is that I have the education, experience, and wisdom to appreciate elegance and simplicity. When I was younger I would throw myself at a problem and keep adding code until the program did what I wanted. I could only imagine what people meant by "elegance," and "simplicity." These days I rely more on mathematical reasoning and think about the problem before I start writing code. I feel as though I can finally see that simplicity is not effortless.

Barring very specific health complications, cognitive decline is not a major factor for most people in their 40s.

Most programmers are fooling themselves if they think they can keep the state of more than a handful of variables in their head and detect errors or understand the entire control flow. That's a code smell, a problem, something that should be addressed. After all: if you can't understand the code, and the next person has difficulty as well -- if you need to make a change to it, how do you know that the change you've made is correct? Do you know that this code does what it's supposed to?


For me (late 50s), I find that I don't feel productive as I use to be and can think of several reasons

* the project I'm on is not "mine". I joined a sub team of ~30 programmers who've been working on a 5 year project. I'm not familiar with the code. this in contrast to previous projects where I was a lead / main contributor. I wrote the initial implementation so I had a very clear view of the structure of the project in my head.

* the project I'm on is not a passion project. I got very luck that most of my career I got to work on things I wanted to work on so I had passion to make them great. my current project I don't feel that. I'm sure part of it is coming in late. I think it's great project but my heart isn't in it the same way it was for many past projects.

As a counter example, I got permission to prototype something on my own for a few weeks. I worked ~80 hours of over time those few weeks because I was so into it and I felt super productive because it was 100% my code that I understood, no waiting for code reviews etc... I appreciate code reviews but compared to prototyping without the feeling a productivity without is incomparable.

* my passion for coding seems to have dwindled. maybe this isn't true given the previous paragraph but coding things I used to spend time exploring I have a hard time working up enthusiasm for like I used to.


I'm not sure it's age related, sure, we might slow down slightly over time, but what we lose in speed... we gain in wisdom, soft-skills, experience in general. Which I suspect more than makes up for a slightly decline in sheer speed cognition wise.

I can't help but think of Donald Knuth, aged 85, sat in his home office somewhere, still chipping away at some of the hardest problems in computer science.

It sounds like your problem is something more temporal. For instance, someone else here mentioned about other stresses and responsibilities in your life for example. It might be that it's just a boring and arduous task, not everyone excels at tasks that are just not that interesting. Besides, I don't think the vast majority of us are good at remembering layers and layers of calls and abstractions.

My advice is, there's probably nothing wrong with your abilities or your brain, just try to work on small sections at a time and don't be hard on yourself. We're not 100% all of the time, there are so many factors that play a part in how we perform on each task.

I'd also say that, 40 isn't particularly old, it's easy to think that when so many engineers are in their mid-20's, but in the grand scheme of things, your cognitive abilities probably haven't changed all that much since you were twenty-something. Hang in there mate.


I just started being a professional developer in my forties, and all I can think of is that I wasn't this competent ever before. I slap my noise cancelling headphones, put some piano music and enjoy the process.

But I'm not perfect. I'll miss a detail, I'll get a message in the chatroom, I'll take a stretch break. I'll forget. That's not just me being 40, that's me being human.

There's also the fact that when you're younger your body lets you get away with "murder": Drink lots of coca cola, eat junk food, sit for hours, never hit the gym. An apt metaphor would be that you had a 10k PC for gaming and lots of games that were not optimized properly but run well enough due to the hardware being that good.

The older you get, the more your bad habits bite you. So it's not just age decline but every lack of maintenance and abuse of drinking, smoking, junk food comes to take its toll. You know, the "I can do that while I am young" kind of habits.

What I'm saying is, it's more than aging that it's at fault. We just like to correlate aging with it because it takes years for the side-effects of all the poor habits to manifest themselves to take effect.


You've received so much feedback, so I imagine my comment will be lost in the weeds, but I'll say it anyway.

I want to work with programmers like you. I really do. I don't want colleagues that can dive through stacks untangling complicated messes effortlessly. I want colleagues that are sensitive to every cognitively burdensome aspect of the codebase and _need_ to fix it to continue working. These are programmers that will be methodical and wholesome in their approach, and will deliver code that is easy to work with. I'll choose a programmer like you over a young-gun-star-code-cowboy every day of the week.

That said, if I were you I'd ask myself if the problems I'm having are inherent in the problem I'm solving, or in the approach I'm taking. I'm somewhat younger than you, but I have horrible working memory (sounds similar to what you're describing), and my self-development as a programmer has been mostly centered around finding ways to make that irrelevant.

Also, you might be interested in the Huberman Lab podcast. He's a neuroscientist and has episodes about ways to improve things focus and creativity.


There are a lot of factors that change with age. For example, I developed an allergy to gluten a few years ago. Took 2 years to figure out why I was brain foggy and tired (and diarrhea) all the time. What do you know, my favorite food became poison!

When I cut glutenous foods from my diet, mental clarity was restored.

NOT saying "gluten-free" is the correct answer. Just saying there could be underlying issues with a symptom of brain fog.


Could it be just fatigue? Do you sleep well?

My wife got diagnosed at 42 with sleep apnea, with no prevalent cause (she's not overweight, does not smoke, etc). Turns out it's just her brain that sends the wrong signals to her breathing when she sleeps. It was life changing. She always felt tired and felt like she could not do her job properly. She got a CPAP machine and now she's feeling better than ever.


It probably has less to do with your age and more with where you are in your journey and how you are seeing things. Increasing domain mastery can also mean less tolerance for BS.

Slightly tangential, and perhaps abstract, but nevertheless applicable - two counterintuitive ideas that might be helpful:

1. Keats' notion of Negative Capability. We always think of abilities in the positive but often beyond a certain point dealing with the uncertainties is an ability in itself. More at https://www.leadingsapiens.com/developing-negative-capabilit...

2. Maslow's idea of Second Naïveté. Domain mastery can easily turn into increasing cynicism. Have to be on the alert for this. The masters are somehow able to reengage as beginners and push past what others find mundane. More at https://www.leadingsapiens.com/naivete-in-leadership/


42 here, I feel it. Don't know if it's age, added responsibilities, or the culmination of all the distraction and task switching I've experienced for years. But, I've just recently started 'brain training' using brainhq.com, kind of for fun and just to see if it makes a difference.

TBH I thought all those ads for brain training were a load of BS, but I recently finished reading The Brain that Changes Itself by Norman Doidge, it's an older-ish book at this point but there was a lot of info in there about how the brain works that I didn't know. Neuroscientist Michael Merzenich's https://en.wikipedia.org/wiki/Michael_Merzenich work pioneering brain plasticity with cochlear implants and expanding that research into autism is highlighted at the beginning of the book and it's pretty damn interesting.

BrainHQ was started by Merzenich, and it's cheap. Figured why not give it a shot?


I have been reading a book that was recommended to me, "From Strength to Strength": and while it is cheesy as fuck, the theory it presents is interesting and has made me think a lot about what has been driving my identity for the past 20 years, and how to pivot from an "addiction" to problem solving into the latter years of life, where you will more frequently be asked to rely on strategizing and helping others to succeed rather than performing the individual contributor tasks that you relied on for a feeling of fulfillment up to this point.

Maybe this will help you too, but I would recommend skipping the intro chapter if you do decide to read it. I almost put it down because the example being given in that chapter was so obviously fake and contrived. But ultimately I am glad that I continued reading it and would recommend it to someone in your situation.


People mentioned already how the overload, responsibilities and distractions that only multiply with age make it difficult to allocate sufficient energy and focus to get a strenuous mental task done. This is much easier when younger. I recall spending long stretches of time reading e.g., a book front-to-back. I don't think the reason I am not doing this anymore is due to declining mental ability. During the pandemic on occasion this has happened again :-)

One simple trick that works for me sometimes is to create a "clean room" for the brain: e.g. change work environment and/or isolate for a fixed period pushing all other deadlines further out. Remove the external pressure and allow time to get into flow.

Ofcourse it might be that what you have to do is materially more difficult than previous tasks you handled. Using mental support tools (notes, diagrams etc) might bring it back within reach.


It's not decline, it's just a tedious task.

You're having trouble finding the motivation to deeply understand the original API.

So, cheat your brain with busy work:

- find typical use cases (hopefully the original was written around use cases)

- use it in the original language, write toy programs

- look for concepts and symmetry (i.e. open/close, add/remove, handles, whatever) that reduce the cognitive load

- mock a rough translation in the target language (it's not final code, hacky works)

- slowly port your toys

- watch for gaps... wash, rinse, repeat.

In the meantime, sometimes finding something mechanical to pursue that moves the job forward may help.

For example, mocking all API calls in the target language, following the original structure. TDD? Build a tool to make the target API shims?

It takes time to absorb something that's not calling you, but you can get there.


One thing I would recommend is that you also focus on your physical health.

At age 40, there are a lot of responsibilities, and taking care of yourself and your health can get pushed to the side.

Take time to eat healthy and get exercise. It is amazing how much a healthy, fit body invigorates the mind.


Seconded, and I'll add a regular sleep schedule to the list.


Not sure if OP is a male or not but if you are get your testosterone levels checked and if they are low, fix them. I was going through the same thing at the same age. Your milage my vary but that was a complete game changer for all aspects of my life.


I would also suggest getting tested for vitamin B12 levels. I began taking B12 injections to compensate for a very low level and it has been a night and day improvement in my energy levels and ability to focus.


I recently turned 50 and am finding the same (to the point that I might want to step "down" to something a little less intellectually-intense like sysadmin) but in my case it's the fact that 18 month old toddler sons are pretty much life-absorbers.

Yesterday I realized that a hard-ish problem in my tiny shell script testing library https://github.com/pmarreck/tinytestlib which I had worked on for over a day was completely moot, and ripped it out while facepalming.

Incidentally, I'm looking for work as... well, the above things, although previously I was a solo Elixir dev.


Sounds hard, man! Poor you :( General tips: exercise, lots of water, meditation/pranayama, emotional processing/therapy if you have unresolved trauma, sleep, cut coffee and alcohol, cut processed foods/snakcs, more vegetables. Maybe try some nootropics? Nootropics are a highly-opinionated / personal / subjective topic but there's plenty of different options. Worth exploring as temporary rewiring enhancement while you get your personal health routine up to sustain your abilities. Also if you can and want to maybe take a break / sabbatical from work and just see where it takes you. What do you want to do?


I felt the same when was infected from Covid. That remained for 6 months, and then gradually went away.

At the downtime I felt like +20 or 30 years older and gone retarded. Can't do any more hard brain work, and felt like I can't do that ever.

But this will pass.


The cause of this could be many things, but one thing is for sure: worrying about it only makes it worse.

My advice would be to visit your doctor, asks for a general round of blood tests to check everything is okay, B12, liver function, cholesterol, kidneys, etc. Do the lot. If they show something isn't normal then you can focus on dealing with it, but just as importantly, if the results don't show anything you can rule out your physical health as the problem and focus on other potential causes.

I'd place a small wager on learning you have a clean bill of health helping you get out of this slump, or could go a long way to getting your mojo back.

Best of luck!


You might try lions mane, a mushroom that noticeably boosts my mental clarity.

Also, being older we have a lot more on our mind. So methods to help organize and focus are more useful than ever to me now. Take notes, keep logs, etc.


What supplier are you using for lion's mane? I've had good experience with RealMushrooms.


While I cannot comment on your long term problem, you can boost your focus temporarily with a combo of L-theanine and caffeine. Works great when you take it after breakfast. Takes an hour to kick in and is effective for around 4 hours. Having a good night's sleep helps a lot when doing this.

For maximum effectiveness, do not try to multi task while doing this. Just think about the problem and let your brain sort it out on its own. Major difference with and without is the lack of tiredness of mind when attacking hard problems. Brain keeps hacking at it till a solution is found.


A lot of good answers in this thread, but another thing to consider -- have you had COVID? Most people with long COVID started with a mild or asymptomatic case, and brain fog is a long COVID symptom. Do you have any other long COVID symptoms, like shortness of breath the you didn't have before? Sudden fatigue? Loss of vision? There is a long list of things, and a lot of them are also just symptoms of aging in general, so it's hard to tell, but if you have a lot of the symptoms and they all started within the last two years, you may have long COVID.


I am turning 40 this year, I have personally gone through this in the last couple of years. I do manage a fairly large team and still code, there are lot of distractions. Few changes helped me to keep coding, I went away from dual monitor to single monitor when I wanted to code, it helped me from not getting distracted. Setting up focussed time for coding also helped and its usually sitting in library. Putting phone or any notifications on the laptop to Going for a run or exercising before I start coding helped to clear my head and focus on coding.


I ran into this problem after salmonella at the age of 28. Cognitive decline occurred after some serious headaches. I had to re evaluate everything. I had to relearn how I took notes. I had to understand how I remembered things. I could no longer work as radial as I used to. And had to switch to linear mode. I had to break down tasks from "intelligent people only" mode to "anyone with a brain".

Of course there were other problems that prevented me from doing that like mental instability. But the whole process took a while. A couple of years.


In such a competitive field, with more and more younger devs being integrated -- the world's best and brightest -- it's completely normal to feel that way.

But the reality is that what you're going through is probably more about a need to optimize for boosted cognitive function/ neuroplasticity / mental performance / healing at the cellular level. It's what a lot of us are dealing with as we approach or welcome the big 4-0 age. Me included.

Supplements, lifestyle modifications and behavioral changes are beneficial to help optimize for enhanced cognitive function. Here are some that have worked for me.

-15-30 min of sunlight + going for a walk every morning -Cold showers (can alternate hot + cold... or even better, 10 min sauna + 1 min cold shower cycles) -NMN/NAD -Creatine -Vitamin D3/K2 -Physical activity/exercise daily -- for me, weekly, it's 3 days of weight training, and 3-4 days of yoga/core work/rebounding/walking/etc. -Meditation/mindfullness -Social interaction (in person!) -Time-restricted eating/intermittent fasting

Hope this helps. It sounds like your programming skills are exactly where they need to be/up to par with industry standards, so focusing on the cognitive/mental performance area should help boost your workflow/output. Good luck! Really enjoyed reading this thread. A lot of gold in here.


As I’ve gotten older I’ve fallen into this problem but also climbed out of it. It is worrisome that it is permanent, but it likely isn’t. There were several things about my life that I changed that helped me regain my focus and deep concentration abilities.

First was reducing TV, social media, and just scrolling internet news. Doing those things all day was training my brain to have a 1 second attention span. A vacation, if used to just chill out and do boring things for hours at a time can help snap you out. Your body and mind don’t want to live in that frenetic state so your stress will reduce too.

Diet and exercise is also important in making your body run as it was designed and helping your brain to be in a more relaxed, nourished state that will give you more mental stamina. Exercising first thing in the morning is good, but anytime you find your brain conking out is a good time for a run and often i’ve felt better immediately. Cardio helps me, I don’t know about weight training.

Diet is very important, and if you eat lots of carbs, especially late in the day you probably aren’t sleeping well and you might have high blood sugar that is impacting your ability to concentrate. Reducing carb intake, eating good breakfasts and light dinners, and not eating for several hours before sleeping (go to bed hungry, you will sleep much better and feel better in the morning) can make a big difference. If you work remotely and get drowsy after eating and you can take a nap early in the day, go for it!

Also just doing whatever it takes to calm yourself down and sleep long and deep night after night can help a lot.

At this age it is also a very good idea to get blood work done to see if there is any imbalance which could be affecting your well-being.

Finally, like muscles our brain seems to atrophy over time and strengthen as you use it. If you’ve been coasting for a while and haven’t had a real challenge, it might take a couple of weeks of frustration before you rebuild that mental stamina.

All of these life changes are very difficult to do at first, but once you make the change and feel the effects it becomes a lot easier and you feel so much better. I’ve done everything I mentioned here and gotten back my ability to learn and focus to a similar level as my younger self.


What language are you porting to? Designs that worked in the prior language aren't usually applicable, or preferable, in another. People who are so heads-down-get-shit-done can be writing the next-gen API in a way that they really shouldn't be, in consideration of language differences. Maybe you're more cautious? There are benefits for both types of personalities in a team, and one isn't better than the other.

Your mental abilities aren't declining. You've got a lot more going on in your life than you used to.


Maybe you are having a problem with managing your energy. What time do you get to work. I found that I can no longer work well into the night like I used to but that starting first thing in the morning is a very productive habit.

Do you have a lot of attention draining responsibilities? Do them after your programming time.

Are you a coffee drinker? If so, consider adding green tea to your routine. It will help smooth out the peaks and valleys of coffee.

Are you anxious and stressed? That will be very distracting and lead to feeling overwhelmed. Very counterproductive.

As we age, we become more aware of the limited time left to us to realize our goals in life. Suddenly, projects we take on can't be just about learning something new or advancing our careers, they start to be in competition with other values and dreams. Maybe what you're working on isn't able to supply a sense of purpose. That feeling can be very draining.

When all else fails, focus on what you can do, not what you can't. Get the system running and spend some time with it. Find things in the old code that are interesting to you. There are stories hidden in legacy code. Think about yourself relative to the craft and those that came before you. Ask to sit with the productive members of your team for a bit, just to ride shotgun and spend some time with a colleague. Rediscovering some of the sociability of coding can be very restorative. A spirit of comraderie can be the difference between apathy and enjoyment.


Some very good advice in this thread. I would only add one thing. Just do not resort to drugs (legal or illegal) in the hopes to improve performance. Drugs like adderall (or even anti-depressants like SSRI's, etc.) might show some benefits, but likely only the short term. By then, you will have trouble getting off, and cessation of the drug will take you back worse from where you started.

Also, you might not be getting enough physical excercise. Probably the best anti-depressive/stimulant there is.


Cognitive decline doesn't have anything to do with it.

I'll be 60 in three years, and it's much easier today for me to learn a new programming language, paradigm, API, etc, than it was twenty years ago. The reason is because: I spend a lot of personal time constantly learning new things, specifically focusing on things that seem scary and uncomfortable, not necessarily complex. If you already know Java, learning C# isn't much of a challenge for your brain. But if you've only programmed using Object-Oriented Programming, try a different paradigm entirely, an environment that's very different, including a different text editor.

Too many developers are too focused on sticking with what they know and optimize for learning the least possible. This is good and bad. It doesn't train your brain to deal with change -- very big change.

So if you've never used vim, force yourself to use vim on a project for six months. If you've only used vim, used Emacs. If you only develop on Linux with Tmux for cloud apps, go get yourself a cheap laptop with Windows, install Visual Studio, and try creating a WPF desktop app. or a Mac with an iPhone.

Back to vim. In my day-job I use Visual Studio. I have some side-projects that I work on that are entirely different environments. One is all NodeJS based using VS-Code. The other is Clojure using the repl. A third is using C and VIM, using raw gnu make that I hand-update. I also use both a Mac and Windows every day, which also adds the challenge of different common keyboard shortcuts on each.

So next time you got a problem to solve for yourself, write a commaand-line utility that is useful to you using C and VIM. Take it slow. Spend an few hours a week. You'll find that you'll have to get much better at context-switching, so you have to leave notes for yourself on what you're doing, where you left off, etc., much more than you do now.

The key is to force your brain to be uncomfortable, especially as you get older, even after you retire.

p.s. I seem to recall hearing John Carmack on some podcast talking about things like, where he recreated Wolfenstein 3D in Haskell, or tried using VI (not even VIM) on a project. I'm not sure what his reasons are, but hey if a strategy is good enough for Carmack, ....


> I don't know if this task is just an especially bad fit for me, or if my mental abilities are declining?

> The code I'm porting is average code, not terrible, but plenty of little things to complain about.

There might be a third option: struggling is a signal that API is convoluted. The code might be alright, but the design is bad.

You seem to be focusing a lot on API implementation (how it's done in another language), not the interface (what the API is doing).

Ask yourself: can you easily explain what should happen when each entry point is called?

If you can, why are you so attached to the old implementation? You should write it from scratch without relying on the old code. Old code is there to expose past knowledge (e.g. edge cases you might have missed), but not as a base for new implementation.

If you cannot, then API has a bad design. It might be alright for computers, but not for humans. Obviously accepting that it is bad doesn't solve your problems.

I had a similar case when I was ~28. What worked for me, is having a picture of how I would build it today, if I were to do it from scratch. This picture is usually much simpler and easy to keep in your head. Then, understanding the diffs between old and new design. The diffs essentially are the flaws of the old design, but now they are also the requirements you have to implement (assuming fixing API interface is not an option).


With the number of comments on this post, I doubt anyone will read this, much less the OP, but I feel compelled to say:

GO TO THE FUCKING DOCTOR!!!

If you're noticing something wrong or different with your body, go to the doctor to rule out something medical. Then continue your investigation. A doctor wouldn't try to diagnose you based on what you've written in your original post, so I wouldn't weight too heavily the opinions of a bunch of NON-DOCTORS with zero skin in the game.


Hey no you're not declining! I think this happens to a lot of us from time to time! I have become fairly good at recognizing it in myself (mid 30's) and have learned what I need to do to get over the hump!

For me - it helps to step away from work. I mean, really step away to the point I completely forget about work. Go play pickleball, take a day trip, hike, swim, camp, try something entirely new that you have never done before (skydiving, SCUBA lessons, cross-country skiing), etc. The goal is to become immersed in your environment to the point it requires a great use of your mental capacity - in a way that is engaging and fun.

Even if I don't feel like stepping away from work and I disagree with myself that the issue is actually becoming too immersed in my work for too long, I have learned to simply default towards leaning on experience and getting away for a while.

By the time I come back to the same problem if I haven't already gathered a good idea as to how to go about it, I will at least have a new perspective; it's a win-win.

Please take care of your mental health, take care of yourself and don't be too hard on yourself. Give yourself a second chance, draw things out, get out of the office, take a break, and come back and approach the problem after you've refreshed yourself!


Do you take notes on paper? If not now's the time to start, get you a legal pad and jot down some notes like the Where, What, When, Why, and How.

We only have so much working memory, life at times can take up much of it. No need to try to force our brains to do so much when you can do your thinking on the paper.

Paper notes are also great for being able to get up and come back to a subject. You can get up at any point and come back with a save state of what you were doing, and how you got there.


This is my worst nightmare, my plan is to leave this industry when I get really old because I’m scared my mental state will worsen and I will lose my problem solving skills.


I'm 45, have been writing code since 8.

Whatever you lose is more than compensated by experience, you spend less time solving the wrong problems.

A bigger issue is the cycles, and the realization that we don't learn much from history. Ignorance is bliss.


from a similar Ask HN:

> I do have memory issues compared with when I was younger, but I've been coding so long that the total set of stuff I know about is huge comparatively. I'm also much less intimidated by technical challenges since I have a lot more techniques I've successfully worked with and I'm more patient with problems.

> I'm definitely not the same programmer as I was in my 20s, I can't do weeks of 12 hour days in front of the computer like I could then, but now I have a much better and more intuitive understanding of what needs to be done, so I waste a lot less time.

https://news.ycombinator.com/item?id=33530972

Older athletes can't compete with younger athletes on pure physicality, so they have to use other skills: intuition, patience and wisdom are three things that come to mind.

You aren't the same programmer you were when you were young.

Good.

Life would be boring if you were.

Maybe the right role for you here is to establish a good, clear test suite for the transformation to ensure that the API transition maintains semantics. That should also teach you the subtleties of the API, making the work easier to deal with.

Another piece of advice I have for people dealing w/ their CPU slowing down is: just go. Hesitation because we aren't as good as we once were kills a lot of older developers productivity and knocks a lot of good developers out of the game. Just go.


As many have said already, it could have one or several of many different causes but aging. Cognitive decline once happened to me at age 35: it was anemia (blood deficiency), caused by colon cancer (long cured)

If the problem is serious, by all means do see a physician. He should be able to diagnose burnout, if nothing else -- which I believe is the most probable cause. There are many programmers in their fourties and older that do fine. Don't believe the agists.


Any number of things can affect your ability to handle abstraction. (Including just not being interested.) Other people in this thread will probably bring up all kinds of ideas for external forces affecting your mental capacity.

First thing you should do is figure out what's wrong. Refer to what other people here are saying. Additionally, see if your family history includes a history mental illness or degenerative medical conditions (including dementia and Alzheimers). Everyone knows someone with this, you're looking for a pattern. For example, multiple people in my maternal grandfather's family had been institutionalized and most of the family had bipolar and schizophrenia diagnoses.

And now, how to still get your job done... :)

At one point in my career, my mental facilities became so compromised, I couldn't follow abstraction. Instead of seeking help, I figured out a system to overcome this.

What I did was externalize my memory. Quite literally, I would write everything I needed to paper: variable names, notes on their contents, call stacks.

Once the entire set of function calls where on paper, I could see the structure and continually shuffle things in and out of very limited working memory as I worked to understand and fix issues.

It's slow, but not as slow as you would think.


I would not consider me as much of an authority to give advice, but here are my highly personal take. I believe that this is more about focus and the ability to do a task with high intention. Also, I stopped active professional programming quite a while back, and hence this is me, a developer turned designer turned business person talking.

In my twenties, I can churn out things pretty much non-stop. I think I was trying to "prove it" and I could clock extras in the evening and weekends to move ahead. I could do something repeatedly until it was better than the last. I also tend to take on other people's tasks a lot.

In my thirties, I was still shuffling, not just me and my task but many other people too. I loved the messiness of deadlines, the near-misses, taking on new things, and being in the front of the battle, fighting in it and not flying over it.

I have now hit my forties; I realize I like to take time but do it right the first or second time. I also want to selectively do things with an outsized return on my time invested.

In short, I would have liked a Gatling gun in my younger days, but now I want precise sharpshooters. I'm of the opinion that it is OK to slow down, breathe, and take more targeted precision strikes.


First, the entire point of using abstractions is that you do not need to understand what's behind them. Try to port API layer by layer (ideally if you can also apply vertical slicing e.g. user endpoint, invoice endpoint). Stub lower layers with some not-implemented-exception or whatever you have in your target language. Make the project compile all the time, setup Jenkins(CI) etc. Then slowly move API part by part. Ideal case would be to make a single API request working in the target language and then to move the rest of the API incrementally.

Second, what you are doing is one of the most boring work there is. Try to find automated translator that can speed up the process (a least the boring parts). Writing one is not an easy task for most folks so I am not advising DIY. If you are doing this work for a 2 weeks or more maybe you are just bored?

Did you notice mental decline in other tasks? LeedCode & stuff? Chess? Forgetting words? If this is only work related it may be burnout. If not, you may try to revisit your lifestyle: did you recently gained weight? are you eating healthy food? do you have enough exercise? In any case it may be a good time to make an MD appointment.


I suspect you're burnt out. Surely you can hold more than 2 levels of a callstack in your head at 40, so something else is going on.

Of course the code can also be particularly convoluted with some domain-specific knowledge that you may not necessarily be an expert on, so in that case, I'd find someone to ask questions or or an intro book until you can get to an 80/20 situation, where you feel like you understood most of the domain context.

If it's not the code, take a break. Long walks in a place with trees helps clear the mind. Longer sleep, exercise to get the blood flowing, no alcohol. All the usual healthy stuff.

You could also try to draw the data flow on a whiteboard, in a "follow the money" kind of way.

Alternatively, if time permits, try to reimplement the algorithm or solve the problem yourself, in your own preferred language/environment. This will get you sufficient knowledge about the functional requirements where you'll be able to see what the author of the code you're porting was thinking, since they likely encountered the same challenges as you.

If nothing else works, you can just be honest with your manager and try another project that feels like it would be easier or more fun.

Good luck!


My biggest pain point with programming is I am constantly rebuilding mental models of software projects.

I think its a problem with the way we write software. I think all code we write should be visualizable at different levels of granularity, and should be able to show data flowing through it inline. We have all these principles about writing good software such as it should be testable, performant, self-documenting...but I would argue the most important thing is that it should be visualizable! And easily debuggable.

---

I would suggest using a visual debugger and an IDE with static call hierarchy features (sometimes called find usages or find all references).

You should think about how you would build it from scratch. Then fit the existing API to your own mental model of how you would build it. Then it will be easier to understand why people did things a certain way. Many times I will see someone's code and wonder why they came up with such a complicated abstraction layer, but then when you build it yourself you see how it comes very naturally. The problem is for most projects you are looking at the end result of someone else's journey of building from scratch and refactoring along the way as needed.


> several other developers are making progress on porting this API

You didn't mention tests. How do you know their 'progress' is actually correct or even good?

I'm presuming the 'several other developers' are younger than you, hence your concern about age. Without some measuring stick to know if what they're doing is correct, you can't tell if they're just doing more work or actually doing it correctly.

> How do I find even a single chunk of manageable work to break off.

How is anyone else finding work to break off? Is this a free for all, or are there any planning sessions to identify things? Without that, you might be overwriting or reworking something someone else already did.

You may want to ask for some pairing with someone else who you think is doing this better/faster than you, and just ask to work with them for a couple hours.

Talking through the problems with someone else might help turn a corner with respect to mental models. How are they reasoning about current code? How are they tracing through the paths? Someone else deep in this problem may be able to come up with language or examples that resonate with you in a way that random HN people can't.


> I can't seem to hold more than about 2 levels of call stack in my head.

If you keep thinking that you can't then you won't.

I recommend you to stop worrying and do the work. In time you will find ways to accomplish your tasks. In any case you can't go buy a new brain so why spend time worrying?

Looking at it differently: Even if a young you had greater mental ability, did young you have the same skills, experience, knowledge etc.?


Don't think about it holistically. Try to just port the smallest, most independent parts you can one at a time and link them up. The approach I'd take (as a developer with shoddy memory to begin with) would be to find my way to the leaf nodes and start porting them, then work back up the tree. Hopefully that way I shouldn't have to have more than 2 levels in mind at any given time anyway.


I agree. While some programmers seem to be able to hold massive quantities of complex spaghetti in their heads, many of us are not. As long as each layer is well designed and the layering itself is well designed, 2 levels is about all you should need to consider at any given time when immersed in the code.


I'm 42 and I forgot my bitwarden passphrase. About 20 hours later I remembered it.

I just sat down and was typing a much older passphrase despite having used the current one daily for over a year. That was probably the scariest part is that I remember the past few weeks as if I were using a different passphrase than I actually was (down to having typos on my phone that are impossible with my actual passphrase)


Just a tip, but print out your password, put it into an envelope, close it, and store it at your family or bank or somewhere. I do this for my 1password and google account in case something happens to me, but can also be useful if your memory fails you


There’s not enough context of you here. Our ability to think clearly is predicated on a lot of stuff, almost all of it psychological and lifestyle but some health and genetics.

Are you depressed? are you burning out? Are you eating well? Are you exercising? Are you disengaged? Are you socially engaged? Are you anxious?

You need to step back from the tasks you’re finding difficult and look at yourself not as a programming machine but as a biological entity with a complex giant dna mutation brain that can easily get thrown off track due to any number of factors. Most likely unless you’re developing some sort of early onset brain disease you are depressed, anxious, burning out, or simply aren’t interested in what you’re doing. By 40 things get complex because the newness of “OMG IM AN ADULT” wears off and just simply working isn’t enough, especially in a task that requires “flow” of intentful mindful engagement.

I suspect you need to step back for a bit and look inside yourself very critically and examine what’s going on. To me it sounds like probably a mixture of all of the above, leading to a growing burnout. My suggestion that worked for my burnout is take up a rigorous practice of vipassana meditation, regular exercise, managed diet, and rigorously constraining work focus to when it’s appropriate and otherwise entirely letting go of the pressure to perform. Then when working not engaging in second guessing your output - we have ups and downs, the important part is enjoying the process of programming. But YMMV, I would start with taking those questions above and asking the people closest to you them and take their answers seriously, see a doctor and explain your challenge, and see a psychologist and explain your challenge, and spend time seeing yourself for who you are not who you think you are.

Good luck!


I think too that younger developers are more enthusiastic and naive, they just go in and do the work. Experienced people can see more complex cases, more failure conditions, more future paths and end up making the task more complicated than it could be. On top of this its probably not as interesting if you've done this a few times before so adds up to a good place to procrastinate.


A technique I found useful as a relatively younger person (early 20s) is to keep a text doc to enumerate work priorities, to record progress, and to record where I left off. I found the last point most salient: whenever I faced an interruption (a colleague question, meeting, etc.), I got in the habit of quickly writing where I left off; that is, lowering the friction in task-switching.

Here's a verbatim example from my notes that I think is similar to your use-case:

```

* Clones `std::vector<AnyModule> modules_` member variable, defined in `./torch/csrc/api/include/torch/nn/modules/container/any.h`. Its `clone()` method calls the `clone_module()` function of its member variable `std::unique_ptr<AnyModulePlaceholder> content_`. `AnyModulePlaceholder` is defined in `any_module_holder.h`. Its `clone_module()` method calls `clone()` on its `std::shared_ptr<ModuleType> module` member variable. `ModuleType` is some module that has a `forward()` method, i.e. an object of type `Module`. __But,__ it should probably also have `Cloneable`.

```


+1 to all the interesting points here.

Just to cover all bases and include external factors, use of Statins could cause reversible cognitive decline (source: https://www.fda.gov/drugs/drug-safety-and-availability/fda-d... )

Statins is a big business for Pharma, and they continue to push these for “managing” high cholesterol. The risks associated with statins is far higher than the benefits obtained from consuming one.

If you are being prescribed Statins, please review these videos

https://nutritionfacts.org/video/are-doctors-misleading-pati...

https://youtu.be/inwfSkSGvQw

Disclaimer: I’m NOT a medical professional and this is NOT medical advice


given that you're asking how to break down a complex task into pieces, it sounds like planning rather than execution is the problem. to wit, it doesnt sound like its mental capacity -- if you knew how to do it before, you'd still know now. i think its quite normal to hit 40, start worrying about aging and attributing things to decline, but chances are you can do much more complicated things than porting an api with your brain and will be able to for a long time yet.

in terms of practical advise: more haste, less speed. ive no idea how the code is organised but consider porting it in layers (e.g. data access, business logic, helper functions) as opposed to API endpoints. Layers should roughly be decoupled things with clear interfaces between them. The stuff on the same layer should have the same concern. That way you can go breadth and not depth first and tackle one function at a time. Once you have a mapping at a function level from the old to the new code base it should be easier to plumb the API.


> You know how it is, code calls other code, and logically it forms a tree of calls and return values that often goes several layers deep. I struggle to hold more than about 2 levels of this call stack in my head. By the time I'm down in the weeds I've forgotten what I'm doing, what the purpose of the actual API call is.

I also had that difficulty when I was a younger developer. The difference now is that the novelty of learning how to program at a professional level, learning a new language, and learning a new framework, isn't there.

Instead, the novelty comes from convincing others not to make the mistakes I would have made 20 years ago; and not making those same mistakes myself.

I was in your shoes, things I'd find frustrating are:

- The original version was working fine; a rewrite just isn't justified.

- Some team members are writing poor quality code, and I just can't convince them to do it right.

- The original version has style / habits that make it fragile or hard to understand.

- The original version has behavior that's generally not understood.


People without great memory deal with this all the time: write more shit down. The amount of pseudo coding I have to do these days would embarrass my 20 year old self. Whiteboards and notepads are your friend.

¯\_(ツ)_/¯

p.s. thank you for sharing these concerns - it's brave of you to talk about mental worries in an industry where "smart" is a superpower. Good on you, brother.


Amazing pile of responses for a crucial problem most of us face (eventually)! Looking at it from an information point of view, we have tons of it available all around, consuming most of it so very generously, and probably in this process the mind is getting overloaded, having slight effects of degeneration in some cases. These are self-observations over a period of time.

Now we may be 40 and find such traces, but this issue is also growing rapidly with younger folks today, as their rate of consumption has further increased in the information jungle.

To forget is human, but occasionally we also tend to forget some crucial info that we sure knew some time ago, and that's when it bugs. This is what motivated me to create a solution for this universal issue, and started developing a system that seamlessly works alongside as a personal extended brain (our own coprocessor) that just cannot forget. If this is something of interest, it'd be great to hear from you (@shrix).


When you wake up in the morning do you feel rested? Or are you still tired?

Others have already mentioned this but I think it's important to reiterate sleep quality. I learned I was not getting enough oxygen at night due to congestion when I went to the doctor for problems with tiredness and brain fog. Taking nasacort each night before bed completely changed my life.


Why not go to a doctor/psych and start getting some blood work done to see if it's a brain fog, mental health or xyz thing? It sounds like you feel like you're loosing your working memory that you had previously, so why not see if good mental health, diet, exercise and professional insight might have. Worst case there you get healthier over all likely increased life expectancy but you're out some time/money

I don't know if this would help, but I'm in my later 20's. I didn't actually know how much my mental health played into how I performed, cause I felt fine. I went to a therapist it turns out I've been *redlining* anxiety most of my life I just got used to constantly operating at that level, and I was wondering why I wasn't getting the performance I thought I could give when doing fun non-stressful environments. It just snuck up and built up over years and that became a normal for me.


I'm almost 50, I don't think this is age related cognitive decline per-se. My guess is that it's motivation-related. As I age, I noticed that my ability to perform what I perceive as needless/unimportant busy work has declined and I find my mind drifting to thoughts like "Why am I doing this? This should be automated. This task would not have been necessary unless someone screwed up." When I was 20 I didn't question whether pulling an allnighter for some absurd arbitrary deadline was justified, but I steer way clear of these kinds of projects and clients now that I'm older.

It may be time for a change. It's probably a programmer's version of a midlife crisis. You notice that your remaining (productive) time is limited and running out quickly. While porting code from one language to another can be fun, I doubt this fun extends to mindlessly porting APIs. Your brain may just be rebelling.


Whenever you get stuck, try copying and pasting chunks of the code into ChatGPT and pretend it’s another expert developer and just ask the questions you have or ask it to do the thing you’re trying to do. Break it up into smaller chunks so it fits nicely in the context window, and take advantage of the multiple messages for follow up and clarification. If the generated code gives an error, simply paste the error message in as the next message in the conversation.

Also try using GitHub Copilot in the unfinished project with all the relevant files loaded into the current project. Then try writing code comments explaining what the following function does. Basically, try supplementing your own human intellect with the machine intelligence. It’s already unbelievably good and is going to get so much better in the next 1-2 years, and then you will already have a head start on how to leverage it to the maximum extent. Good luck!


Twenty years ago, if I was asked to do something like port an API from one language to another, I'd just tackle it. And it'd turn out like complete shit. But co-workers would be happy because its done, and they'd say I was a great programmer since it was completed so quickly, and as a result of my port we'd have new technical debt that would probably haunt the team for years.

Today it'd take me much longer, and the end result would be better. This is experience, because I know many of the ways in which a port could go sideways. The way I deal with massive bodies of work would be to handle it in well tested small pieces. If you're having difficulty figuring out how to arrive at these small pieces, then that's the challenge right there. You'll get good at it by working towards it.

I know that, despite my age (44), its not cognitive decline. It's experience and the end result of my work is simply better.


As I get very close to 50, I actually feel smarter. Reasoning on hard things come easier. I can approach problems I found too hard in the past, sometimes even being embarrassed of my previous dumber self.

I'm in good health but I do have less energy, like a higher horsepower engine with a smaller tank. I don't have a problem with the tradeoff...


I'm 50 and it's harder for me to rapidly process input and big "systems" like I used to. I suspect this is more due to having kids and increased responsibilities than age.

Here's what I did and it seems to help tremendously:

1. Get plenty of sleep.

2. Get fit. As part of this, get your weight down to a health level.

3. Eat right.

4. Get your weight down to a healthy level. I don't know if it's related to circulation or respiratory or what, but my body/mind function better when my body weight is lean.

5. Reduce inputs, such as podcasts, HN, Reddit, etc. Don't stop entirely, but take occasional days or weeks off from one or all of the above.

6. Spend more time doing nothing, being bored, in thought, like we did before the Internet.

7. Be at peace and work on the top 6 the best you can, and forgive yourself when you can't, and get back on track ASAP.

You will fall off the wagon on your goals. Recognize it when you do and immediately forgive yourself and get back on track. Immediately.


Is it that you don't "know how" or that you aren't motivated to do it?

As I've gotten older (and overall more competent) my threshold for novelty / interest has gotten higher. Drudge work, that once might have been fresh for a younger version of myself, now feels repetitive. I already "know how" to do something, since I've done things like it before, and as soon as I sketch out the high level overview in my mind grinding through the implementation bores me. It's simply become harder to find projects I have an interest in.

This manifests in my work. The stuff I find boring/lame I am terrible at - when I sit down to work, my mind wanders.

For me, at least, this feels a lot like school. "I know this already. Or at least, I know the broad strokes enough that I can see how I'd go fill in the gaps. Time to zone out and think about something more interesting."


1) I used to feel that way and then I tested myself against my younger self and was as good as ever. A lot of this could be 'in your head' pun intended.

2) Oxygen: past 30 if you do not exercises or do cardio you will probably pay a price. Everyone is different. 30 mins running will make you feel 10 years younger.

3) You may have more perspective and more distractions. In my 20's I didn't even read the news. Who cares? Now, I 'care' about all of those 'issues' and I'm constantly engaging my mind with those materials and it's a distraction. Even children, colleagues, other responsibilities - those wear on your focus. 'Young me' could just sit there and work and literally not give a thought to anything else! That's a luxury. If you can create a silent work environment without distractions maybe that might help.


Only writing this because I didn't find anyone else referencing it, but I'd also check for some sort of a deficiency. It turns out that I was severely vitamin D deficient, as soon as I started taking it daily all my long-term health problems (including mental fog and memory issues) pretty much disappeared.


I would like to add, that I had the same issue. I was consistently worse at my job during winter. I picked up vitamin d and feel much better mentally. And i can finally work properly.

One more thing - co2 levels inside room can have significant impact on your mental capacity. So open the windows every morning, lunch and evening.


It's not normal decline at 40. You have a few decades more of programming if you want them. (I'm calling that out first because you put it in the HN headline all the 23yo founder techbros will see.)

Get a doctor visit to start addressing your concerns, like you're determined to fix it. And you mean actively fix it, not make a notation in your record and plan to do another checkup in a year.

If you WFH, make sure don't have CO2 or other air quality problems.

Make sure you're exercising, getting solid sleep on a regular schedule, maybe cutting out caffeine, and maybe ask doctor for nutritionist referral.

Also consider that the problem might be motivation. Maybe you see nothing interesting or worthwhile in porting someone else's hugely complicated API bureaucracy from one language to another.


Not quite 40 yet but I’ve felt this way sometimes. Like the problem is too big and I can’t break it into small enough chunks to make sense of it.

Sometimes it helps me to open a text doc to use as a “thought stack”. Just a bulleted list of items as I descend into a problem. Whether that’s an actual call stack, or just a yak-shaving exercise, it’s nice to have those first few levels written down so I can get myself back out. It also helps for refreshing the context.

Another strategy I’ve used is to write out the architecture in prose, explaining the pieces and how they relate, stream-of-consciousness style. I find it helps my mind break out of thought loops.

I also notice that my mind recoils at anything that is boring, or that seems relatively pointless, to the point where it’s very hard to get into a flow with work like that. I think that used to be easier to push through.


”It's often assumed that children learn more efficiently than adults, although the scientific support for this assumption has, at best, been weak," says study co-author Takeo Watanabe, a cognitive psychologist from Brown University”

https://www.sciencealert.com/kids-incredible-learning-may-al...

My theory is simple - kids simply have more time to learn and less other bullshit to deal with. Some years they have practically nothing else but learning, exploring, sleeping, eating and pooping. And not to mention that many of the humans around them actively bring all concepts down to their level (and some use babytalk) to explain them. So yea… an adult doesn’t have any of these advantages.


I agree with much of what others say: if you want to assess your mental ability, first count how many other tasks/responsibilities/distractions/obligations etc, you have in your life. When I was young, to a large extent I could concentrate on the task. And I ran. Later with two kids, a dysfunctional wife and dysfunctional job - not so much. I'm over 65 now. I still like programming. I have lost some quickness in some kind of memory, but that is made up for by a much, much deeper understanding of the patterns. I'm not sure how to describe it.

And thinking of patterns, perhaps that is part of what you are up against. I find that trash code is increasingly hard to sort through. Does the API itself make sense? If not, then maybe you are better off thinking about how it should be written. As a starting point.


I would talk to your doctor and get their input on the situation. Perhaps it's nothing, or perhaps it's something easily treated with medication. Why spend months and years continuing to suffer without doing anything about it.

I'm curious though have you had one or even more than one COVID infection? Brain fog / difficulty concentrating has been known to be a symptom of long term COVID complications. The sooner you identify it as a potential problem the more you can do to work on addressing it with a healthcare professional.

I don't buy for a second that a 40 year old is 'getting old' or that this is normal for your age. I'm 41 and as sharp as ever--I love solving problems and don't struggle with abstractions. Something is up IMHO and it's time to talk to a pro.


Others have given a lot of good advice, but porting code is a menial task and not suited for someone of your experience level. Unless this port is a real game changer and you're going to get lots of credit for helping the company in a major way, it's just a thankless waste of time.


I've felt the same way. That's why I'm having to take better care of my mind and body through better diet and exercise. It helps but it's not like when I was in my 20s. I'm also working on starting up a business or two that I can just manage workers with rather than have to do gruntwork. There's a lot of ageism in coding, and I think it's because our brains just don't do as well in 9ur 40s and 50s+ with all this complication. I hope you socked some money away, like retirement, etc. Focus on that as much as you can. Index and mutual funds, growth so you can exit the industry before it boots you out. There's plenty of room to foster an idea and have others do the layers of abstract function branches.


You're porting one functioning api from one language to another.

How high up there is this on your list of things that you would like to be doing today? I'm guessing it's not very high. It would be pretty low on my list.

Start fiddling with ChatGPT and get it to convert it for you.

You're bored, not brain dead.


Perhaps try working memory training software of the type that Suzanne Jaeggi used in her studies. The software is called Brain Workshop. It is free.

Note the science on this is messy. Jaeggi's paper suggested transfer to fluid intelligence, then another paper questioned that, then she wrote a better designed follow up, then another paper questioned that.

Anecdotally I think it worked for me. I personally think the difference in study outcomes may have been driven by differences in how diligently study participants stuck to the regime, or perhaps even how well they understood what they were supposed to do.

A second recommendation is to read John Medina's book 'Brain Rules for ageing well' which has lots of tips for combating cognitive decline.


Found Brain Work here: https://brainworkshop.sourceforge.net/

and also a browser-based versions of Dual-N-Back here:

https://www.brainturk.com/dual-n-back

https://brainworkshop.sourceforge.net/


At 50 or a bit after, things begin to shift for me. I couldn't just head down crank out code as well. I couldn't multitask nearly as well. Distractions and interruptions became more of a killer.

But I could "see" better. I could see more clearly what was code that was likely to become problematic. I could see what was architecturally "smelly", and what was a better alternative.

Did that change make me less valuable? Or more? I think more.

So you may be feeling the start of that. Maybe you're becoming more valuable than just cranking out a port. Maybe this is a good task for younger you, but no longer a good task for who you are becoming.

And maybe you can talk to your manager about where you could be more valuable.


Are you doing exercise, like aerobics or weight training?

Are you sleeping well?

Are you doing early time restricted eating? I.e. intermittent fasting

Hows your diet? Any alcohol or nicotine?

Those can have profound effects, and, though not an expert myself, they can be synergistic with each other

Exercise spurs neural growth in the hippocampus, which is key to short term memory

As you age sleep quality naturally deteriorates, starting a rapid decline at around age 45 if I remember correctly. Meanwhile, phsycal activity and sunlight exposure to your eyes during the day improves sleep quality. In addition, time restricted eating can have a powerfull effect on sleep quality

Intermittent fasting also increases neural growth and energy

On diet: Read a book called "Biohack your Brain" by Dr. Kirsten Willeumier


I felt that way when I was on welbutrin for depression. The fog likely started creeping in sooner, but I didn't notice it for over a year. As soon as I got off, the fog started to lift. Just something to consider if you take any medications.


Maybe you know "better" now?

With the experience you have built, you know which problems can occur, which architectures work well, which traps appear in the code you read, ... so when you have to take on something, you may be more interested in turning it around, but it's a tough task, and sometimes not even possible due to your company, so you end up being depressed

On thing I have become good at with time is refactoring, but when I can't do it properly, don't have enough information, not interested by the subject, or the team, I end up mostly giving up.

I think this is kind of being more wise and doing things that matter (to ourselves), instead of just writing some piles of code.


I'm 43 and feel the complete opposite. I am less coordinated and heavier than I used to be. I am learning advanced SQL for the first time and it feels like I am picking it up at a good speed, but still a bit slower than maybe if I were younger. I suspect this is more bias than mental degradation because I look at SQL and wonder why people would put such advanced logic into stored procedures which are limited by archaic conventions.

On the converse my primary programming skills have never been sharper. There is a caveat to this. I feel like I am an expert in what I do, which means I am confident in what I know and what I don't know. It also means there is a lot I have unlearned or intentionally avoided because such practices are anti-patterns or decrease productivity. Some of these things I deem "poor choices" are extremely common conventions which may indicate I am only a beginner from the perspective of a less practiced person who cannot live without such "poor choices".

I believe my programming skills are sharp because I am doing things outside of work that nobody else is doing. I have now reduced my OS GUI to a load time of around 165ms in Edge (130ms in Chrome). I saw a code package from Google on Github on the front page of HN either yesterday or the day before describing a means of file transfer cross-os. My personal JavaScript application has been doing that for years. Soon that personal JavaScript application will have a command terminal that executes in a web browser that works on both the local device and remote computers cross OS.

I once read about this in a book. I cannot remember if that was Blink, Outliers, or Good to Great. Performance follows practice, but the practice must be strenuous, such that you are continuously solving ever more challenging problems. Its the difference between a hobbyist whose skills will degrade over time, a professional whose skills are actively maintained but not advancing, and an expert whose skills continue to increase. As an example most senior developers I have met believe they are awesome because they are doing the same things they were doing 5 or more years ago, but now they are so much faster at it. That isn't awesome, its steady state.


I'm in my early 30s, have been programming for 10+ years and have this from time to time but as another comment said I don't think it's age related but more burnout or general tedium of the task. As I get older I do notice I have to force my brain a bit more to do boring tasks like the one you're describing, it feels like I'm not necessarily mentally declining but have less patience for these kinds of tasks and have a better idea of what I'd rather be spending my time on (creative tasks, friends, family).

Also anecdata but I'm finishing up a project in which the CTO of the company has a good 15 years on you and seems as sharp as ever.


I hear you, and I've definitely felt it myself, although not sure I'd jump straight to cognitive decline. Sounds more like a bad case of brain fog, which is a known thing.

Maybe there were stresses on your body that youth simply helped you handle better until now.

A few quick questions: do you exercise regularly, and specifically, do you go jogging or running? That usually helps a lot.

For me, it was more a case of high blood sugars and poor diet. My head cleared up a lot once I fixed those.

Here's an old favorite of mine: https://youtu.be/7H7id3to1cg

Other tips: intermittent fasting, get rid of dairy / other allergens.


What I’ve found is that some developers seem to thrive in chaos, whereas others expect things to make clear and logical sense. I’m one of the latter, and maybe you are too.

I’ve found that messy or illogical code slows me down more than other developers. On the upside though, I typically write cleaner code than other developers, because that’s the only type of code that I’m comfortable with.

Just accept that not everything is going to fit well with how your brain works and try to get through it.

I recommend taking detailed notes on everything you find and trying to map out on paper the call tree and different classes involved. This can help greatly when dealing with messy code.


I struggle with certain type of tasks (age 30) but for something like this I'd literally print out the code and go through it line by line. I find it's easier to visually parse the connection between bits of code. Otherwise, if I don't have a printer, I'd just open a ton of VScode windows on my giant monitor, which I have mainly for this purpose, or write it out slowly in a sketch book.

For me, I used to be very good at CSS, but I'd always fall apart when needing to actually sit down and write the code. That's largely still true, but haven't really kept up with the css spec that much in recent years.


Don't underestimate the fact you likely don't care about what you are doing.


I’m 41 and feeling the same. One solution that helps me is to be more methodical, and make detailed notes. So, for example, when trying to understand a set of nested calls, I decide whether I’m going to do a “depth first” or “breadth first” analysis and then I work my way through it, noting as I go. And if it’s BFS, I do actually keep a noted queue of nodes to traverse. Then I can work mechanically without worrying about my limited memory capacity.

My memory is totally shot. I think it faded away through years of insomnia, poor diet and lack of exercise. It became harder to live healthily after I had kids.


I am coming late to this thread, but I'd also like to note: we don't exist in a vacuum. In less than 10 years, we've had severe civil schism and a worldwide pandemic. These things can activate our fight-flight-freeze-fawn system, which specifically takes energy from higher thought. That last sentence I need to underscore as actual neuroscience, not anything hippy-dippy. The cure is, among other things, to be kind to yourself. Again, neuroscience: to assure that system within you that you are okay helps return the system to better functioning.


"Youth is the most precious thing in life; it is too bad it has to be wasted on young folks."

When I was young, hungry, eager, I would drive fast and take chances, fail fast often, move fast and break things, you get the idea. I would have ripped apart that API and put it back together in record time, paying no attention to any debt I have accrued.

Years of mistakes have earned me the caution necessary to not deliver products that ruin my nights and weekends, disappoint clients, or make my company look incompetent. It sounds like your experience is correctly preventing you from making those mistakes.


Burnout can affect your ability to work on complex things, a lack of time away from programming, high stress positions and long hours, boring repetitive work. Overcoming all or some of those things takes a lot of energy away from your ability to focus.

It's not age, I was more capable when I retired in 2021 than I was in the 1980s because I found ways to give my brain enough time away (sometimes getting laid off forces you!) and also switching to completely unrelated programming jobs to provide a new perspective. I never completely burned out by giving my brain something new to focus on.


Design: top down Implement: bottom up

In my experience, certain tasks are not challenging and I really don't want to do them. I have a system for when things get this mundane. A pad of paper, and 3 pens, blue, red and green. I write down the next 5 or so things I need to do to make progress in blue. Really nitty-gritty when needed ('search list for target value', etc) Optionally, if needed, I put a green dot (instruction pointer lol) next to the current line in the list. When the line is complete I joyously scribble over it in red and get to the next thing. Repeat as needed.


The following are things I've identified myself, in case it's useful for anyone else.

When people say X is bad for you, they're usually right. But how bad is it? Will it affect you 5%, 10%, 50%? When you combine many bad things, they'll gang up on you together to make your life hell. They also affect you more the older you get.

Bad things:

* Lack of sleep

* Lack of exercise

* Social media

* Drinking/drugs

* Interruptions

* Unresolved/ongoing family/friends issues

* Bad and/or irregular diet

* Not doing things you like to do.

The feeling you describe using the contrived SHA-512 task, is of total, utter panic and hopelessness, putting it mildly.

I don't know how deep into this you are but it left unchecked it turns into a vicious cycle. Then those bad things mentioned above are more likely to knock on your door and make the problem worse in the long run.

Throughout my career I've sometimes had to use pen and paper to keep track of my thoughts while reverse engineering (which you are doing) or debugging spaghetti. File/Class names with function names and simple diagrams have been very helpful.

I've found out that trying to save time by not setting up a proper debugging environment is a very bad thing. Ideally you should be able to run both old server and old client on your computer. Write a very, very simple client that speaks to the old client.

Add logging and breakpoints to the old API. Step through it and write notes on paper.

Mental abilities declining? I don't know. I've encountered code that I struggled with at any point it my life. Perhaps the other devs know the code better or have had similar experiences. Perhaps you're working on a more difficult part of the code.

I'm guessing this old API was written over a long time. As such it'll have warts and bug fixes that are not trivial to understand. Do you know the language and framework it's written in? If not, write a very simple API in that lang/framework to understand it.


This may sound entirely irrelevant but certain common diseases that usually show up around middle age cause brain fog, which we usually incorrectly diagnose as "aging". Diabetes is one such disease which highly decreases focus and energy on most people. Luckily, once managed, those effects mostly disappear.

In my case, it was allergies. I discovered that I had gluten allergy (mild) since birth that somehow stayed out of my radar for 28 years. Only after age 28, its side-effects became so apparent that I had to take action, only to find out that it was there all the time.


Stop asking Hacker News and start seeing a neurologist. This is a job for a professional.

It could be that you just need a break or some clever productivity hack etc. Or it could be something serious. Better rule that out first.


If anything I'm a much better programmer in my 40s than when I was younger. My cognitive capacity (being able juggle more balls at the same time) is about the same, probably a bit better now. My lateral thinking has definitely improved. And then of course I'm wiser because I have more experience and my instincts are just better.

What surprises me is I learn much faster now than I used to. But I guess it makes sense. I never stopped learning new things (coding or otherwise) so I've learned to learn. I also have more data points to compare new stuff to.


I see several people have mentioned "see a doctor", but I will repeat it. This past year I was diagnosed with a B-12 vitamin deficiency. Now, a year later, my job is much easier than it was then.


I used to think I was smart. But I realized I'm just ok in smartness. We need to get smart about not being smart. To me that means having a plan. Then you can become effectively smarter than smart people. For example, I take notes now, I keep a work log and work journal. I read and watch the same articles/videos multiple times. I take my time understanding more before wagering a solution. I ask more questions and get more input from others. I provide value through better emotional intelligence than brute force productivity.


It sounds like you're trying to hold all this in your head rather than taking notes! Why?

Are you sure the task really requires going three+ levels deep into what the API is doing??! On the surface, being asked to "port the API" sounds more like a request for a work-alike API not a complete redesign, although with the idiom of the target language of course.

I don't think this has anything to do with age! You should be at the top of your game at age 40, if not still improving, but maybe there are personal/stress factors that are affecting you.


You could also go to a neurologist and have some tests run -- beyond general aging and its impacts on memory and reasoning there are other types of issues that can impact people much younger than expected.

That said, if you do not exercise you should really try for a few weeks. Where your body may have been able to coast with normal effort in the past as you get older you need to give it more focused work to get the same level of outcome. Beyond being good for your health exercise is known to have huge impacts on both mental state and acuity.


Maybe this just isn't the job for you? If I were in your shoes, I'd be thinking less about the existing code, and more about what it does, and any edge cases, I would also review the code of your peers to see if they're just verbatim copying it, or if they're just making sure that you get the same output you need.

Another thing you could do is, become the guy who builds all the documentation for the new codebase + unit tests. If you're confirming the two code bases are "exact" you will need a lot of testing.


It's social media that has turned our brains into mincemeat. I can't concentrate on anything for more than 5 minutes anymore. I'm definitely worse at coding than I was 10 years ago.


Yeah, I am actually feeling this a little bit. Five years ago I could still focus properly. It is already way harder I find. Though another part is that I am way more aware of things I do not know, so I get caught in decision paralysis because of things I do know will break, and because of things I did not know of.


Wait till your 50!

Days get shorter, winter gets colder, days blur together. Things change. Fortran was way easier... Pfff objects of objects to keep track of.

Remember what your core strengths are... Where the true wisdom is. And always check back to the requirements document.

You have a detailed one right?

Break what you are required to do into smaller components, but from the other side of the problem, systematically. I find by going smaller and smaller I eventually find a manageable chunk that I can start with.

A rainbow attack on the sha512 can often deliver a fast result.

I have to go yell at a cloud now...


It's probably not you, it's just badly structured legacy code, and you're trying to understand it all like you wrote it. Been there, it sucks.

Find someone who worked on it and have them explain it to you like you're a 5 year old. If they can't explain it in simple terms, you'll confirm that it's not the piece of cake you thought it was.

I don't dismiss that you might just need some sleep and are overworked, but since you're asking these type of questions, I'd say you're probably fine.


40 something Dev here. Some things that have worked for me: eat a high fat/protein breakfast with little to no carbs. Stuff like avocado,eggs, sardines,spinach,seeds,nuts,coconut flour; regular exercise (duh); supplement a good omega oil; Lions mane mushroom extract; eliminate distractions;good headphones; daily meditation (TM is a good place to start);use a knowledge manager like obsidian and write everything down in it;always think 'whats a better way to do this' because there is one


Is it possible the teams you work with build unnecessarily complicated or abstracted stuff, because there are more choices of frameworks now? And perhaps the use of those frameworks is attractive for reasons like resume development?

I find in my 50's that my level of patience for gold plating is less than what it was, and I am less _willing_ to wade through layers of cruft when I know through experience there are simpler and more efficient ways to get things done - efficient in both developer and machine time.


I'm in my 20s still, and I wouldn't make much progress on this at all without diagramming or leaving annotations on almost every line of code. Go ahead and do those things. If you don't, you could alternatively invest a hefty chunk of time into reading and absorbing the code so well you don't need to. And if you don't do that either, you're setting yourself up for failure in a way your managers probably protected you from when you were younger and less experienced.


As a lot of other people mentioned here, it's probably have nothing to do with your cognitive abilities, but rather with your emotional state.

Recently, I found out that stressing my body can "reset" my mental and emotional state when I'm in a bad spot (similar to what you described).

I stress my body by doing a physical activity (like running or cycling) or going on a diet (skipping 1 or more lunch). I'm trying to do the opposite of what I feel I want to do (eating more sugar-stuff and doing nothing).


Practical tip: many editors will track call stacks for you. In VIM it's ctrl+[ (go to definition/push stack) and ctrl+t (return from definition/pop stack). I assume vscode and others have similar functionality.

There might be some setup to make it work with any given editor (including vim) but it's worth it because it provides an immediate productivity boost - if you forget where you are, you can 'pop' the stack, check it, then 'push' back down to where you need to be.


Gut bacteria. There's a growing amount of research that points to your microbiome as controlling a ton of your hormones to the point of if something shifts (which is easy) it can cause brain fog. Don't take antibiotics however, that will upset the stack. Look into probiotics such as B. Longum and Helveticus. There are a few other probiotics - don't just get yogurts, you have to MAKE your own yogurt and flush out the old by overwhelming your system with the bacteria YOU want.


If you're interested in it, you still can do it. And coding required many hours STRAIGHT of uninterrupted time to dive deep. Something that you get less and less of as you get older. Plus the distractions (Hello Hackernews).

I have a list of passion project ideas. When there's a new hot technology/language I want to learn, I apply it to one of my passion projects and it becomes more directed and focused on a goal and it goes a lot better than just goofing around aimlessly on a new language.


Yes! Never underestimate the role of distractions, especially in this day and age. Social media, news sites with a steady flow of 'new' information, 10-15 second videos you can endlessly scroll thru, etc. All of that can be fun, but it will play a role in taxing your cognitive capacity.

Not everyone agrees with it, but I highly recommend checking out the concept of 'deep work' (and the book of the same name). There's nothing new about the concept, but there's a definitive history of folks who have embraced the uninterrupted time approach that have been successful with it.


Like you, there were things I could hold in my head when I was younger that I cannot now. However, thinking back, it probably had more to do with the fact that when I was younger my other knowledge was less useful to anyone so it was unlikely I'd get interrupted. Now, I get interrupted much more frequently.

Might it be that the people making progress are less interrupted? Also, this sounds like it might be a place where pair programming would be more efficient than two people working alone.


I won't comment on your particular example, but i've definitely witness a good side : you'll immediately spot code that's a bit too clever for its own good.

I have recently tried to raise the bar on my designs and being older is definitely a plus. Not only do you have the previous experiences to user as a reference, but the amount of energy you'll need to fit everything in your head means you'll instinctively accept the effort if you feel like it's worth it.


I’m 26, for context.

When I use to eat sugar like a madman, I use to feel just like you, so perhaps there could be other factors impacting your mental sharpness.

I have a few questions for you to answer to yourself:

1 - How fit are you? (Cardio and strength) 2 - How is your sleep? 3 - How often do you practice programming / play with greenfield software projects outside of work?

There could be more questions, I am not a specialist, but I have felt just like you described when I use to eat more sugar-based food than I was supposed to.


I sometimes feel like that, but I don't think it's anything to do with age.

First factor: having kids (or replace with any other adult stuff). It takes a lot of mental and physical energy I could just use for other things before.

Second factor: As Oscar Wilde said, "I'm not young enough to know everything". Many years ago I would have an opinion, off the hoof, about everything and everything seemed simple. Nowadays I tend to think things are rarely as simple as they appear.


What helped me a lot was to regulate my caffeine intake. I consumed way to much, that it wasn’t helping me with my energy levels. Caffeine also takes about 8h until its gone from the body. So it effects your sleep quality as well. Now I usually drink one decaf coffee in the morning (decaf has only about 20% caffeine from normal coffee). When I need to focus on important tasks (like no meeting days or private projects) I drink a coffee and it helps me a lot.


Im 32 and feel have felt the same way on and off for a couple of years. I think it's 70% burnout and 30% just not being interested at all. To make progress, I have to write integration tests that use the API, and then implement it call by call. It gives me a clear goal and a failing test, and I can even compare the results with the original API. At least I find I can keep making progress using this approach, even if I have a bad day or a bad month.


Sounds like Diet. Eat stuff rich in nitrates (spinich) and do some cardio to get the oxygen and blood flowing. I'm 41 and that trick has a noticeable impact for me.


I am nearing that age, and personally I find its a factor of motivation more than anything. I got really excited about a side project last year and smashed out more code than I had in years. Refactoring an api for work doesn't sound super exciting. When I don't care, my brain doesn't care as much either.

If you do not believe that is a factor then examine your sleep and physical fitness. These things factor a lot more into brain function as we age.


It might be worth seeing somebody; you may be suffering from burnout or depression. 40 is not the age you'll see cognitive decline; rather, in many situations, you will begin to approach peak mastery. That's not to minimize or say that you may be experiencing some kind of true decline; rather, it's that I think it's potentially more probable that it's something else. I am of course not a trained medical professional.


I know we as programmers tend to be obsessed with our mental abilities, but statistically speaking you're about 30ish years off from the average timeline of mental decline. In times like this you need to take a few steps back and see what's actually taking up space in the back of your head. Usually in cases like this it's burn out, stress etc that people don't notice until they try and feel what's weighing them down.


38. Sounds like normal dev work, nothing to worry about.

I had to pick up some work using something called OPA open policy agent, horrible. It took 3 senior devs on a call together something like 4 hours and we were all struggling to understand and debug this code. Horrible to work with and understand. It's taken me double the estimated time to work with it.

For your work I'd probably be looking at the requests and responses then trying to fill it all in from there.


You might also be bored out of your mind. The first couple times you saw such badly designed and implemented big balls of mud you might have found it a welcome challenge of some kind, something to prove your skill among your peers.

Now, after having attended conferences, after having read the books and admired the best codebases, those developed in companies than care and are proud of their DevEx; now you see it for what it is after all, shovelware.


I’ve felt this too in my 40s. I generally don’t recommend books that might be considered self-help, but a recent book by Arthur Brooks called “From Strength to Strength” was really helpful for me to understand what’s happening to me, and how to embrace the use of crystallized intelligence in my later career. If that doesn’t interest you, you can find some interviews with him about the subject and book in a few places by search.


If it helps anything, I'm 30 which is supposed to be peak cognitive ability. During some days / weeks I have that exact feeling. I think it's a mixture of cognitive bias (you probably don't remember all the "easy" things you struggled with 10 years ago) and that it's completely natural to have periodic ups and downs in your cognitive abilities. On some weeks I'm just not feeling it.


I feel this. I've found there are a number of possible causes. The most common one with the biggest impact is not getting enough quality sleep, as sleep quality often declines as you age and under stress (life is most stressful in your 30s and 40s). Restrict your caffeine intake and improve sleep hygiene, it makes a big difference, as poor sleep affects short and long-term memory, cognitive speed and mistakes.


How are you breaking this problem down? I'd suggest stubbing out the endpoints as a skeleton with their respective HTTP verbs so the API contract is what you start with.

Then pick an easy endpoint and start to implement the code. Follow this through for the rest and add tests as you go. You'll probably want to adjust some of the app structure and maybe do small refractors to help keep things organized when you get there.


I discovered that if someone tries to do something that has abstractions and multiple branches (not in a Git way) and tries to put everything in his head -- will be fail. So my solution for that cases is: take notes, create flow diagrams, mindmaps, anything you feel good with and you'll see it clarify.

Of course some tasks are bored and we don't want to do so we loose focus that doesn't mean mental ability.


I read a study that programming skill improves with age. And another that cognitive decline doesn't really happen until the late 60s if then.

You might have some decline in motivation due to other reasons, not least anxiety about aging!

If your colleagues who are enthusiastically porting that API were the same age as you, you would attribute your lack of focus to something else. There is no reason to latch onto age as the explanation.


"I struggle to hold more than about 2 levels of this call stack in my head. By the time I'm down in the weeds I've forgotten what I'm doing, what the purpose of the actual API call is."

I started using paper notebook/pencil to go down function call trees.

It helped me immensely.

I am in my late 40s and as another commenter mentioned this could be because we have more responsibilities and not necessarily cognitive decline.


How's your diet? Do you take any supplements? Do you have stressful things going on in your life? Are you bored with your job? Maybe your brain doesnt want to do it anymore. Diversify your activities? Do something with your hands, paint, sculpt, woodworking? Something very different. I went back to college to study programming when I was 40. I don't think it's age related.


Are you physically active? Do you avoid sitting for longer than an hour at a time? Do you limit your intake of high-carb food like bread, pasta, rice?

Your glucose metabolism and aerobic fitness start impacting cognition long, long before officially crossing any diagnostic thresholds, and it's usually the middle age where our frequently poor lifestyles start impacting us.


Been feeling this though I'm not 40 yet, fairly close though. What's helped is exercise, eating well rounded meals, getting good sleep, and knocking out health issues that I was either aware or not aware of by getting regular checkups.

Sounds cliche, but def a list to keep in mind and check off if you haven't. Even just a single 20-30 min workout makes a sea change in cognitive functions


Maybe Code Browser helps, it can link to positions in the document. So you can write down the precise call stack.

https://tibleiz.net/code-browser/index.html

That said, I am also currently in a hole, can just not look at code. Make yoga, eat healthy, sleep enough, let the sun shine on your head.



Clean your office. Seriously. All the little distractions and annoyances around us eat a serious amount of brainpower that _is_ shared with the brain chunks needed to do deep coding work.

Every time I find myself unable to focus beyond a shallow level I invariably find that I've let my mental and physical environment slowly go to shit and I'm running at 1/3 capacity because of it.


I doubt it's age related. There could be medical reasons for it, sure, and perhaps checkin with a doctor, but for some definition of 'normal' you aren't going to decline at all at 40. Likely more social, emotional, psychological reasons are the cause. Determining what that is, of course, isn't particularly easy, i'm guessing. Good luck to you.


I'm 39. I don't feel like my coding ability is declining, but my ability to give a shit when people keep reinventing the wheel and repeating past mistakes is declining extremely quickly.

It's not that I can't code, it's that work is just making me not want to code. I'd rather put time into playing fighting games while my fingers still work, if anything XD


Hey, I always tried to avoid leveraging my memory when doing tasks.

It's fine to hold no more than 2 levels of call stack in your head. Most devs have a very hard time tracking more than a couple of variables.

What I can tell you: write lots of notes. Break the problem in smaller ones and take notes about the problem itself. You don't need to "hold" anything in memory, write it down.


I've observed something similar, and agree with so many other citing COVID as one of the reasons. I just have to think on things for a lot longer than before when I'd get solutions much quicker. This started happening after covid. I don't have any other obvious 'long covid' symptoms, but I can feel the mental ability decline.


I turned 40 this part March and for a while I felt the same way. "Oh gosh, I'm losing my neural plasticity at a rapid pace!" Nope! I was just having a mini crisis of self-perception based on an arbitrary number and once I got used to being 40 my mental acuity magically returned to me. I suspect the same will happen to you.


Whens the last time you had a check up? There are lots of things that can cause brain fog. Lack of exercise, sleep apnea, etc.


I'm going to assume you are male. If not, disregard.

Get your blood work done.

I know this may seem unrelated, as we often think of testosterone as related solely to muscle development and sex, but it's far, far more. It is very important for cognition, focus, and mood. Further, the estradiol produced from aromatization is highly neuroprotective.

Check your levels, just in case.


Is it just this API, or do you struggle with other coding tasks too?

From your description, you want to deeply understand the functionality to make better porting, which is what I expect from a senior developer.

Also, this might be a boring project, not triggering any mental reward for accomplishing it.

I would focus on your learning pace for exciting topics to measure mental abilities.


Open excel spreadsheet, paste function, when in this function another is being called, paste it and draw an arrow to it. Now, you have both of them visible. You can navigate stack going along arrows. Add comments, or colors. Spreadsheet is almost infinite 2D canvas. It is not my idea, I stole it 14 years ago from my work peer.


Mental abilities may decline if you have other health issues.

Be especially weary if it becomes difficult to read an analog clock: https://yourdementiatherapist.com/alzheimers-dementia/what-i...


Do not underestimate that holding the problem in your mimd is part of the solution. You have the answer in your question i believe. I do not see the reason to try to compare to a past you (something that i find myself doing too… mmmh) find the strategies that work for you and stick to them. Good luck to us the old people :)


As an "old" programmer who's still in the trenches, my secret to working around this problem is to take notes as I work. As you map things out, write it down. As you collect state/call stacks while debugging/tracing, write it down!

It's WAY easier to just consult your notes than to try to remember everything.


Maybe it was just implemented with too much abstraction, which can make things more confusing.

Instead of porting it as-is, rebuild it with the actual functionality required and throw away the overly abstracted parts.

Oh, and I echo the other guy: make sure you have a test harness that validates everything, so you know if you've done it correctly.


I know how you feel. I'm a bit younger at 38, but I can feel it as well. It started around mid-2020 for me. I'm not sure whether to chalk it up to covid, or depression, or natural aging. I hope it's not natural aging, because I can lose my muscles or my youthful appearance, but I cannot lose my brain.


Everything I would have said is already here in other comments, so I’ll just say +1. I’m 44 and had a period around 40 where I thought this was happening to me, too, and I’m quite convinced it was NOT mental decline. Im doing better than ever because of just exercise in my case, though I may still investigate ADHD.


I would posit that in reality, you just don't give a fuck the way you used to.

Because seriously, you have a couple of decades to go before you hit real physical performance decline (assuming you don't have early onset alzheimer's or something)

I would also point out, that not really giving a fuck is a much more informed position...


I've experienced similar things and always put it down to boredom. My younger self might still have found it interesting and novel. Now I just view it as a chore. I've lost some of that intrinsic interest which I think contributes. If I work on more interesting problems the issue is less pronounced.


I started writing code full time at age 38. I turn 60 this year, and I feel like I'm going strong. I might have lost a half step. I guess I won't be writing code at 70.

It's possible I'm unique, but I don't think so. I wonder if you're just distracted or perhaps experiencing burnout.


the podcast "future of code" recently did an episode discussing the paper "programming as theory building."

maybe it's just because i listened to that podcast last week, but it sounds like you don't have the theory of the api you're porting. by theory i mean an intuition of what the software is, what motivates its existence, what it ought to do. to define the term "theory" by an example from the paper (or possibly from "the concept of mind" by gilbert ryle, referenced by "programming as theory building"): you don't have newton's theory when you can answer a question that he answered the way he answered it, you have newton's theory when your answer to a question he wasn't ever asked is how he would've answered.

so this notion of theory means, first, you can never record a theory. you can't write it all down. to have the theory means you can apply it to any new circumstance that arises, so you can't just write it all down, because you'd be writing forever. a theory is knowing how to respond. the impliction for software is that the code and documentation can't communicate the theory of the software. a theory can't be communicated at all, it has to be acquired.

so how does one acquire a theory? how'd you learn to read? how'd you learn to write? how'd you learn arithmetic? theory transmission is a social function. people with the theory show you, teach you, guide you in forming the theory for yourself.

the conclusion is that software firms should put a lot of effort into retaining people who have the theory of their software, and put a lot of effort into transmitting that theory to new people. that's not the world we live in, is it?

actually, i think that conclusion applies to any business, yet onboarding is terrible everywhere, and workers are treated as interchangeable.

what i'd be asking myself if i were you is who has the theory of this api you're porting, and how much of their time can i get?


I don’t know if it applies to you, but this post from a couple of days ago on HN might apply. People pretty much said to stay away from weed, and I’d alcohol:

https://news.ycombinator.com/item?id=34279527


For me the checklist would be:

1. Sleep quality 2. Nutrition quality 3. Exercise 4. Lifestyle

First make sure that all the above is in check.


My first question would be: how do you sleep? In terms of enough hours but more importantly also the quality of your sleep. Find a way to measure it if you don't know, and of course be brutally honest with yourself.

Sleep is a game changer in cognitive abilities and it can swing either way.


At 40 you should still be sharp, it seems hard to me to accept this is natural cognitive decline.

Had you have COVID? Some people, including myself, have shown long term cognitive effects after it. It took me about 6 months to get back to normal.

This can also be purely psychological. Talk to a doctor!


A lot of people have B12 deficiency, and I'm sure there are others which affect cognition. Maybe have your GP run some relevant blood tests?

You can buy sublingual oral B12 supplements OTC if you want to just try and see. The methylcobalamin form seems to work better than cyano FWIW.


I'm almost 40 and I'm much more aware of the circumstances when my mental ability are worse. If I want to be at my peak, sleep well, not have breakfast, drink a cup of coffee. Under these circumstances I think I may have better mental ability than 10 years ago.


Any chance you've got little kids or for some other reason are not getting enough sleep? Lack of sleep can be very insidious because you can get to the point where you don't notice it anymore except for maybe a vague feeling that you're losing your edge.


I'm 40 too and haven't felt more sharp in coding anytime before. However I started to code in my early 30s so maybe it contributes here somehow. It sounds like the task you have is a misfit for you or the code you have been given is way worse than you think.


38 years old here. For me it depends on the work type. If I need to rewrite someone's API, I will struggle because the code is written by someone and his logic not obvious fir me. If I would write the same logic from scratch by myself, it will be much easier.


Don’t hesitate to change your work style to include more quick notes and simple diagrams scribbled down to keep your mental stack at a minimum. This helps a lot, it’s maybe unnatural at first to get used to but it helps to keep your mind more focused and calm.


I'm in my 30s and feel my programming skills have been slipping. I feel very similar to you. I'm struggling to replace one api call with another due to not understanding the previous implementation and dealing with the interfaces/abstraction.


As I age (going to be 59 soon) my programming abilities just increase (along with my waistline, unfortunately). I even went back to school and finally got my master's degree in 2016. So, maybe see a doctor? There might be a legitimate medical issue.


Sorry for your situation.

I'm sure you will be okay later on because that has nothing to do with your age or cognitive decline.

You can be physically stronger and "brainly" faster and more effective than any man younger than you as long as you keep exercising/coding.


"I can't seem to hold more than about 2 levels of call stack in my head"

you should try writing things down! Like, keep a notepad around. I have trouble with this sometimes and writing it down reduces the number of things I have to keep in my head.


Are you doing more than 1 job at a time :)? If yes, that might be because you don't have enough time. So give it more time and you'll be fine (remember that you need 9 months to create a new baby no matter how many women you have :) ).



Exercising helps with neuroplasticity, think of exercise as investing in your future cognitive self. Adequate butrition and full nights of sleep will all help you rule out these areas that affect us more cognitively as we age. Good luck!


My recommendation is to use pencil and paper. Plot out the tree of function calls and refer to that. Your brain may be busy doing other things which may ultimately bring insight to the API porting so I wouldn't worry about that.


I found immediate relief to fatigue from BCAA(branch chained amino acids) and I got no major extra benefit the next day so it must have been my diet. Certainly going to keep taking BCAA I get so much energy. Great thread overall !


Experienced the same. Got quite severe. Turned out to be a few things. Autoimmune and heavy clotting the biggest.

Changing my diet dramatically, d3/k2 magnesium, Vit e, omega 3s, and blood thinners cleared up my mind.

Also exercise is absolutely critical.


It may be nutrition or some stress/anxiety/sleep issues etc Get a blood test, get a psychological assessment

My bet is Vitamin D deficiency - anything below 30 ng/dL is borderline 80 to 100 is best for longevity and cognition.


There’s also the fact that programming is getting harder, mental decline or not. Things were very simple when I started programming professionally in 1980. You could understand everything about a system, hardware and software.


Have you looked into CPTSD? Some people are able to hold it together for a long time but eventually the mind starts to fray and focussing becomes almost impossible because the chaos catches up with you... or me in that case.


Visual schemas and sketches help greatly when dealing with complex deep abstractions. There is no need to keep it all in your head all the time. Just summarise the architecture in a visual way which can be fast to look up.



Your brain needs assistance, write down your thoughts as you debug and inspect the code.

It doesn't matter if you never look at your notes again, their use is the short time after you write them

Notion or Obsidian work for me.


You are 63% of my age (there's a coincidence there, do the math).

A point I haven't yet seen in the comments: how much the advancement of civilization owes to 20-30 somethings. Take The Beatles, Alexander Hamiliton, even Anthony Fauci (who had the rare reprise late in life) as examples. At around 40 I gave up any illusion I might do something illustrious, and accepted that from then on, I would just work for a living. My best work became my children, and I'm happy to have done that.

Many of the other comments line up with my own observations at this sage old age:

* more distractions (my house seems to be aging much faster than me, and taking up much more time to maintain)

* bigger responsibilities (more savings to manage with less time until retirement to fix investment errors, offspring where simple existential needs like food and diapers have been replaced by tuition, aging in-laws with real decline issues like eyesight and bad joints)

* less energy. true, and most especially I can't skip sleep like I could 20 or 40 years ago.

* burnout ( this stuff does get old, and "boring" as noted by one commenter)

* underestimating the value of my experience. Not writing that really clever code when a simpler solution will suffice, for example. The ability to tell people a realistic estimate of work, not my old optimistic "couple of days" estimate that was almost always 10x short

* ADD, not helped by social media (stay off it when working, or always) and a trying to ignore the constant stream of news (except HN of course lol). But a great help in being open to new methods where I find myself evangelizing about git to people half my age.

* exercise, fitness, diet: need to up my game after covid isolation and increasingly creakey joints. It does make a difference. In my case living in The Big Easy doesn't help.

* Did I mention sleep? Why yes I did, forgive my forgetfulness....no, actually I put it here intentionally because it is that important. Exercise helps with getting quality sleep.

I am still writing code and I "provide value" (their words) in that I can solve complex data analysis problems that come to me after co-workers reach the limits of using vlookups and pivot tables in Excel. I'm not the fastest and I'm always fighting imposter syndrome, but that's quashed whenever I catch a glimpse of production code written by pricey consultants and realize they make the same mistakes and use truly ugly workarounds even I wouldn't consider.


So I experienced this as well at that age. I would recommend looking at your sleep and diet patterns. After that look into Testosterone Replacement Therapy, this was life changing for me in my 40’s.


IMHO think its possible that you are disinterested in the task. I am at about the same age and have been increasingly finding it difficult to concentrate on tasks that don't help me learn much.


I’m 50 and I feel in better cognitive shape now than ever. I’m wondering if there is something else going on with you than old age cognitive decline. Maybe you should check with your doctor?


As we age our bodies change.

Try working for 3 weeks without alcohol or coffee intake and see if that makes a difference. Then slowly reapply.

Its not that the older engine is broken but it does require different maintenance.


Another N=1, but I'm past 40 and feel that I'm a far better programmer/thinker than I've ever been in the past (I've been in software dev for >20 years).


I just turned 56. Yeah, my energy levels are lower, but I think I am just more jaded with technology and don't get has excited about "new" technology as I used to.


Its just doubt - in this case self doubt. - Assume its true - will these thoughts be beneficial? Assume its false - will these thoughts be beneficial?

There might be other questions worth asking.


Do you happen to have small kids? They soak up so much mental energy which combined with less/worse sleep definitely makes things a lot harder than they used to be.


You sound like you are very tired. Your mental capacity will take a hit, regardless of age. Try to address that by taking some vacations (if you can), and getting some exercise.


That sounds more like a lack of interest combined with unintuitive names/abstractions than anything. Try drawing diagrams to visualize the flow and structure of the code.


Man you look more depressed than under cognitive decline. Maybe you should look around this issue, or seek assistance and try to see why you're feeling so low.


If u re like me and got nerd neck, blood flow to the head could be impaired.

The inside of my mouth feels constantly cold. So I know I got an issue, but appointment is in march.


Why try to keep things in your head? Make notes on a piece of paper, or in a text file as you go. I find that this helps tremendously with non-trivial tasks.


Seems unlikely to really be about cognitive decline but if you think it actually is then get checked by a neurologist. Early onset dementia is a real thing.


If you want to improve your cognitive function and you drink alcohol, stop drinking. I stopped 8 years ago and felt more mentally alert within a few weeks.


40 seems early for a "mental decline" (or so I'm telling myself at 38), but maybe consider a full checkup? Physical and mental maybe?


I've always felt like this. My short term memory is a bit of a mess. I blame drug abuse when I was younger. Anyway I get by with pen and paper.


Supplement vitamins B1, B2 and B3. You might have hit a common deficiency presenting itself after 35+. Your neurons/glial cells need a support.


I am 46 and on "intermittent fasting" right now and it is great for this. Mental clarity is so noticeable. I feel younger. YMMV though.


You should eliminate bad sleep as a potential cause.


Check if you have sleep apnea. Do you wake to with a headache that goes away?

The sleep apnea damage is permanent, but you can stop it from getting worse.


No. You are not declining. You just need a break. Go out with friends. Do some Sports, socialise. Take oxygen. I am 55 and still ok.


This happens to me when I’m trying to force myself to do something I do not want to do.

Maybe I’m making myself subconciously incapable of doing it.


Something has changed. Could be an indication of a serious underlying medical condition or nothing at all. Go get checked out.


COVID? If so take it easy, it will get better over time. If not, ask older family members if they experienced the same thing.


Go into custom development. In that area, the dumber you are, the more you make because you get closer to your clients.


Not to create unnecessary paranoia, and the odds are low, but there is a possibility of early onset alzheimer's...


How is your sleep? If you’ve gone years without good sleep, the damage could be accumulating into cognitive functions.


I am 54. I am now working with Go and Flutter. It's not as good as when I was a 40 year old young programmer.


As someone pushing 40 myself it feels like my hacker chops go up and down almost directly with my diet and exercise.


What? Next months I will be 41. I just got into this industry less than 3 years. I am afraid I will be like you.


I am 54. Programming in Go and Flutter. It's not as good as when I was a 40 year old young programmer.


I did a project during my PhD with a 70year old who coded way better than almost half a century younger me…


Have you been working from home for the last 3 years? Less social interaction could contribute to this.


With a 45-year-old Tom Brady still leading teams into the playoffs, I think this is a bad argument. If you think you're experiencing a cognitive decline at 40 you should see a doctor. Physically, yes your healing abilities aren't the same as when you were a teenager but the brain is different. Talk to your doctor about this before you make any life-changing decisions.


Start by making integration tests that test each and every little behavior of the existing API.


Are you overweight? Are you taking any medication? Both of these can affect your cognition.


I've heard more and more people talking along the lines of people feeling mentally not all there. Part of this might be the natural course of aging and being distracted by more life responsibilities that come with age. I know a lot of people are leaning heavily into the idea of long-Covid as an explanation(which I think is real, but quite likely overblown, but this isn't a Covid thread so I'm not going to go into that further)

My personal thinking is that there's a lot of social malaise and hopelessness that's affecting people mentally right now for these and possibly other reasons that's contributing to this mental fog. People are checked out right now.

> Whether you're very scared of Covid or not the least bit scared, everybody is frustrated with still dealing with it and the measures they have to go through.

> Prices of everything are going up, layoffs are happening, and there's a general sense in the air that the economic calamity that's possible is just getting started and there's nothing you can do about the coming bad times.

> For lots of complex reasons, one of the biggest traditional sources of joy (people creating families) has been plummeting and possibly getting worse in this time period.

> Everybody, regardless of political idealogy, has some big topic to feel hopeless about. Some people think the world is ending due to climate change, some people think the world is ending due to Putin, some people think the world is ending due to economic migration, etc. This is subjective, but there's a limited real aspirational message of hope for the future that most could agree with and see unambiguous positivity from.


Anecdotal, but I have found that doing pull ups regularly has major cognitive benefits.


I hit this, but found that changing my diet, and doing more exercise really helped.


It could also be diet related. Are you eating healthy, getting enough exercise?


I learnt how to code at 40. Its not you getting old. Its just you burnt out.


Instead of posting on HN about it, spend some time working with the problem.


I'm 60 and my decline is not as bad as you described. Consult a doctor.


Have you considered a sleep study? Brain fog is a common symptom of apnea.


> I can't seem to hold more than about 2 levels of call stack in my head...several layers deep...call stack in my head.

This describes me (early 40s but I was always like this) so I just write it down in a notebook. There's no advantage in trying to keep everything in head when we can use well tested tools.

As such, do know that porting API is tough in best of times. It's not easy to just walk into it and understand, let alone replicating the functionalities in other language. You are trying to pull off several things at once.

I'll also repo my earlier comment verbatim[1] where I offered my suggestion to someone in similar situation.

It's beneficial to approach learning about an API top-down and bottoms-up. The context in which the API operates and then the working of the API in itself. Imagine if you were in charge of maintaining a hardware tool. I first want to know how this tool is used by various customers before learning how the tool works.

1. Begin by learning all the end-to-end product flows this API is going to be invoked within. This is the context in which your API is operating in. It also sets the stage for non-functional requirements such as latency, and availability requirements. How will end customer and business be impacted if this API were to misbehave?

2. Next speak to all the customers of this API. How do they produce the data for your API's inputs and how do they consume your API's output. You will be surprised by all sorts of creative ways in which an API gets used, not necessarily what the API was intended to begin with. But you need to support all those clients so better get to know their use cases. Also, understand how they handle your API failures. The consumers tend to make unstated assumptions about input/output validations and invariants. It's not documented anywhere but floats around as tribal knowledge. Extract that knowledge and document it somewhere. Make sure you are very clear about every single input parameter, how it's produced and its expected values as well as every single output parameter and how it's consumed. Don't forget about exceptions. Often times customers treat exceptions as just one of the expected output parameters and so actually depend on the API throwing that exception.

3. Finally, take a look at the API's implementation. Don't get frustrated if you don't understand more than 50% of the code. It's perfectly fine. Make notes of the parts that make sense and also note down those questions. Ask around. Often some parts makes absolutely no sense to you. But it is there for a reason, someone as competent as you put it in the first place. Again, ask around both within your team and the API's clients. Pay attention to the API's downstream dependencies and how their failures are handled and bubbled up to your clients. Your API's SLA depends on your downstream APIs, learn about them and ensure that it matches the expectations.

4. You also have indirect consumers of your API who depend on the side effects produced by it. Make sure you learn about them. If this API causes a side effect (such as DB update, publish a message to Kafka) then learn how those side effects are consumed. Does someone depend on it? If yes, how? Though I've described these steps in sequence I find it useful to approach all of them in parallel and over multiple iterations. At first everything is blurry and after first pass you penetrate through about 10% of cloud cover. After 4th or 5th pass you will have a reasonable understanding (~85%) to make small bug fixes.

[1] https://news.ycombinator.com/item?id=25944265


oof, i feel you. when that happens to me, i tend to wish for the code to magically turn into a graph... which is when i fire up bouml or whatev and try to draw a diagram to help me in my quest

best of luck to you


Hi, I think it is perfectly natural – as others write here :) But still, you can do a lot about this. I am 50 and I feel even better than in my forties. We have three kids, I run demanding business (book publishing in small country) and I have many other responsibilities.

My way to improving has been pretty long (10 years of trying) but ... TLDR: I started to be more physically active, including strength training, completely overhauled my circadian – sleep habits (I sleep 10x better than years before). I suggest to follow Peter Attia and read books from David Sinclair, Satchin Panda, Matthew Walker... It pays off. :) Keep going, you can improve your mental abilities again.

PS: Last year I started to learn Clojure (I am not programmer, I just love it as I feel like functional languages are like poetry:). Yes, it is not easy, but I hope my first simple and useful app will be out and public this year. Just for fun.


first do these: zone 2 & 3 aerobic exercise, meditation than add these: lions mane, rosemary, common sage tea if adventurous these too: semax, pigs / lamb brains


exercise.

interesting book to read: https://smile.amazon.com/dp/0316113514


I just came to say that the comments here are pure gold.


Might I recommend regular cardio and a nutritional diet?


I feel it too. And I'm about the same age.


I'm 46 and I'm at the top of my game.


Do it bottom up, not top down.


time to move into management, no need for much cognitive abilities there.


Sleep, exercise, chess


In my case it's sleep, exercise, and learn new languages.


48 , and feel smarter than before


Draw a diagram?


draw it out on paper.


Time to start nootropics


[deleted]


Lots of good advice in this post. I have just one addition: get a mental math app. Practice each day, this seems to help for some reason, possibly because it relies on using your working memory.


Are you getting enough magnesium? I know this is just some guy in the internet, but you may as well give it a try after you talk to a doctor. I take it, and I have noticed a distinct improvement in my sharpness, so to speak. Perhaps clarity might be a better descriptor.

Anyhow, good luck!


Use chat gpt :) and get blood work done.




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

Search: