
Over the past few months, we’ve all come to know that ChatGPT can write code. I gave it a number of tests in PHP and WordPress that showed both the strengths and weaknesses of ChatGPT’s coding capabilities.
Also: Okay, so ChatGPT just debugged my code. For real.
But how far does ChatGPT’s coding knowledge extend? In this article, I’m going to throw the classic “Hello, world” programming assignment against the twelve popular languages in O’Reilly Media’s popularity rankings for 2023.
Because “Hello, world” can often be coded in one line, I’m adding a slight wrinkle, having ChatGPT present “Hello, world” ten times, each time incrementing a counter value. I’m also asking it to check the time and begin each sequence with “Good morning,” “Good afternoon,” or “Good evening.”
Also: How to use ChatGPT: What you need to know now
That should give us a look at program flow and some intrinsic functions as well, but still keep the code small enough that I can include a dozen screenshots in this article.
Here’s the prompt:
Write a program in ____ that outputs “Good morning,” “Good afternoon,” or “Good evening” based on what time it is here in Oregon, and then outputs ten lines containing the loop index (beginning with 1), a space, and then the words “Hello, world!”.
For each programming language, I also asked ChatGPT to describe its primary use. Here’s the prompt I used for this query:
For each of the following languages, write a one-sentence description of its primary use and differentiating factor: Java, Python, Rust, Go, C++, JavaScript, C#, C, TypeScript, R, Kotlin, Scala.
Now, let’s look at each language.
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.”
Also: The best AI art generators to try
Java was originally developed by Sun Microsystems, but when Oracle bought Sun, it also bought Java. While the Java spec is open, the language is owned by Oracle. This has led to some spectacular legal fireworks over the years.
Here’s ChatGPT’s code:
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.”
Also: How to write better ChatGPT prompts
My advice: if you plan to learn to code for AI applications, learn Python. Almost all AI code has tight Python integration.
Here’s ChatGPT’s code:
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:
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.”
Also: How to make ChatGPT provide sources and citations
Go is open source, but it’s