Playing with Github Copilot: Can AI automatically write ABAP code?
A few months ago GitHub released Copilot, an AI to help you write code by guessing what you will type next. It’s ‘powered by’ OpenAI and was trained on public GitHub repositories.
For example, the light gray text here is code proposed by Copilot (generated automatically as I type):
If I press tab it’s inserted. Then Copilot suggests how the function should look:
Which means when I hit tab a second time I get a working factorial function in two keystrokes.
Of course this really works with popular function names like GetUserAddress or ConnectToPostgress, not a or supercalifragilisticexpialidocize.
What about ABAP?
Well, copilot is completely language-agnostic, so it works for that too as long as you edit with visual studio code, either using my extension to edit code on your server as I’m doing here, or edit files on your laptop (perhaps to transpile to js or sync with your server using abapgit)
the good news
Still manages the factorial pretty well:
…except for the all-important missing spaces (added here by me):
I’d find it more useful for your typical ABAP boilerplate, though. For example:
Mmmh, not really. Let’s see with a little help:
I like seeing all the strings and values here but it’s not valid ABAP, and I have no idea where system_status comes from. Also with 17 exceptions I’d rather have a case statement.
Let’s try this bit again. I had to write all the code up to the first ‘when’, but now it’s starting to work:
Valid, sensible ABAP and reasonable text. But why stopping at 2 out of 17???
the bad ones
With less regular code Copilot really struggles.
Ok for guessing the variable name, but then wants to call gui_upload for every loop iteration…
As the training data for ABAP is really scant, what the system learns from the current code gets more important. Editing a big file with several loops already gets you more sensible results. It suggested this to me, for example:
On top of the dummy code using for this article, I’ve been using copilot for a while in several languages, mostly ABAP and typescript but also CDS, haskell and F#
It usually provides a good scaffold for what I want – often good enough to be left alone for the most tedious boilerplate. ABAP performance is by the far the worst of the languages I’ve tried, but even there I still find it useful at times. Definitely something to keep an eye on
SourceAI’s ambitions are a sign of a broader revolution in software development. Advances in machine learning have made it possible to automate a growing array of coding tasks, from auto-completing segments of code and fine-tuning algorithms to searching source code and locating pesky bugs.