Can an AI Code Explainer Help Developers? Denigma Review

  • 8 mins read

Can an AI Code Explainer Help Developers? Denigma Review

I’ll be the first to admit when I don’t understand a line of code. Large projects and legacy codebases, in particular, can be confusing and unwieldy. Fortunately, I could always settle my curiosity or solve my query with a quick Google search or a few minutes on Stack Overflow.

I stumbled across Denigma while perusing a GitHub repo of resources for technical writers (which contains a TON of other valuable tools, which I’ll link here). After playing around with it for a few minutes, I immediately saw the potential value some devs and product managers might get out of it. I also noticed some drawbacks.

In today’s article, we’ll dive deep into whether this AI code explainer is effective and what some of its best use cases might be. We’ll also tear it apart, figure out where it is lacking, and go over why you might not want to trust it completely. Anyway, let’s get into it!

What is an AI Code Explainer

Developers spend between 70 and 294 minutes reading code each day. With statistics like these, any tool that can help ease this burden is a welcome addition to any dev’s toolbox. That’s where new tech, such as AI-powered code explainers, comes in.

Apps like Denigma and Gemini are some of the earliest players in the AI code explainer space. While the technology is in its infancy, we can enjoy a front-row seat to see how AI continues to develop and expand its software and web development capabilities. Not many devs fear an AI takeover of their jobs just yet. Still, if apps like this continue to improve and become mainstream, we could see benefits like increased productivity and better communication between development teams.

How Do AI Code Explainers Work

I believe Denigma uses OpenAI’s GPT-3 language model. This is similar to what you’ll find behind GitHub Copilot, an AI-powered pair-coding tool. Unlike apps like Copilot and Tabnine, which are used for automatic code completion, Denigma is used to decipher and explain preexisting code snippets. It is basically just an AI code explainer.

It takes contextual clues from variable names and analyzes your code snippets based on datasets it has been exposed to from a variety of languages. Denigma makes its limitations pretty clear on the app’s website. For example, to keep the AI focused on the task at hand, you should limit the amount of code submitted to under 15 lines. Additionally, since variable names can confuse the AI, Denigma prefers simple naming conventions like “foo” and “bar” for code snippets. 

Who is this For?

Denigma’s developers aim the app at a wide range of audiences, including beginners and advanced developers. It’s pretty clear the team is hard at work improving the app’s functionality, evidenced by the wealth of extensions available for text editors and IDEs like VS Code, PyCharm, PHPStorm (for PHP), and plenty of others. However, the underlying AI isn’t quite ready for the mainstream just yet.

Denigma is not great for working on codebases with spaghetti code and unconventional naming practices. It’s also not great for larger projects with many moving parts. The AI gets especially confused in situations where it encounters a lot of variable names or comments. 

While well-commented code is a valuable asset to most developers, Denigma seems not to appreciate it. Many developers argue that code that needs extensive commenting to be understood by human readers is not going to decipher any easier by an AI. As a matter of fact, extensive comments are the enemy of clean code when properly-named variables do a better job.

Robert C. Martin, author of Clean Code: A Handbook of Agile Software Craftsmanship, says it best: “A long descriptive name is better than a short enigmatic name. A long descriptive name is better than a long descriptive comment.”

Refactoring your code to be more self-explanatory and less reliant on comments is the preferred solution, but at that point, you would hardly need an AI to tell you how your code works.

What are the Positives

Even so, the AI effectively deciphers small code snippets with conventional variable naming practices. In situations where it is relatively straightforward what the code does, Denigma has no problem explaining things. Experienced developers will find this utterly useless. However, a beginner might see this as a godsend.

If you’re just starting in web development or programming and have no foundation of knowledge from which to draw to decipher code snippers, Denigma comes in clutch. While even a beginner can quickly look up a code snippet and gather its functionality from a few minutes of research on Stack Overflow, Denigma figures out the answer for you in a few seconds.

Denigma excels at simple JavaScript functions and snippets. If you’re unsure what a bit of code does, you can drop it in the AI and get a quick answer. 

More experienced developers won’t find any use in this. But a tool to quickly explain simple bits of code can prove valuable to a beginner. If you’re learning JavaScript, this can be a helpful utility to keep around.

What are the Disadvantages

Denigma and AI code explainers, in general, have some serious limitations. As the technology is still in its infancy, it hasn’t achieved the level of functionality that the creators envision. That’s not to say it isn’t helpful in some aspects already. But there is a long way to go before it becomes a mainstream tool for developers and product managers.

Besides limited support for frameworks and regular expressions, Denigma has a few glaring limitations that need resolving before mainstream adoption is possible.

Variable Naming

The main drawbacks stem from the application’s misinterpretation of variable names. An early user of Denigma submitted the following C++ code:

#include "tu2.hpp"
#include "tu1.hpp"
#include <iostream>
#include <typeinfo>

int main()
{
    auto nametu1 = tu1();
    auto nametu2 = tu2();

    std::cout << "tu1: " << nametu1 << "\ntu2: " << nametu2 << "\nsame? " << (nametu1 == nametu2)
            << '\n';
}

The output from Denigma looks promising at first, but upon closer inspection, you can see that variable names lead to a confusing and inaccurate explanation. In this case, the developer intended “tu” to mean “translation unit.”

Denigma’s output:

The code is a program that prints out the name of two different types of tuples.

The first type is called tu1 and it contains one element, which is an integer.

The second type is called tu2 and it contains two elements, which are also integers.

The main function creates two variables nametu1 and nametu2 with values from the tuple types tu1 and tu2 respectively.

Then in the next line, they print out “tu1: ” followed by the value contained in nametu1 followed by “\ntu2: ” followed by the value contained in nametu2 to see if they are equal or not.

The code prints out the following:

tu1: 00000000000000000000000000000001 tu2: 00000000000000000000000000000001 same?

true

Denigma excels until it encounters this naming convention. At this point, the AI assumes that the developer uses “tu” to refer to tuples, which are records in a database. This incorrect assumption leads the AI to spit out complete gibberish beyond that point.

Removing the first two lines of code, #include “tu2.hpp,” and #include “tu1.hpp”, clears up the problem for the most part, but the AI still trips over missing information. To fill in the gaps, the algorithm will make a lot of assumptions, many of which could be misleading or incorrect.

Code Snippet Length

Another area Denigma struggles with is the length of code snippets. If you submit a code snippet that is too long, the AI won’t be able to make sense of it. The upper limit seems to be roughly 15 lines of code. 

However, code snippets that are too short pose a problem too. Take the following code:

const triangle = (num) => (num * num + num) / 2;

This is a relatively simple JavaScript function for calculating the area of a triangle. Denigma protests that this one line is ”too short to provide a detailed and accurate answer.”

Final Thoughts

Apps like this are a fantastic idea overall. If properly executed, an AI code explainer can help developers understand legacy codebases and large projects with spaghetti code and confusing documentation. However, as they stand right now, this is one use case they are terrible for. AI trips over code that is too long or complex or filled with unconventional variable names.

We’re still exploring the limitations of this technology. While we can forgive the AI at this point since its knowledge is based entirely on the dataset it was trained with, not many experienced developers will find it helpful. 

If you’re a beginner, an AI code explainer like Denigma can be handy to keep in your back pocket. Since it is excellent for explaining simple code, self-taught learners and students might appreciate the quick explanations. However, you should be careful not to trust everything 100% and always double-check the explanations you get.

Denigma and AI code explainers, in general, show a lot of promise. If the technology continues to improve, we could see applications like this become more mainstream. Additionally, if the accuracy of the explanations improves, beginners can rely on it to explain complex functions and code snippets.

Leave a Reply