DEV Community

Mark Laszlo for AWS Community Builders

Posted on

AWS CodeWhisperer - Your ML powered Coding companion

Advancements in technology have brought multiple virtual assistants to help with everyday tasks. Most of us who have worked with Microsoft products are familiar with Clippy. One of the first Virtual assistants did fun animations, helped with commands, and provided helpful hints and productivity tools to make work easier.

Image description

We have so many tools that help us with day-to-day work,
Most of us have Siri to help manage schedules, set up reminders, and help recall when
A birthday or anniversary is coming; it's been ages since I've set up
an alarm in any way other than voice control. Most houses have an Amazon Alexa powering
the work going on. Virtual assistants surround us; it is only time before assistants support developers. Well, with AWS’s latest offering, that is now a reality.

AWS proudly introduces AWS Code Whisperer, an ML-powered coding companion trained on millions of open-source code sources. Code Whisperer increases productivity by looking at previous code and natural language code and comments and improves the solution.

It sounds too good to be true. While working on a solution that involves sending a file to an S3 bucket, all it required on my part was to write in comments.

Create a function to send a file to s3

And code whisperer creates the entire function required to perform the functionality for me to review and approve.

The above took less than 10 seconds to review, amend and add to the code. On any other day, it would’ve taken 5 minutes to code or 10 to look through old code, find a function that works, and copy-paste it into the existing solution.

Image description

Code whisperer is currently available for the three major programming languages, with the development team working on adding support for more. The currently supported languages are:

  1. Java
  2. Python
  3. Javascript.

In addition to the languages, Code Whisperer integrates seamlessly with widely supported IDEs through the AWS Toolkit, such as

  • JetBrains (PyCharm, IntelliJ and WebStorm)
  • Visual Studio Code
  • AWS Cloud9
  • AWS Lambda Console

AWS Code Whisperer not only reviews the current code and provides insight, code recommendations, and examples but also builds upon the work done with AWS Service intercommunications and APIs. It adds content based on the requirements of the code. So whether you are working on AWS EC2, Lambda, or S3, CodeWhisperer can understand the flow of the code and provide code suggestions similar to how a developer would write code from scratch.

Due to its underlying ML learning algorithms, CodeWhisperer continuously learns by understanding how you code. In my short time using it, CodeWhisperer would interpret comments and provide options to complete even comments written in English. The developer chooses to go with the top recommendation or look at the list of recommendations, after which CodeWhisperer provides a best-practiced, code block that saves the hassle of copy-pasting code from the internet.

Another significant advantage of CodeWhisperer that builds upon the last point is that CodeWhisperer also provides a developer to harness the power of ML to improve the standard of the code. CodeWhisperer automatically scans each line of code written for vulnerabilities and security risks. You simply click the “Run security Scan” Button on the AWS Toolkit, and CodeWhisperer provides an analysis of the code and suggestions to improve the quality. Secondly, it has an in-built reference tracker which reviews whether the code blocked, written, or recommended exists in CodeWhisperers training algorithms or data and provides references that add to the credibility of the code.

Image description

Code Whisperer is currently in preview mode, and there is a substantial waitlist to get an access token.

Simply log in to the AWS preview waitlist page and provide your information. AWS will provide you with the access token.

Afterward, install the AWS Toolkit in the IDE of your choice. For me, that was Visual studio code. In the extensions tab, click CodeWhisperer and add the access code.

Image description

And you are done. Enjoy coding with your virtual partner and reap the productivity rewards.

Personal Experience:

CodeWhisperer is by no means a polished product which makes sense as to why it's in preview mode.

The code suggestion can be hit or miss sometimes. I implemented a real-life example where one of my clients asked to get the public IPs of all EC2 instances so they may run a pen test on their environment.

Seems easy enough. Just add a handy comment and let CodeWhisperer give you a function that provides just that.

Except, the function that was returned did not use pagination which meant it had the possibility of not running the complete code should the values returned be more than the page results that are paginated.

Another example was requesting a function to connect to MySQL database. CodeWhisperer assumes it's supposed to be on AWS and creates a function that does not fulfill my requirements.

However, retesting and tweaking it allows the code whisperer to understand better and provide another alternative that does much better.

CodeWhisperer’s other two capabilities are a lot more polished. The code suggestions that CodeWhisperer Provides prove very helpful when crafting an extended code or script.

In fact, in conversations that i’ve had with Cloud developers and software engineers who have used CodeWhisperer, they have all had the same opinions, such as

  • Provides an additional viewpoint through suggestions
  • Provides auto code completion, which increases productivity and speeds up coding
  • Provides insight into security and best practices while coding.
  • It gives alternative options to write code better or more optimized.

CodeWhisperers Security scan is also an excellent tool to have. I ran the security scan on some scripts in production, and CodeWhisperer pointed out flaws such as missing pagination that had bypassed QA.

CodeWhisperer is currently in preview, which means that AWS is optimizing the product before launching it to open public. I’m interested in seeing the changes that AWS will make, whether they will add additional features to the product, and the most important thing for me would be the pricing.

CodeWhisperer is a wonderful product that can help your development team create better code quickly, but if it is not priced competitively, I fear it may be something that wouldn’t gain much traction.

Overall, CodeWhisperer is an exciting addition to AWS’s Services and offerings. I will personally use it a lot, and I am excited to see what the future holds for AI Code companions and Assistants with AWS.

If you had the chance to try out, please leave a comment and share your experience.

Top comments (0)