AI-powered bug spray: Facebook’s new tool SapFix debugs code with AI
Welcome to the future of debugging. Facebook’s new tool SapFix uses advanced AI to debug code and create patches. Are we about to enter a post-debugging world?
Is there anything AI can’t do? It can detect faces, it can draw, and now thanks to Facebook engineers it can debug your code. Turing test, watch out, because the future of debugging is on its way and it’s an AI’s world.
Recently, we learned that code debugging takes up an inordinate amount of time in a developer’s day. This comes as no surprise to developers surely. Slogging through code, testing, and continuously debugging is not something that anyone looks forward to. Facebook engineers unveiled a new AI hybrid tool that helps shave down the time between writing code and deployment. SapFix automatically generates fixes for bugs.
Getting by with a little help from AI
First thing is first, SapFix is not available for general download just yet. However, it will be open sourced “in the future, once additional engineering work is completed”, so jot it down on a sticky note for later. The goal of this project is leading to a fully automated debugging, which sounds like a dream but may one day become a reality.
Facebook has a massive amount of code and SapFix is how they manage all of those potential bugs. It’s already been used in code updates to the Facebook Android app, run on millions of devices worldwide.
According to Facebook engineers, this is “the first such use of AI-powered testing and debugging tools in production at this scale”.
How does it work? SapFix can run either as an independent tool or alongside Sapienz, another Facebook creation. (Sapienz also helps makes the testing process faster through automation and will be open sourced alongside SapFix when the time comes.) When using Sapienz, it finds bugs before productions, and then sends them to SapFix. SapFix then chooses from several strategies in order to generate a patch.
To address high-firing bugs, SapFix creates patches that either fully or partially revert the code submission that introduced them. For more complex crashes, the system generates patches by drawing from its collection of templated fixes.
Of course, the AI has to get data from somewhere. The patch templates are all built from previous fixes from people. If the AI comes across a bug that no available patch fixes, it then will modify the code until a fix is found. Tested patches are also sent to a human reviewer.
The future of automation?
As of writing this, SapFix isn’t ready for a larger scale. However, Sapienz is already working on producing bug reports for Facebook owned Android apps (Facebook, Instagram, Messenger, and Workplace).
The results so far are optimistic. Facebook states that, “Approximately three quarters of Sapienz reports resulted in fixes by developers”. With continued development, this number will surely grow. Lowering technical debt is the goal many other projects in development, including a tool that detects code smells in Java.
If we enter a post-debugging world, developers will have much more time on their hands that isn’t spent focuses on code quality, but instead can be used to create new software. Facebook engineers also state that they are focusing on how to use SapFix to prevent crashes before they happen. A crash-free world with self-debugging code? It could be a developer’s paradise.
What do you think about the potential for debugging to one day become fully automated? Is it real life – or is it just fantasy?