Lurker News
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?

Comments (510) 299 threads

Earlier comments
thiago_fm1 reply#
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.

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

What OP is trying to do is quite literally impossible. Not even the best chess players in the world can hold such a big (decision) tree in their heads _at once_. And they might be the most extreme data point we have on this matter.
The way we humans compute needs to be supported by breaking stuff apart and focus on few things at a time on one side, and by abstraction on the other side. Iterating on smaller problems and generalizing the big picture along the way.
Think forest & trees metaphor, or the 7 +/- 2 problem.
Of course as we get older our ability to completely emerge into one task and put all our energy into it generally weakens for a variety of reasons. But there's enough evidence to support the idea that regularly challenging our cognitive ability keeps us sharp and maintains or improves our ability to learn and tackle new things.
What we can't do however is fight our natural limitations and OP seems to try just that.
Additionally, and this might be just as important, this seems to be a very tedious and boring task. The worst tasks are the ones that require a lot of mental effort while also being incredibly boring. It's hard to find a high state of motivation and focus, which contributes to the issue.

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

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

gritcrit2 replies#
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?

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

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

BadCookie#
I would add that, if both sleep and exercise don’t seem to solve it, then sleep quality (e.g., sleep apnea) could be an issue, especially if a person is overweight or has other health issues (e.g., bad allergies).
algem1 reply#
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.
didericis#
I highly recommend lap swimming as a general physical/mental sharpening exercise you can do with virtually zero joint or other injury risk your whole life.

I had the good fortune of being coached for a brief period by this guy: https://magazine.wsu.edu/2009/08/11/channel-swimmer/ Having that kind of an example was awesome.
The downside of swimming is trekking out to a pool and finding a time when lap swim lanes are open, and climbing the learning barrier if you’re completely new. In my experience, a lot swimmers also tend to be instinctually quiet, standoffish and very competitive, which can be very intimidating if you’re going for a lap swim as a newbie. Especially if it’s crowded and someone wants to lane share.
But there’s almost always a time slot somewhere when it’s virtually empty, or a friendly lane sharing buddy who’s relatively new/not doing flip turns and stuff, or a friendly expert who’s casual and happy to give learners a wide berth. A local YMCA or one in a neighboring area is usually the most friendly place to start swimming, but I think a decent number of big commercial gyms have pools too, and universities/schools sometimes have public lap swim times as well. And if you’re completely new/never learned to swim, lesson instructors often LOVE private adult lessons because they actually listen/you don’t have to additionally do baby sitting/kid wrangling. I lifeguarded for a bit and taught swimming, and liked teaching kids too, but adults were so much more relaxing.
It’s absolutely worth climbing those barriers. Especially if you get one of these: https://www.underwateraudio.com/products/waterproof-ipod-shu...
I haven’t really checked the landscape post covid, though. I’m guessing a lot of places with pools got hit really hard. All the more reason to get out and find/support one, they’re a really awesome community resource.
Speaking of which, I’ve turned into a stressed out couch potato/haven’t been to a pool since covid, I should take my own advice and get back out there.

flippinburgers1 reply#
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.

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

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

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

Load more comments