
Over the past few months, I’ve learned that you can write code on ChatGPT. I did some tests with PHP and WordPress to show both the strengths and weaknesses of ChatGPT’s coding capabilities.
again: Well, ChatGPT has debugged my code. actually.
But just how far does ChatGPT’s coding knowledge extend? In this article, we pose classic “Hello, world” programming challenges against the 12 most popular languages in O’Reilly Media’s 2023 popularity rankings. increase.
Since “Hello, world” can often be coded in one line, let ChatGPT display “Hello, world” 10 times, incrementing the counter value each time. It also checks the time and asks you to start each sequence with “Good morning”, “Hello” or “Good evening”.
again: How to Use ChatGPT: What You Need to Know Now
This also allows you to see the program flow and some built-in functions, but the code is still small enough to include many screenshots in this article.
The prompt is:
Outputs “Good morning”, “Hello”, or “Good evening” based on the current time in Oregon, plus a loop index (starting with 1), a space, and the words “Hello, world!”.
For each programming language, ChatGPT also explained its main uses. Here are the prompts I used for this query:
Describe in one sentence the main uses and differentiators for the Java, Python, Rust, Go, C++, JavaScript, C#, C, TypeScript, R, Kotlin, and Scala languages.
Let’s take a look at each language.
Java
ChatGPT describes Java as:
again: Best AI art generators to try
Java was originally developed by Sun Microsystems, which acquired Java when Oracle acquired Sun. The Java specification is open, but the language is owned by Oracle. This has led to some spectacular legal fireworks over the years.
Here is the code for ChatGPT:
python
ChatGPT describes Python as “a general-purpose language used for data analysis, artificial intelligence, web development, and automation, known for its readability and ease of use.”
again: How to create better ChatGPT prompts
My advice: If you plan to learn to code AI applications, learn Python. Almost all AI code is tightly integrated with Python.
Here is the code for ChatGPT:
rust
ChatGPT describes Rust as “a systems programming language used to build high-performance, reliable software, known for its memory-safety and thread-safety guarantees.” I’m explaining.
Here is the code for ChatGPT:
go
ChatGPT describes Go as “a systems programming language used to build scalable and efficient network and server applications, known for its simplicity and built-in concurrency capabilities.”
again: How to get ChatGPT to provide sources and citations
Go is open source but maintained by Google. go. Google. get it?
Here is the code for ChatGPT:
C++
ChatGPT describes C++ as “a systems programming language used to build operating systems, game engines, and high-performance applications, known for controlling hardware and memory.”
Here is the code for ChatGPT:
JavaScript
ChatGPT describes JavaScript as “a client-side scripting language used to build interactive web applications, widely used in web development and known for being able to run in a web browser.”
again: Future versions of ChatGPT could replace most of the work people do today
And along with CSS (one of the web’s leading visual design languages), JavaScript is directly responsible for 87.45% of the profanity I’ve uttered over the last nine years or so.
Here is the code for ChatGPT:
C#
ChatGPT describes C# as “a general-purpose language used to build Windows desktop applications, games, and web applications, known for its object-oriented features and integration with the .NET framework.”
again: How to create a resume using ChatGPT
C# is a proprietary language provided by Microsoft. I have taught him at the University of California, Berkeley Extension for over 10 years. This is a very interesting gateway language, primarily for someone who wants to do programming in his Microsoft environment.
Here is the code for ChatGPT:
C.
ChatGPT describes C as “a systems programming language used to build operating systems, embedded systems, and high-performance applications, known for its efficiency and low-level control.”
again: How to create Excel formulas using ChatGPT
It is said that you never forget your first love. Before he taught himself C programming in the days of wooden ships and iron programmers, he didn’t really like programming languages. But then I started using C and my world changed. it was love Something about the brevity simplicity of this language spoke to me on a deep, primal level. That’s probably an over-share, but it’s also true. C has always been my first syntactic love.
Here is the code for ChatGPT:
TypeScript
ChatGPT describes TypeScript as “a superset of JavaScript used to build large-scale web applications, known for its optional static typing and advanced language features.”
again: How to code using ChatGPT
TypeScript is also a Microsoft product, but unlike C#, it’s open source and non-proprietary.
Here is the code for ChatGPT:
R.
ChatGPT describes R as “a language used for statistical computing and data analysis, known for its powerful data manipulation and visualization capabilities.”
Here is the code for ChatGPT:
Kotlin
ChatGPT describes Kotlin as “a general-purpose language used to build Android apps, server-side applications, and web applications, known for its simplicity and interoperability with Java.”
again: What is Auto-GPT? What you need to know about the next powerful AI tool
Kotlin was developed by JetBrains, a small company that also creates PhpStorm, my current favorite development environment.
Here is the code for ChatGPT:
scala
ChatGPT describes Scala as “a language used to build scalable distributed applications, known for its support for functional programming and integration with the Java Virtual Machine.”
Here is the code for ChatGPT:
final thoughts
As a computer language nerd, I found this exercise very enjoyable. That said, there are a few things to keep in mind. First, I haven’t tested all the code. Testing that many outputs is beyond the scope of this article. That said, I read through the generated code and it looked good in most languages.
again: AI can automate 25% of all jobs.The highest (and lowest) risks are:
However, ChatGPT can lose threads. Out of curiosity, I decided to ask him to generate the same code in Forth, a very funky but fun language. The generated code was Forth (the leading colon is a useless gift), but the code block was labeled “perl” (another very fun and funky language).This code is definitely no Pearl:
Also note the Scala output (see above). I have never programmed in Scala and am not very familiar with it. AI used to provide syntax coloring for all other languages, but for Scala it didn’t seem to have that information at hand, so ChatGPT doesn’t seem to.
As with all my other visits down the rabbit hole in ChatGPT and coding, I was impressed, but also cautious. Here are my recommendations: Use it as a tool, but test, test, test.
You can follow my daily project updates on social media. follow me on twitter @DavidGewirtzon Facebook at Facebook.com/DavidGewirtz, on Instagram at Instagram.com/DavidGewirtz and on YouTube at YouTube.com/DavidGewirtzTV.