AWS Announces CodeWhisperer

Posted by Ivan Klishch on Thu, Apr 13, 2023

Amazon Web Services (AWS) has announced CodeWhisperer, an AI-powered code completion tool aimed at rivaling GitHub's Copilot. These tools have become increasingly popular, providing developers with assistance in writing code more efficiently. In this article, we’ll explore features of the new service, as well as pros and cons of using AI-driven coding tools like CodeWhisperer and GitHub Copilot.

Real-time code suggestions customized for you

Trained on billions of lines of Amazon and publicly available code, Amazon CodeWhisperer understands comments written in natural language (in English) and can generate multiple code suggestions in real time to improve developer productivity. The service suggests entire functions and logical blocks of code (often consisting of up to 10–15 lines of code) directly in the integrated development environments (IDE) code editor. The generated code is similar to how you would write code, matching your style and naming conventions. You can quickly accept the top suggestion (tab key), view more suggestions (arrow keys), or continue writing your own code. Always review a code suggestion before accepting them, and you may need to edit it to ensure that it does exactly what you intended. As you type, CodeWhisperer even provides suggestions to complete the comment itself.

Amazon CodeWhisperer provides artificial intelligence (AI)–powered code suggestions for multiple programming languages, including Python, Java, JavaScript, TypeScript, C#, Go, Rust, PHP, Ruby, Kotlin, C, C++, Shell scripting, SQL, and Scala. You can use the service from multiple IDEs, including JetBrains IDEs (IntelliJ IDEA, PyCharm, WebStorm, and Rider), Visual Studio (VS) Code, AWS Cloud9, and the AWS Lambda console.

gohugo-default-sample-hero-image.jpg

Optimized for use with AWS services

CodeWhisperer makes it more efficient for developers to use AWS services by providing code suggestions that are optimized for AWS APIs including Amazon Elastic Compute Cloud (Amazon EC2), AWS Lambda, and Amazon Simple Storage Service (Amazon S3). As you write code in your IDE, CodeWhisperer automatically analyzes your code and comments. It makes a suggestion using the relevant cloud services and public software libraries for the desired functionality, and then it recommends code snippets that meet AWS best practices.

Built-in security scans

With CodeWhisperer, you can scan Java, JavaScript, and Python projects to detect hard-to-find vulnerabilities, such as those in the top 10 Open Worldwide Application Security Project (OWASP) or those that don’t meet crypto library best practices and other similar security best practices. The service analyzes existing code in the IDE (whether generated by CodeWhisperer or written by you), identifies problematic code with high accuracy, and provides intelligent suggestions on how to remediate it.

Code responsibly: Reference tracker for open-source code

CodeWhisperer provides a built-in reference tracker that detects whether a code suggestion might resemble open-source training data and can flag such suggestions. These suggestions are annotated with the open-source project’s repository URL, file reference, and license information so that you can review before deciding whether to incorporate the suggested code. All flagged suggestions that you used are logged so that you can review later and add license attribution at your discretion. You can also opt to filter out all code suggestions that CodeWhisperer determines resemble open-source code.

Code responsibly: Bias avoidance

Responsible use of AI and machine learning (ML) technologies is key to fostering continued innovation. CodeWhisperer helps developers avoid bias by filtering out code suggestions that might be considered biased and unfair

Enterprise administration

Provide users or groups access to CodeWhisperer using single sign-on (SSO) with AWS IAM Identity Center integration. Manage group-wide policies, such as including suggestions with referenced code.

Pros and Cons of using AI for Code Generation

Pros

  • Improved productivity: AI-driven coding tools can accelerate development by providing autocomplete suggestions, generating entire functions or code blocks, and offering alternative solutions to problems.
  • Learning aid: For novice developers, these tools can act as a learning resource by showcasing best practices and coding patterns, helping them improve their coding skills over time.
  • Reduced errors: By suggesting code snippets based on a vast dataset of well-written code, AI-driven coding tools can help minimize common programming mistakes and improve overall code quality.
  • Multilingual support: Tools like CodeWhisperer and Copilot can provide suggestions in various programming languages, making them versatile and beneficial to developers working in different technological ecosystems.
  • Enhanced collaboration: By standardizing coding practices and offering consistent solutions, these tools can make it easier for teams to collaborate and maintain a unified codebase.

Cons

  • Overreliance on AI: AI-generated suggestions might lead to overdependence on the tool, potentially hindering developers’ ability to problem-solve independently and critically evaluate their own code.
  • Imperfect solutions: AI-driven coding tools may not always provide the most optimal or efficient solutions, so developers still need to review and test the generated code rigorously.
  • Intellectual property concerns: When using code generated by these AI tools, developers should be cautious about potential copyright or licensing issues that might arise from incorporating publicly available code into their projects.
  • Security risks: Although AI-generated code might be based on best practices, it may still introduce vulnerabilities or security risks that developers need to be aware of and address accordingly.
  • Limited customization: AI-driven coding tools may not always cater to specific project requirements or unique coding styles, which might require manual adjustments or customizations by the developer.

Conclusion

AI-powered code completion tools like AWS’s CodeWhisperer and GitHub’s Copilot offer numerous benefits, including improved productivity and code quality. However, developers should be aware of the potential drawbacks, such as overreliance on AI and imperfect solutions. The key to successfully utilizing these tools lies in striking the right balance between automation and manual intervention, ensuring that developers maintain control over the quality and security of their codebase.