image-blog-qac-ai-programmers
July 26, 2018

With AI Writing Code, Will AI Replace Programmers?

Static Analysis

Software developers have plenty to keep them awake at night. Their top concern is no longer how to express the latest algorithm in their favorite language (C, C++, Erlang, Java, etc.). Instead, it’s being replaced by artificial intelligence (AI).

Here we take a look at the process for AI writing code and answer the question: Will AI replace programmers?

Read along or jump ahead to the section that interests you the most:

➡️ Start Your Free Static Code Analysis Trial

Back to top

AI Writing Code: The Future of AI Technology

In a survey conducted by Evans Data Corp, 550 software developers were asked about the most worrying aspects in their career. “I and my development efforts are replaced by artificial intelligence,” said 29%.

A team of researchers at the U.S. Department of Energy's Oak Ridge National Laboratory agrees. By 2040, machine learning and natural language processing technologies will be so advanced that they will be capable of writing better software code. And they’ll do it faster than the best human developers. 

Oxford University’s "The Future of Employment" study warns that software engineers may become computerized as machine learning advances. And software design choices will be optimized by algorithms.

Software development, particularly in safety-critical industries, needs to ensure high code quality that delivers on functional requirements.

So, if AI is developing code, the code should be error- and issue-free. This also includes AI in software testing, as it should be able to detect coding errors “with a reliability that humans are unlikely to match.”

If you do have AI writing code, be sure to verify that it is safe, secure, and reliable by using a static code analyzer.

➡️ Start your free static code analyzer trial today and put your code to the test.

Back to top

Is AI Writing Code Possible? And Will AI Replace Programmers?

AI can write code.

In 2015, Andrej Karpathy ran a project that used Recurrent Neural Networks to generate code. He took GitHub’s Linux repository (all the source files and headers files), combined it into one giant document (it was more than 400 MB of C code), and trained the RNN with this code.

Here’s what it produced:

 

/*
 * If this error is set, we will need anything right after that BSD.
 */
static void action_new_function(struct s_stat_info *wb)
{
  unsigned long flags;
  int lel_idx_bit = e->edd, *sys & ~((unsigned long) *FIRST_COMPAT);
  buf[0] = 0xFFFFFFFF & (bit << 4);
  min(inc, slist->bytes);
  printk(KERN_WARNING "Memory allocated %02x/%02x, "
    "original MLL instead\n"),
    min(min(multi_run - s->len, max) * num_data_in),
    frame_pos, sz + first_seg);
  div_u64_w(val, inb_p);
  spin_unlock(&disk->queue_lock);
  mutex_unlock(&s->sock->mutex);
  mutex_unlock(&func->mutex);
  return disassemble(info->pending_bh);
}

static void num_serial_settings(struct tty_struct *tty)
{
  if (tty == tty)
    disable_single_st_p(dev);
  pci_disable_spool(port);
  return 0;
}

static void do_command(struct seq_file *m, void *v)
{
  int column = 32 << (cmd[2] & 0x80);
  if (state)
    cmd = (int)(int_state ^ (in_8(&ch->ch_flags) & Cmd) ? 2 : 1);
  else
    seq = 1;
  for (i = 0; i < 16; i++) {
    if (k & (1 << 1))
      pipe = (in_use & UMXTHREAD_UNCCA) +
        ((count & 0x00000000fffffff8) & 0x000000f) << 8;
    if (count == 0)
      sub(pid, ppc_md.kexec_handle, 0x20000000);
    pipe_set_bytes(i, 0);
  }
  /* Free our user pages pointer to place camera if all dash */
  subsystem_info = &of_changes[PAGE_SIZE];
  rek_controls(offset, idx, &soffset);
  /* Now we want to deliberately put it to device */
  control_check_polarity(&context, val, 0);
  for (i = 0; i < COUNTER; i++)
    seq_puts(s, "policy ");
} 

 

AI generated code — including functions and function declarations — overnight. It had parameters, variables, loops, and correct indents. Brackets were opened and later closed. It even had comments.

However, the AI produced code had syntactic errors. It didn’t keep track of variable names.  Sometimes variables were declared but never used. Other times variables were used but not defined. The second function in the code example compares tty == tty.

The project is available on GitHub. It uses the Torch7 deep learning library. Here is the whole output file produced by Karpathy’s exercise.

Back to top

Will AI Replace Programmers?

AI won’t replace programmers. But AI might write code one day.

Of course, it will take time before AI will be able to create actual, production-worthy code that spans more than a few lines.

Here’s how AI will impact software development in the near future.

AI Will Improve

It will become effective at helping developers understand their options. And it will then let the human decide how to optimize for circumstances beyond AI’s understanding.

AI Will Become a Coding Partner

Software developers will use AI as a coding pair to write better software.

But Programmers Will Remain Important

The true value of a programmer is not knowing how to build it. The value is in knowing what to build.

It will take even longer before AI learns how to interpret the business value of each feature and advise you what to develop first. There will always be a role for the human programmer.

Back to top

What If AI Writes Reliable Code?

That’s a big if. Most humans can’t write reliable code. And AI is just an application that analyzes vast amounts of human-written code. So, it’s unlikely that AI will write reliable code.

So, AI isn’t the answer to improving code quality.

Back to top

How to Improve Code Quality Today

You can improve code quality today. But it’s not by replacing programmers with AI.

Code quality improves with static code analysis.

Here’s how.

Programmers write the code. A static code analyzer ensures the code complies with coding rules. It also scans code to identify potential errors and security vulnerabilities. And it finds bugs that are commonly missed in code reviews and software testing. This improves overall code and software quality.

One of the simplest ways to improve code quality is to use a static code analysis tool. Start your free trial today.

➡️ register for a free static analysis trial

Back to top