back
▲ 6 points

Ask HN: How to remember programming language API details?

by deepaksurti·9y ago·9 comments·view on hn ↗
I should rather ask, does even need to remember? For example; all string functions in Python standard library or the path manipulation API in Objective C. Do you just look up as and when you need it or spend some time remembering/internalizing the API?

FWIW, I am a polyglot developer and proficient in multiple languages. I just do a lookup as and when it is needed. Sometimes I think that if I knew these API calls without having to look up, it would be even better to not break my flow?

What is your experience in this context? Any tips, tricks to remember details which helps you to stay in the zone? I looked at Anki, but won't there be review fatigue, as some Googling mentions?

Thanks in advance.

9 comments
I go once over the language reference in order to learn what it is capable of but don't bother remembering details. That's what search engines are for.
This. Read through whatever it is once to get an idea of what exists; then look details up as you need them. You'll naturally end up remembering the patterns you use most often.
I have a custom implementation of the popular “cheat sheets” idea, optimized for not leaving the zone.

My sheets are short snippets of reStructuredText. When I press Win+H, my tool pops up in a small window, asks me for a keyword, and then displays, one by one, every sheet that contains the keyword. I can press Alt+N to show the next sheet. I can press Alt+C to copy the current sheet’s last paragraph into the clipboard (this lets me mix explanatory text and code in one sheet). The text is also navigable with a caret, so I can select and copy arbitrary pieces. When I’m done, I press Win+F12 to close the window.

Check out Derek Sivers' write-up on spaced repetition: https://sivers.org/srs
Personally I love intellisense and autocomplete functions of modern IDEs, I guess we have it so easy these days. The biggest drag on my coding velocity is more often thinking through the logic of what I actually want to program, recalling more APIs and function calls from heart would only make me slightly quicker, but then I'm also a contemplative deep thinker which may have an affect.
>> thinking through the logic of what I actually want to program

Yes, that is very important and I do ensure that I have the design and the details fleshed out. Still, I get tripped up and sometimes the IDE (Xcode) also fails me, though that is a failure of the IDE feature.

For example, I was recently working on making a class which would have some animation settings and there is a fill mode. I did not know the exact one and I had to look up. I tried `fill` for autocomplete to help, but did not work. Then I go do a look up and I hate these breaks.

>> would only make me slightly quicker,

I am not sure of the ROI to memorize these details, but looking at the other comment which links to Derek Siver's usage of spaced repetition for the same, seems to be effective, but then that is not a large sample set. I guess I will give the spaced repetition a try for a month or two and see.

Thanks.

The trick is practice. The more you use the language and APIs the more you'll remember. If you don't remember then a search engine is your friend. Libraries are so big these days that you can't be blamed for not remembering something. When I'm coding in C# I'll just google the API I'm using, which typically leads me to MSDN. When I'm coding Elixir I just head to Hexdocs.pm because the documentation is just fantastic.
In C/C++, I use the man pages (I already have a pretty good idea of what the APIs are, I just need to get some details).

For the C++ STL, I use www.cplusplus.com/reference

For Java, I pretty much use the IDE, assuming I can figure out what class I want to use. If I can't, I browse the Javadoc.

For Perl, I use perldoc.perl.org (or install the perldoc locally).

I'm in a similar boat where most of my work is in c# and java and I have some work in javascript. I work on multiple projects at the same time and try to make c# calls in java and vice versa. I often have to double check the API for simple calls but feel other programmers look down on me for making those rudimentary mistakes.