Chat GPT vs. Google Bard: Which AI Chatbot is Better at Programming?

When Google launched Bard, its answer to OpenAI’s ChatGPT, it lacked a feature much appreciated by ChatGPT users: the ability to write code. However, following popular demand, Google gave Bard a shot in the arm, allowing him to write code in dozens of programming languages.



videos of the day

Innocn 48Q1V: Ultimate gaming immersion on this 48″ monster. The Innocn 48Q1V is one of the biggest, fastest, and best-sounding gaming monitors you can buy in 2023.



Google has since talked about how well Bard is capable of writing and debugging code, but how does it compare to the phenomenal ChatGPT? Let’s find out.



Chat GPT vs. Bard: Language support

Officially, Google’s Bard can work with about 20 programming languages. These mostly consist of the popular ones like Typescript, Python, C++, Go, Java, JavaScript and PHP. It can still handle less popular options like Perl and Scala, but it’s not necessarily as efficient.

ChatGPT on the other hand does not have an official list of supported languages. The chatbot can handle most of what Bard can handle and dozens more. ChatGPT can write, debug and explain code in both newer and popular programming languages ​​as well as less popular legacy languages ​​such as Fortran, Pascal, BASIC and COBOL.

However, support does not necessarily mean expertise. We tried some simple tasks in selected languages ​​like PHP, JavaScript, BASIC and C++. Both Bard and ChatGPT were able to offer popular programming languages, but only ChatGPT was able to cogently cobble together programs in older languages. So in terms of language support, we give the win to ChatGPT.

Chat GPT vs. Bard: accuracy and quality of the code

Let’s say you ask ChatGPT or Bard to generate a piece of code that does something and spits out dozens of lines of code in seconds. Easy, right? But how often will that code work? Let’s say the code works; how good is that code?

To compare the accuracy and quality of the code generated by the two AI chatbots, we gave both a few coding tasks to complete. We asked Bard and ChatGPT to generate a simple to-do list app using HTML, CSS and JavaScript. After copying and pasting and viewing the generated code in a browser, the ChatGPT app looked like this:

ChatGPT to-do list interface

Using ChatGPT version, you can add a new activity, delete an activity or mark an activity as done. Google’s Bard was also able to generate a functional to-do list app. However, you can only add a task, with no means of deleting or marking it as done. Bard’s interface also looked less appealing; here’s what it looked like:

Google Bard to-do list interface

We repeated the test, this time asking both chatbots to recreate Twitter timeline cards. Here is the result of ChatGPT:

ChatGPT Twitter history clone

And here’s what Google’s Bard came up with:

Google Bard Twitter Timeline clone

Both results have their pros and cons. We would have gone with Bard’s results if she had the Like, Retweet, and Comment buttons. However, he bizarrely left them out, so we’ll let you decide which one is best. Of course, the quality of the code isn’t just about the aesthetics of what it produces.

Looking at the code generated by both chatbots, Bard’s appeared to be more object oriented while ChatGPT’s was more procedural. Our choice of programming language might influence this, but ChatGPT seemed to write cleaner code when needed. It also tends to generate more complete solutions, typically leading to more lines of code.

In terms of the quality of the generated code, we award this round to ChatGPT.

ChatGPT vs. Bard: debugging and error detection

Errors and bugs are like puzzles that programmers love to hate. They will drive you crazy, but solving them is quite satisfying. So when you run into bugs in your code, should you ask Bard or ChatGPT for help? To decide, we gave both AI chatbots two debug problems to fix.

First, we asked both chatbots to fix a logic error in some PHP code. Logical errors are notoriously harder to spot because the code containing them doesn’t look wrong, it just doesn’t do what the programmer intended.

Logical error in PHP code

The code in this screenshot runs, but doesn’t work. Can you spot the logic error? We asked Google’s Bard for help and unfortunately the chatbot was unable to locate the logic error in the code. Interestingly, Google’s Bard typically has three draft attempts to fix a problem, we checked all three drafts and they were all wrong.

Bard tries to identify a logic error

We then asked ChatGPT for help and it immediately spotted the logic error.

ChatGPT identifies a logical error in the PHP code

The PHP script had no syntax errors, but the logic in the file isOdd() the function was backwards. To see if a number is odd, you would typically check to see if it has a remainder after division by 2. If it does, it’s an odd number.

While Bard was nowhere near able to identify this bug, ChatGPT caught it on the first try. We tried four other logical errors and Bard was only able to pinpoint the error in one instance while ChatGPT delivered consistently. After switching to code with syntax errors, Google’s Bard was able to keep up, identifying them in nearly every sample submitted.

Google’s Bard is relatively good at debugging, but we’ll give this win to ChatGPT again.

ChatGPT vs. Bard: context awareness

One of the biggest challenges with using AI chatbots for coding is their relatively limited awareness of context. You ask the chatbot to write some code, then more… down the line, it completely forgets that the next thing it’s building is part of the same project.

For example, say you’re building a web app with an AI chatbot. You tell it to write the code for your HTML registration and login page, and it does it perfectly. And then, as you continue building, ask the chatbot to generate a server-side script to handle the login logic. This is a simple task, but due to limited context awareness, it may end up generating a login script with new variables and naming conventions that don’t match the rest of the code.

So which chatbot is better at maintaining context awareness? We gave both tools the same programming task: a chat app that we know ChatGPT can already create.

Unfortunately, Bard simply couldn’t complete the app because it lost track of the project context after sitting idle for some time. While subject to the same conditions, ChatGPT completed the app. Again, in terms of context awareness, we give it to ChatGPT.

ChatGPT vs. Bard: Troubleshooting

At this point, Google’s Bard is missing in many ways. But can he finally score a victory? Let’s put your problem solving skills to the test. Sometimes you just have a problem, but you’re not sure how to represent it programmatically, let alone how to fix it.

Situations like this are when AI chatbots like Bard and ChatGPT can come in very handy. But which chatbot has better troubleshooting capabilities? We asked both of “write JavaScript code that counts how many times a certain word appears in a text.

Bard responded with a working code, though it fails when punctuation marks are near a word or the word appears in different cases.

Google Bard troubleshooting

We ran the same issue on ChatGPT and here is the result:

ChatGPT troubleshooting

ChatGPT’s code takes a more robust and accurate approach to counting occurrences of words in a text. It considers word boundaries and case sensitivity, handling punctuation correctly and providing more reliable results. Again, in terms of troubleshooting, we give it to ChatGPT.

Since Google Bard lost out on pretty much every metric we used for comparison, we decided to give it a chance to redeem itself. We asked the chatbot “Which is better at coding? ChatGPT or Google Bard?

While he agreed that ChatGPT was more creative, Bard said that its competitor was more prone to mistakes and that ChatGPT produced less efficient, poorly structured, and generally less reliable code. We have to disagree!

Google Bard Boost to be better than ChatGPT

ChatGPT is in a league of its own

Google’s Bard has enjoyed a lot of hype, so it might come as a surprise to see how much it lacks compared to ChatGPT. While ChatGPT clearly had an edge, you’d think Google’s massive resources would help it erode that edge.

Despite these achievements, it would be unwise to write off Bard as a programming aid. While not as powerful as ChatGPT, Bard still packs a significant punch and is evolving at a rapid pace. Given Google’s resources, Bard’s emergence as a worthy rival is surely a matter of time.

#Chat #GPT #Google #Bard #Chatbot #Programming
Image Source : www.makeuseof.com

Leave a Comment