Ask HN: I'm 40 and feel my mental ability declining. Programming seems harder.
596 pointsI 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?
Comments (510) 299 threads
Earlier commentsI'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, ....
> 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).
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.
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!
All comments shown.
Couldn't load more comments. Check your connection and try again.