ML to the Rescue: AI Developer Tools

Machine learning continues to penetrate the most diverse spheres of human activity, and such a technological area as software development, of course, could not be an exception. According to the forecast of AI and machine learning specialist Sergey Markov, voiced in the lecture “Results of AI-2019” , in 2020 a large number of development tools using machine learning will appear. This led me to the idea that some of these tools should be available on the market right now - can they then help in everyday life an ordinary web developer writing in Java, Python and JS? 

Looking ahead, I’ll say that, unfortunately, there are currently no open solutions that can generate at least some “combat” code. Closest to this came Bayouand DeepCoder, but these projects are still too raw. Greater progress is observed in related areas - such as auto-complete, static analysis, test generation. I will talk about this in the article.



Kite - smart autocomplete and built-in documentation in the Python IDE


Website: https://kite.com/
Price: Completely free.

Plugin to speed up code writing with the help of smart auto-completion. Kite indexes the code base of the project, which means showing the most relevant tips. In addition to the autocomplete itself, if necessary, you can open the built-in documentation with code samples for 800+ libraries in one click (most useful for libraries like numpy or pandas). Once a week a report is sent to the mail with statistics on the use of the auto-substitution function. 
 

Kite suggestions (marked with an icon) are much more relevant than native ones. Pop-up with documentation will tell you what can be transferred to kwargs

Kite used to send small pieces of code to the server, which is not suitable for many for security reasons, but good news! - Now Kite has abandoned this practice, and the whole analysis takes place locally. The plug-in is quite friendly to use - it is easy to install and works quickly without loading the system. Kite supports most of the popular IDEs: Idea, PyCharm, Sublime, Vim, Vs code, Spyder, and Atom.


The bottom line: perhaps the most ready for combat use project in the selection. I recommend to everyone who writes in Python.

For other languages, there are similar products - Codota for Java or TabNine, which supports 22 languages. I didn’t have time to try them out, but it feels like Codota offers more conservative hints, while TabNine (for Java) offers whole pieces of code, including variable names (sometimes without any context) and gets to the point.

DeepCode - a static code analyzer with a focus on vulnerability search


Website: https://www.deepcode.ai/
Price: Cloud version is free for opensource projects and teams for up to 30 people. There is a self-hosted option for GitLab and BitBucket Enterprise, the price is negotiable.

As the developers aptly put it, DeepCode is a Grammarly for code. The purpose is to help the developer in detecting errors and vulnerabilities in the code. The self-hosted solution comes in the form of a docker container, is integrated into the version control system through hooks and is configured in literally 10 minutes. A bot is also available for checking pull requests. Declared support for Java, Python, JavaScript, and TypeScript.


Example of DeepCode recommendation.

Impressions of use: very pleased with the low percentage of false positives. All the problems found were quite real and did not fire for reasons independent of the quality of the check (code with bugs did not start, unsafe code did not use user input). Performance warnings also look quite reasonable. The number of detected problems in comparison with the FineBugs Java code analyzer or the same PVS-Studio seems insignificant - 200 against 2-4 thousand. I don’t know whether to consider this a plus, but at least 200 pieces can really be taken apart, which cannot be said about 4 thousand. 


The bot checks every pull request

The bottom line: if you were always upset by the number of false positives when working with linters, you should try DeepCode. It’s also a great way to contribute to opensource: fork the project for yourself, run the test - and a couple of useful pull requests in your pocket.

DiffBlue - unit test generator for Java 


Website: https://www.diffblue.com/ 
Price: $ 3375 per month for a team of 25 people. A free tariff for individual use is still in the plans.

This product looks the most ambitious in the selection. A British startup last year that received 20 million in investment from Goldman Sachs. If initially I was looking for something that generates code for tests, then DiffBlue generates tests for code with the ability to be embedded in CI. The product features good integration with the Spring Boot test infrastructure. Works with Gradle, Maven, testng, Junit.

The developer announced two modes of operation: 

  • Essential: tests are generated by method signature
  • Advanced: the method body is also taken into account and tests are generated for each branch in the code. 

DiffBlue is supplied as a CLI utility for embedding in CI or as a plugin for IntelliJ IDEA for generating tests during development.


DiffBlue itself soaks classes, generates fixtures and assertions.
 
On real projects, DiffBlue proved to be ambiguous. 

  1. . — «». , , .   Gradle . . jar' , jcover.config. c Serializable, Active Record . — 3000 (sic!), coverage 3%.
  2. Case two, much more successful. Stateless microservice on Spring Boot. According to the developers, they devote a lot of time to supporting spring boot applications. Everything worked without errors, coverage rose from 28 to 42 percent, but only according to the instructions. On branches, coverage grew by only 6% from (41% to 47%). This is because many tests were tested by getters or setters. Perhaps in Advanced mode the results would be even more interesting.


It also happens. For a class with a dozen public methods and complex logic, it turned out to be a dummy.

The bottom line: if everything worked, as planned, it would be very cool and made sense, but this is still a long way off. Version 0.1 shows that the guys are still ahead.

Conclusion


Using AI for programming is gaining momentum, but so far the industry is still at the very beginning of the journey. There are many possible applications: in some, there has already been competition, in others so far only single products are presented. The main and most seemingly obvious goal - the generation of the code itself - has not yet been taken by anyone, but it is already able to increase the development speed, reduce the number of bugs in the old code and prevent the appearance of new ones.

All Articles