Build applications faster with Amazon CodeWhisperer, an ML-powered coding companion

Build applications faster with Amazon CodeWhisperer, an ML-powered coding companion

Although the cloud has democratized application development by providing on-demand access to compute, storage, database, analytics, and machine learning (ML), the traditional process of building software applications still requires developers to spend a significant amount writing boilerplate sections of code that isn't directly related to the core problem that they’re attempting to solve. Even the most experienced developers struggle to keep up with multiple programming languages, frameworks, and software libraries, while ensuring that they’re following the correct programming syntax and best coding practices. As a result, developers spend a significant amount of time searching and customizing code snippets from the web.

Amazon CodeWhisperer is a machine learning (ML)–powered service that helps improve developer productivity by generating code recommendations based on their comments in natural language and code in the integrated development environment (IDE).

With CodeWhisperer, developers can stay focused in the IDE and take advantage of real-time contextual recommendations, which are already customized and ready to use. Fewer distractions away from the IDE and ready-to-use, real-time recommendations help you finish your coding tasks faster and provide a productivity boost.

Support for popular programming languages and IDEs

As of now Amazon CodeWhisperer provides recommendations to accelerate development of C#, Java, JavaScript, Python, and TypeScript applications.

The service integrates with multiple integrated development environments (IDEs), including JetBrains (IntelliJ IDEA, PyCharm, WebStorm, and Rider), Visual Studio Code, AWS Cloud9, and the AWS Lambda console.

?

Example- How to Enable Amazon CodeWhisperer with Visual Studio Code:

As mention above CodeWhisperer can integrates with multiple IDEs i.e. ?Visual Studio Code, IntelliJ, AWS Cloud9, and the AWS Lambda console. In this example we are providing end to end steps for integration with Visual Studio Code.

?

?Step 1:

Launch the Visual Studio Code IDE. You will see the AWS logo on the left-hand side menu bar. That is the AWS Visual Studio extension pre-installed. Click the AWS extension.

No alt text provided for this image

Step 2:

In the bottom half of the Explorer menu that just opened, click CodeWhisperer (Preview) > Start.

No alt text provided for this image

Step 3:

A dropdown will appear from the top of the screen, prompting you to select a connection option to begin using Amazon CodeWhisperer. Click on the first option, Use a person email to sign up and sign in with AWS Builder ID.

No alt text provided for this image

Step 4:

A new tab will open, prompting you to enter an email address to create a new AWS Builder ID. Enter you email and click Next. an additional field will appear, prompting you to enter your name. Enter your name and click Next.

No alt text provided for this image

Step 5:

A verification code was sent to your email (be sure to check spam if you do not see the email). Enter the code and click Verify.

No alt text provided for this image

Step 6:

Now you will be prompted to set a password. Enter and confirm the password and click Create AWS Builder ID.

No alt text provided for this image

Allow aws-toolkit-vscode to access your data by clicking Allow.

No alt text provided for this image

A message will appear indicating you have successfully completed the process and can return to your development environment.

When returning to Visual Studio, you will be prompted to review and accept the Amazon CodeWhisperer Terms of Service. Click Accept and Turn on CodeWhisperer to continue.

No alt text provided for this image

You have now successfully set up your development environment with Amazon CodeWhisperer. You can proceed directly to the CodeWhisperer for Python section on the left-hand side.

Example- How to use Amazon CodeWhisperer to generate Code

Let's started by implementing the first Lambda function in python language, which is responsible for downloading an image from the provided URL and storing that image in an S3 bucket.

For more information on how to work with Code Whisperer in VSCode, please visit the?User Guide?.

Step 1:

Create a new file in the IDE and save it as anyName.py.

Step 2:

Add an empty AWS Lambda function handler.

To start using CodeWhisperer, write a comment that describes the required functionality you need to achieve. ?

# Function to get a file from url

Step 3:

  • Place your cursor after a comment or line of code, click?enter?to activate CodeWhisperer.
  • You can browse through multiple suggestions (if available) with the?left/right arrow keys.
  • Accept a code suggestion by pressing?Tab.
  • Discard a suggestion by pressing?Esc?or typing a character.
  • After accepting or writing new code, click?enter?again to get the next line of suggested code.
  • Manually trigger Amazon CodeWhisperer or if the suggestion is not appearing, you can click?Option + C?on MacOS or?Alt + C?on Windows.

Step 4:

You should get a suggested implementation of a function that downloads a file using a specified URL. If needed, fine-tune the code. CodeWhisperer generates the core logic, but you might want to customize the details depending on your requirements.

No alt text provided for this image

Conclusion:

CodeWhisperer makes it easy for developers to use AWS services by providing code recommendations for AWS APIs across the most popular services, including Amazon Elastic Compute Cloud (EC2), AWS Lambda, and Amazon Simple Storage Service (S3). If our customers are utilizing the SDKs provided by AWS they can be faster and more efficient with CodeWhisperer. With CodeWhisperer customers will save time by not having to look at API documentation to accomplish simple AWS tasks.?

要查看或添加评论,请登录

Ashwani Dogra的更多文章

社区洞察

其他会员也浏览了