DEV Community

saifmomin
saifmomin

Posted on

Code better with Amazon CodeWhisperer

There is a lot of buzz around Generative AI these days. CodeWhisperer is a Generative AI product from AWS that is powered by a Foundation Model trained on billions of lines of code. It speeds up software development by providing contextual code suggestions in real time.

This blog discusses how AI code generator tools like CodeWhisperer could change the way software is developed.

CodeWhisperer - The Code Buddy

CodeWhisperer is your personal Coding Assistant. With CodeWhisperer, you code faster and spend less time writing boilerplate code.

Quick Highlights

  • CodeWhisperer currently supports 15 popular programming languages and VS Code & JetBrains IDEs.
  • Support for JupyterLab is also available.
  • It is integrated with AWS services like SageMaker Studio, AWS Lambda and Cloud9.
  • Offered in two tiers: Individual (Free) and Professional (Priced).
  • To get started, you need an IDE, an AWS Toolkit extension and an authentication method (AWS Builder ID or IAM Identity Center or IAM).

Code Examples
Let's now see some illustrations to witness how CodeWhisperer can boost your coding superpowers.

Auto-complete: CodeWhisperer will auto-complete your comments or code as you type.

auto-complete comment

auto-complete

Get full function code from comments: You can provide comments as prompts to CodeWhisperer and it will implement the function for you.

full func

Get full function code from function signature: CodeWhisperer can generate the function body from the function signature.

signature

Generate Docstring from Code: Type the delimiter (/** */) above the method and CodeWhsiperer will generate the docstring for it.

doctring

Get line-by-line code recommendations: CodeWhsiperer can provide line-by-line code suggestions and can eventually complete the entire code block.

line-by-line

Write SQL queries: CodeWhisperer can suggest Structured Query Language (SQL) code based on comments.

sql

sql

Write shell scripts: CodeWhisperer can help you write code for shell scripts.

shell script

shell script

Write unit test: CodeWhisperer can create unit tests to develop testing scenarios for code.

unit test

Create test data: CodeWhisperer can help you generate dummy data - just enter the first object as an example, and CodeWhisperer will continue repeating the pattern.

test

test

Write Infrastructure as Code: CodeWhisperer can help you write IaC code using AWS CDK.

cdk

Write code in Jupyter Notebook with SageMaker Studio: Data Scientists can use CodeWhisperer to get code suggestions directly in the Python notebooks in Amazon SageMaker Studio.

sage

CodeWhisperer - More than a Code Generator

Now that we've seen how CodeWhisperer can help you write code faster, let's look at how it's more than just a coding advisor.

Helping Developers write Secure Code
CodeWhisperer helps you deliver secure code by shifting security commitments closer to the developer. CodeWhisperer can run security scans on the code directly in the IDE, allowing developers to detect security vulnerabilities, and get code suggestions to fix them instantly. CodeWhisperer uses Amazon CodeGuru to perform the security scan.

Inculcating use of Responsible AI
Does using the code generated by CodeWhisperer subject the organisations to copyright infringement? Fortunately, AWS has a solution to mitigate the legal risk associated with using AI-generated code. CodeWhisperer can flag code for license references (for example, MIT or Apache) ensuring developers don’t inadvertently use licensed code while accepting code suggestions from CodeWhisperer. This empowers developers to use AI responsibly and enables organisations to deliver products to their customers without infringing on the copyright.

Defusing Privacy Concerns
When you work with CodeWhisperer, AWS may collect your data for service improvement purposes. So are you putting your organization’s data at risk by using CodeWhisperer? Not really, because CodeWhisperer gives you the control to decide whether or not you want to share your data with AWS. This helps developers and organisations alike to build great software confidently with CodeWhisperer without any privacy concerns.

Transforming the Developer Role
The emergence of Generative AI tools like CodeWhisperer opens up the need for a new breed of Developers - those who can code as well as work effectively with AI. Prompt engineering is an emerging job role in the IT industry. Developers can take the leap and become specialists in prompt design, which is about crafting effective prompts to generate desired output from generative AI models. CodeWhisperer can also help developers learn new programming languages more quickly. A Java developer, for example, can easily start writing Python code using CodeWhisperer.

Removing Technology Barriers
AI code generators like Amazon CodeWhisperer play an important part in bringing users closer to technology. One of the best things about CodeWhisperer is that it comes with a free tier, making it easily accessible to everyone.

Looking Ahead

The future of Generative AI is exciting! It would be interesting to see how Amazon CodeWhisperer evolves over time. For instance, it would be nice to see a chat window and code translation capability in the product in future.

For now, go ahead and witness firsthand how it changes the coding experience.

Top comments (0)