AlphaCode and the Future of Programming
February 2, 2022
DeepMind researchers have released AlphaCode, an AI tool that has the ability to solve programming competition problems. For example, given this problem:
// RATING: 1200 // TAGS: *special,implementation // LANGUAGE IS python3 // CORRECT SOLUTION // You are given two strings s and t, both consisting of lowercase English // letters. You are going to type the string s character by character, from the // first character to the last one. // // When typing a character, instead of pressing the button corresponding to it, // you can press the "Backspace" button. It deletes the last character you have // typed among those that aren't deleted yet (or does nothing if there are no // characters in the current string). For example, if s is "abcbd" and you press // Backspace instead of typing the first and the fourth characters, you will get // the string "bd" (the first press of Backspace deletes no character, and the // second press deletes the character 'c'). Another example, if s is "abcaa" and // you press Backspace instead of the last two letters, then the resulting text // is "a". // // Your task is to determine whether you can obtain the string t, if you type // the string s and press "Backspace" instead of typing several (maybe zero) // characters of s. // // Input // // The first line contains a single integer q (1 ≤ q ≤ 10^5) — the number of // test cases. // // The first line of each test case contains the string s (1 ≤ |s| ≤ 10^5). Each // character of s is a lowercase English letter. // // The second line of each test case contains the string t (1 ≤ |t| ≤ 10^5). // Each character of t is a lowercase English letter. // // It is guaranteed that the total number of characters in the strings over all // test cases does not exceed 2 ⋅ 10^5. // // Output // // For each test case, print "YES" if you can obtain the string t by typing the // string s and replacing some characters with presses of "Backspace" button, or // "NO" if you cannot. // // You may print each letter in any case (YES, yes, Yes will all be recognized // as positive answer, NO, no and nO will all be recognized as negative answer). // // Example // // Input // // // 4 // ababa // ba // ababa // bb // aaa // aaaa // aababa // ababa // // // Output // // // YES // NO // NO // YES // // Note // // Consider the example test from the statement. // // In order to obtain "ba" from "ababa", you may press Backspace instead of // typing the first and the fourth characters. // // There's no way to obtain "bb" while typing "ababa". // // There's no way to obtain "aaaa" while typing "aaa". // // In order to obtain "ababa" while typing "aababa", you have to press Backspace // instead of typing the first character, then type all the remaining // characters.
AlphaCode generated this Python solution:1
t=int(input()) for i in range(t): s=input() t=input() a= b= for j in s: a.append(j) for j in t: b.append(j) a.reverse() b.reverse() c= while len(b)!=0 and len(a)!=0: if a==b: c.append(b.pop(0)) a.pop(0) elif a!=b and len(a)!=1: a.pop(0) a.pop(0) elif a!=b and len(a)==1: a.pop(0) if len(b)==0: print("YES") else: print("NO")
1I didn't immediately see a way to cut-and-paste this code, so I retyped it by hand. Any typos are my own.
Some commenters on Hacker News are worried that this means programming careers are in danger. I disagree.
I think the core of programming is analyzing things people want and expressing solutions to those wants clearly, unambiguously, and in a way that is easy to change in the future. I’d say algorithms and math—what AlphaCode can do—are a very small part of this work.
This does raise the question of whether AlphaCode can turn into something that does do real programming work. Perhaps it will. But the need for the kind of analytical thinking programmers do won’t go away.
I suspect tools like AlphaCode (and GitHub’s Copilot, which offers AI-driven code completion) will just be more tools programmers use—and they’ll still require specialized knowledge and training to use correctly, same as other programming tools today.
AlphaCode is a very impressive achievement. I’m not worried about the future of programming, though. Even if AlphaCode’s descendents can do programming work in the future, I suspect there will always be people needed to clearly define the problem AlphaCode and its ilk need to solve.
And that’s not much different than what programmers do today. We provide a clear specification (source code) that enables a tool (compiler or interpreter) to produce code that actually runs (executable machine code). The future of programming looks a lot like the present of programming, just with different tools and specifications.