Skip to main content
The Keyword

AI

Bard now helps you code

An animated GIF displaying text of how “Bard can help you”: debug your lines of source code, generate documentation and tutorials for source code, explain your code to you line by line, translate your code from one language to another.

Since we launched Bard, our experiment that lets you collaborate with generative AI, coding has been one of the top requests we’ve received from our users. As a product lead in Google Research — and a passionate engineer who still programs every day — I’m excited that today we’re updating Bard to include that capability.

Starting now, Bard can help with programming and software development tasks, including code generation, debugging and code explanation. We’re launching these capabilities in more than 20 programming languages including C++, Go, Java, Javascript, Python and Typescript. And you can easily export Python code to Google Colab — no copy and paste required. Bard can also assist with writing functions for Google Sheets.

An animated GIF showing how Bard can generate code and export to Colab.

Bard can now generate code for you, and you can easily export Python code to Google Colab.

In addition to generating code, Bard can help explain code snippets for you. This is particularly helpful if you’re learning about programming for the first time, or if you need some additional support to understand what a block of code might output.

Animated GIF showing someone ask Bard to explain code within the google/jax GitHub repo.

Ask Bard to explain code. For example, "Tell me about the code within the google/jax GitHub repo."

Bard can also help you debug code, even code that Bard wrote. If Bard gives you an error message or code that doesn't do what you intended, just tell Bard “this code didn’t work, please fix it,” and Bard can help you debug.

An animated GIF showing a prompt in Bard for help debugging a file and Bard's response with debugging instructions.

Bard helps debug error messages.

Bard is still an early experiment, and may sometimes provide inaccurate, misleading or false information while presenting it confidently. When it comes to coding, Bard may give you working code that doesn’t produce the expected output, or provide you with code that is not optimal or incomplete. Always double-check Bard’s responses and carefully test and review code for errors, bugs and vulnerabilities before relying on it. Despite these challenges, we believe Bard’s new capabilities can help you by offering new ways to write code, create test cases, or update APIs. If Bard quotes at length from an existing open source project, it will cite the source.

In many cases, Bard can also help optimize your code by making it faster or more efficient. Just respond to Bard’s initial output with “Could you please make that code faster?” or “Find error handling clauses you might have missed.”

Bard is already helping people with everyday tasks, from crafting presentations and writing lesson plans to inventing new recipes or planning a workout routine. With new coding capabilities, we’re excited to apply generative AI to accelerate software development, inspire innovation, and help people solve complex engineering challenges.

For the latest Bard updates, visit our Experiment updates page. We’re excited to see what you build!

Let’s stay in touch. Get the latest news from Google in your inbox.

Subscribe