
In computer terms, bugs are definitely not the best of friends. They should be squashed, eliminated, removed and obliterated.
.
But the thing about finding bugs in computer codes is that, it can be overwhelmingly difficult. This is why Facebook has built an AI to do the job, to help programmers patch buggy codes with less of a problem. The tool is called 'SapFix', and it's initially used internally by Facebook to automatically detect anomalies in code and suggest relevant fixes.
"Debugging code is drudgery," said Facebook. "But SapFix, a new AI hybrid tool created by Facebook engineers, can significantly reduce the amount of time engineers spend on debugging, while also speeding up the process of rolling out new software."
When first introduced, SapFix works on fixing bugs found by Sapienz, Facebook's automated testing tool software. But with plans to roll out SapFix to the public, Facebook wants to make it work independently, without requiring developers to use Sapienz.

In order to fix a bug, SapFix either fully or partly revert codes that caused it. To handle more complex bugs, it needs to pick up a template from its knowledge base.
"These templates were automatically harvested from those created by human engineers, based on a pool of past fixes," explained Facebook.
When previously used human-designed templates don’t fit, SapFix can make a mutation-based fix by performing multiple small code modifications to the abstract syntax tree (AST) of the crash-causing statement, making adjustments to the patch until a potential solution is found.
TAfter that, SapFix tests those fixes against three parameters:
- Are there compilation errors?
- Does the crash persist?
- Does the fix introduce new crashes?
When the tool knows the fix, it sends the results to the engineers for review and feedback.

According to Facebook, this marks the first time that a machine-generated fix - with automated end-to-end testing and repair - has been deployed into a codebase at Facebook's scale.
This is a milestone in AI development, showing that AI hybrids can offer search-based software capable of reducing friction in software development.
"As we develop SapFix to work with different kinds of bugs and software, the tool has the potential to change the speed and quality of code generation. That’s true not just for companies that operate at large scales, but also for nearly anyone who creates code. Whether used together or separately, SapFix and Sapienz let developers spend less time on debugging and more on generating what’s next," continued Facebook.
"SapFix can automatically head off crashes before they happen, the longer-term applications could include making software faster and more responsive. These systems offer significant baseline benefits, and their impact promises to be as varied and wide-ranging as the developers who will use them."
Both SapFix and Sapienz are intended for open source release, but Facebook said that they need more engineering work before that happens.