
Chinese scientists have published a study that is a small step to ensure that another human specialty, a software developer, has faded into oblivion. Links:
original article (
Russian translation ).
The authors of the study coached the RNN-network using a database with short programs that were written by students and were identified as valid (by launching the task verification system). Task descriptions have been reduced to this: “find the maximum number and the next largest number”.
As a result, the following code was generated (indent style and “author’s punctuation preserved unchanged):

It contains 4 errors, after correcting which the program began to solve the task.
')
It is important that the generated code did not contain any of the original examples in its pure form. Otherwise, I would have to admit that in such a perverted way I managed to write the usual code base search system. With the help of ccfinder, the closest examples from the training sample (more than 500 source code samples) were found:


From the first example, the structure is taken, from the second - the names of identifiers.
Interestingly, the network itself defined the synonyms of the “i <n” and “i <= n-1” constructions.
Also, it should be noted that no one specifically taught RNN the syntax of the C language - she derived all the rules on the basis of examples of novice programmers.
Of course, this example is very simple, but it shows the ability of RNN networks to generalize code and translate not only between natural languages. The researchers call the term “coming decades” as the time when a computer will write a program based on a description in natural language. Yes, the term is very vague, given that this time is of the same order as the entire lifetime of the industry.