Self-writing Code

My code started writing itself today. Feels magical and slightly annoying. It shouldn’t be this easy πŸ™‚

So, I wrote:
def recreate_if_exists(directory):

…and the body of the function automatically filled itself in.
if os.path.exists(directory):
shutil.rmtree(directory)
os.makedirs(directory)

Turns out it was Tabnine – the AI code completion plugin I installed recently.

I typically write all the function names and tests(not always) first, and then go about filling the function body (with all the usual debugging, doc searches, and Stack Overflow visits). Tabnine seems to be short-circuiting a lot of that process with clean, bug-free code, including declaring the right imports. πŸ€·β€β™‚οΈ It’s able to do this for roughly between 20% – 40% of the functions depending on the context.

Granted, the hard problems are still there, but all the little time-consuming and frustrating bits are disappearing. And the gain in final throughput is perhaps not going to be proportional to the productivity gains, because of the typical 80:20 rule in software development. Nevertheless, when developers don’t have to deal with numerous little problems, they can focus on the big ones better and that makes programming so much more fun.

Leave a comment