HACKER Q&A
📣 Buttons840

I'm 40 and feel my mental ability declining. Programming seems harder.


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?


  👤 jb1991 Accepted Answer ✓
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.


👤 pentaphobe
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


👤 jwr
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.


👤 cr3ative
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.


👤 Starwatcher2001
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.


👤 lukehutch
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.


👤 xnorswap
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.


👤 fileeditview
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.


👤 cjbgkagh
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.


👤 aeschinder
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...


👤 404mm
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.


👤 markbnj
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.

👤 brian_cunnie
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."


👤 alfonsodev
> 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.


👤 foxyv
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.


👤 jesuscript
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.


👤 sheepscreek
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.


👤 jcpst
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.


👤 subharmonicon
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.


👤 markus_zhang
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.


👤 kennethh
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.


👤 jgrahamc
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.


👤 dkarl
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.


👤 matt_s
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.


👤 randomh3r0
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.


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


👤 kardianos
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.


👤 chadlavi
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."

👤 tptacek
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.


👤 darthbourbon
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)


👤 wonderwonder
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.

👤 semireg
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.


👤 weatherlite
> 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.


👤 michaelrpeskin
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.


👤 thesz
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! ;)


👤 cultofmetatron
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


👤 thiago_fm
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.


👤 gritcrit
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?


👤 algem
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.

👤 flippinburgers
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.


👤 anonyfox
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.


👤 caned
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!


👤 agentultra
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?


👤 gernb
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.


👤 vegancap
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.


👤 Arisaka1
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.


👤 dmos62
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.


👤 naltroc
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.


👤 fbnlsr
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.


👤 sherilm
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/


👤 jrwoodruff
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?


👤 EdgarVerona
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.


👤 college_physics
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.


👤 juancn
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.


👤 RcouF1uZ4gsC
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.


👤 wusher
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.

👤 pmarreck
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.


👤 graderjs
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?

👤 habibur
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.


👤 humps
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!


👤 mooneater
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.


👤 allisdust
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.


👤 jedberg
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.

👤 sky_fan
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.

👤 nashashmi
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.


👤 mattbdc
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.


👤 aristophenes
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.


👤 Dowwie
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.


👤 pnf
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.


👤 starkd
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.


👤 kasajian
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, ....


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


👤 positivejam
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.


👤 xxEightyxx
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!


👤 asciimov
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.


👤 Alifatisk
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.

👤 recursivedoubts
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.


👤 Findecanor
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.


👤 kayodelycaon
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.


👤 Brajeshwar
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.


👤 0xmarcin
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.


👤 optymizer
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!


👤 vaughan
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.


👤 mgkimsal
> 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.


👤 okl
> 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.?


👤 captainbland
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.

👤 aidenn0
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)


👤 fnordpiglet
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!


👤 rr888
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.

👤 kvathupo
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 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 content_`. `AnyModulePlaceholder` is defined in `any_module_holder.h`. Its `clone_module()` method calls `clone()` on its `std::shared_ptr 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`.

```


👤 abavatar
+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


👤 usgroup
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.


👤 gwbas1c
> 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.


👤 spandrew
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.


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


👤 taterbase
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.


👤 AnEro
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.


👤 Udo
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.


👤 eigenvalue
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!


👤 cfeduke
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.


👤 danielrpa
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...


👤 runjake
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.


👤 JeremyNT
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."


👤 jasmer
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.


👤 smnscu
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.

👤 neilv
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.


👤 dceddia
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.


👤 EGreg
”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.


👤 talkingtab
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.


👤 qbasic_forever
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.


👤 linuxftw
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.

👤 neycoda
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.

👤 NDizzle
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.


👤 drited
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.


👤 AnimalMuppet
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.


👤 spoonfeeder006
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


👤 stronglikedan
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.

👤 gregoriol
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.


👤 throwaway0asd
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.


👤 jamil7
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.


👤 surume
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.


👤 brokencode
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.


👤 brailsafe
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.


👤 antirez
Don't underestimate the fact you likely don't care about what you are doing.

👤 cbeach
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.


👤 MollyRealized
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.

👤 aternal
"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.


👤 coldcode
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.


👤 CodeWriter23
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.


👤 ranting-moth
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.


👤 diegoperini
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.


👤 VyseofArcadia
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.


👤 pier25
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.


👤 miqueturner
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.

👤 jmartrican
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.

👤 HarHarVeryFunny
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.


👤 wstuartcl
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.


👤 giancarlostoro
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.


👤 twowatches
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.

👤 simmo9000
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...


👤 mrleinad
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.


👤 morog
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

👤 bsg75
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.


👤 cnees
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.

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


👤 GrinningFool
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.


👤 coding123
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.

👤 johnla
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.


👤 troupe
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.


👤 bsaul
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.


👤 mr90210
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.


👤 rvieira
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.


👤 obrhoff
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.

👤 javier2
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.

👤 pookha
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.

👤 victorvosk
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.


👤 rabi_molar
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.

👤 fzeroracer
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.

👤 jwmoz
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.


👤 eecc
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.


👤 tpool
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.

👤 Spiwux
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.

👤 naasking
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.

👤 cdnsteve
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.


👤 vando
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.


👤 rendall
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.


👤 senthil_rajasek
"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.


👤 semeliussemper
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.

👤 Llamamoe
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.


👤 throwaway743
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


👤 nilslindemann
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.


👤 aappleby
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.


👤 mbfg
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.

👤 OOPMan
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


👤 epolanski
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.


👤 piyush_soni
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.

👤 biggestlou
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.

👤 weberer
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.

👤 caeril
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.


👤 Oras
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.


👤 majgr
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.

👤 mensetmanusman
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...


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

👤 eschneider
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.


👤 manv1
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.


👤 danielvaughn
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.

👤 thomasqbrady
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.

👤 johnea
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...


👤 nprateem
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.

👤 timtas
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.


👤 pasquinelli
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?


👤 DougN7
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


👤 WmyEE0UsWAwC2i
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.


👤 fleddr
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.


👤 gcj
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!


👤 pengaru
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.


👤 mbar84
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.

👤 stdbrouw
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.

👤 jarek83
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.

👤 goodgrief99
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.

👤 Isamu
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.

👤 giantg2
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.

👤 g051051
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.

👤 begueradj
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.


👤 catherinezng
"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.


👤 dxxvi
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 :) ).

👤 agrimonyhal

👤 sizzle
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!

👤 itronitron
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.

👤 aapotahkola
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 !

👤 treeman79
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.


👤 rep_movsd
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.


👤 fortran77
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.

👤 SebKba
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.

👤 Azkron
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.


👤 amatiasq
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.


👤 wistlo
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.


👤 DamnYuppie
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.

👤 krisgenre
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.

👤 irrational
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?

👤 cap_hindsight
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.


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

👤 daltont
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.

👤 derrida
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.


👤 peterhoeg
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.

👤 haolez
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.

👤 CuriouslyC
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.

👤 soufron
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.

👤 aszantu
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.


👤 jononor
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.

👤 adamsmith143
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.

👤 dougSF70
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.

👤 id02009
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?

👤 bennysonething
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.

👤 bitL
Supplement vitamins B1, B2 and B3. You might have hit a common deficiency presenting itself after 35+. Your neurons/glial cells need a support.

👤 paufernandez
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.

👤 altcognito
You should eliminate bad sleep as a potential cause.

👤 ars
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.


👤 tmilard
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.

👤 Aeolun
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.


👤 mmaunder
Something has changed. Could be an indication of a serious underlying medical condition or nothing at all. Go get checked out.

👤 jacquesm
COVID? If so take it easy, it will get better over time. If not, ask older family members if they experienced the same thing.

👤 anovikov
Go into custom development. In that area, the dumber you are, the more you make because you get closer to your clients.

👤 gbasin
Not to create unnecessary paranoia, and the odds are low, but there is a possibility of early onset alzheimer's...

👤 robg
How is your sleep? If you’ve gone years without good sleep, the damage could be accumulating into cognitive functions.

👤 rio_m
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.

👤 benreesman
As someone pushing 40 myself it feels like my hacker chops go up and down almost directly with my diet and exercise.

👤 carlhung
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.

👤 rio_m
I am 54. Programming in Go and Flutter. It's not as good as when I was a 40 year old young programmer.

👤 nxpnsv
I did a project during my PhD with a 70year old who coded way better than almost half a century younger me…

👤 threadweaver34
Have you been working from home for the last 3 years? Less social interaction could contribute to this.

👤 Lendal
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.

👤 stewartjarod
Start by making integration tests that test each and every little behavior of the existing API.

👤 rayusher
Are you overweight? Are you taking any medication? Both of these can affect your cognition.

👤 logicalmonster
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.


👤 carlsborg
Anecdotal, but I have found that doing pull ups regularly has major cognitive benefits.

👤 matrix12
I hit this, but found that changing my diet, and doing more exercise really helped.

👤 nomy99
It could also be diet related. Are you eating healthy, getting enough exercise?

👤 wesleywt
I learnt how to code at 40. Its not you getting old. Its just you burnt out.

👤 d1l
Instead of posting on HN about it, spend some time working with the problem.

👤 donpark
I'm 60 and my decline is not as bad as you described. Consult a doctor.

👤 schwartzworld
Have you considered a sleep study? Brain fog is a common symptom of apnea.

👤 vishnugupta
> 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


👤 mlatu
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


👤 tombarys
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.


👤 rikelmens
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

👤 m463
exercise.

interesting book to read: https://smile.amazon.com/dp/0316113514


👤 makz
I just came to say that the comments here are pure gold.

👤 ingen0s
Might I recommend regular cardio and a nutritional diet?

👤 scoofy
I feel it too. And I'm about the same age.

👤 Yuioup
I'm 46 and I'm at the top of my game.

👤 mirekrusin
Do it bottom up, not top down.

👤 momirlan
time to move into management, no need for much cognitive abilities there.

👤 co_dh
Sleep, exercise, chess

👤 ok123456
Draw a diagram?

👤 baremetal
draw it out on paper.

👤 b34r
Time to start nootropics

👤 throwoutout
[deleted]

👤 adenozine
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!


👤 random314
Use chat gpt :) and get blood work done.