Article
Over the past year, we’ve all come to know that ChatGPT can write code. I gave it a number of tests in PHP and WordPress that showed the strengths and weaknesses of ChatGPT’s coding capabilities.
But how far does ChatGPT’s coding knowledge extend? When I originally drafted this article in early 2023, I threw the classic "Hello, world" programming assignment against the 12 most popular languages in O’Reilly Media’s popularity rankings for 2023.
We’ve subsequently done a lot of analysis about programming language popularity, but even with this late 2024 update, I’m sticking with the original 12 languages we tested. While some of our 12 aren’t really massively popular languages, they’re still current and in use. This selection gives us a very good cross-section to better help us understand how well ChatGPT handles a wide range of languages.
Because "Hello, world" can often be coded in one line, I added a slight wrinkle, having ChatGPT present "Hello, world" ten times, each time incrementing a counter value. I also asked it to check the time and begin each sequence with "Good morning," "Good afternoon," or "Good evening."
This gives us a look at program flow and some intrinsic functions as well, but still keeps the code small enough that I can include a dozen screenshots in this article.
1. Java
ChatGPT describes Java as, "A general-purpose language used primarily for building desktop, web, and mobile applications, and known for its ‘write once, run anywhere’ philosophy."
Here’s ChatGPT’s code:
**2. Python**
ChatGPT describes Python as, “A general-purpose language used for data analysis, artificial intelligence, web development, and automation, and known for its readability and ease of use.”
**Here’s ChatGPT’s code:**
**3. Rust**
ChatGPT describes Rust as, “A systems programming language used for building high-performance and reliable software, and known for its memory safety and thread safety guarantees.”
**Here’s ChatGPT’s code:**
**4. Go**
ChatGPT describes Go as, “A systems programming language used for building scalable and efficient network and server applications, and known for its simplicity and built-in concurrency features.”
**Here’s ChatGPT’s code:**
**5. C++**
ChatGPT describes C++ as, “A systems programming language used for building operating systems, game engines, and high-performance applications, and known for its control over hardware and memory.”
**Here’s ChatGPT’s code:**
**6. JavaScript**
ChatGPT describes JavaScript as, “A client-side scripting language used for building interactive web applications, and known for its widespread use in web development and its ability to run in web browsers.”
**Here’s ChatGPT’s code:**
**7. C#**
ChatGPT describes C# as, “A general-purpose language used for building Windows desktop applications, games, and web applications, and known for its object-oriented features and integration with the .NET framework.”
**Here’s ChatGPT’s code:**
**8. C**
ChatGPT describes C as, “A systems programming language used for building operating systems, embedded systems, and high-performance applications, and known for its efficiency and low-level control.”
**Here’s ChatGPT’s code:**
**9. TypeScript**
ChatGPT describes TypeScript as, “A superset of JavaScript used for building large-scale web applications, and known for its optional static typing and advanced language features.”
**Here’s ChatGPT’s code:**
**10. R**
ChatGPT describes R as, “A language used for statistical computing and data analysis, and known for its powerful data manipulation and visualization capabilities.”
**Here’s ChatGPT’s code:**
**11. Kotlin**
ChatGPT describes Kotlin as, “A general-purpose language used for building Android apps, server-side applications, and web applications, and known for its conciseness and interoperability with Java.”
**Here’s ChatGPT’s code:**
**12. Scala**
ChatGPT describes Scala as, “A language used for building scalable and distributed applications, and known for its support for functional programming and its integration with the Java Virtual Machine.”
**Here’s ChatGPT’s code:**
**Final thoughts (and a little Forth)**
As a computer languages geek, I found this exercise super fun. That said, there are some things to keep in mind. First, I didn’t test all the code. Testing this many outputs is outside the scope of this article. That said, I did read through the generated code and, for most languages, the code looked good.
**Conclusion:**
My recommendations stand: use it as a tool, but test, test, and test.
**FAQs:**
**Q: How does ChatGPT generate code?**
A: ChatGPT uses a combination of natural language processing and machine learning algorithms to generate code.
**Q: What are the strengths and weaknesses of ChatGPT’s coding capabilities?**
A: The strengths of ChatGPT’s coding capabilities include its ability to generate code in a variety of programming languages, its ability to handle complex logic and algorithms, and its ability to provide accurate and efficient code. The weaknesses of ChatGPT’s coding capabilities include its limited ability to handle very large or complex projects, its limited ability to provide detailed comments and documentation, and its limited ability to provide debugging and testing support.
**Q: Can I use ChatGPT to generate code for my own projects?**
A: Yes, you can use ChatGPT to generate code for your own projects. However, it is important to note that ChatGPT is a tool and not a substitute for human expertise and judgment. It is important to review and test the generated code thoroughly to ensure that it meets your needs and is free of errors.
**Q: How do I get started with using ChatGPT for coding?**
A: To get started with using ChatGPT for coding, you will need to sign up for a free account on the ChatGPT website. Once you have an account, you can access the ChatGPT code generator and start generating code.

