Translate between programing languages with AI

Part 1 of 2

Read Part 2

In this article about “AI-learning (E-learning 3.0)” series, we delve into translation of code, to make it easier to understand. To show that AI is also about learning and not only automation.

Transcending Language Barriers in Coding

One of the most formidable challenges in the world of programming is the diversity of languages. Python, JavaScript, Groovy, and C# — each serves its purpose, but fluency across them can be daunting. Enter ChatGPT 3.5, an AI model that acts as a linguistic bridge, effortlessly translating code from one language to another.

So, if I take the following code:

Python
# Given
number1 = 1
number2 = 2

# When 
result = number1 + number2

# Then
print(result)

and put it into ChatGPT as:

Can you please translate the following Python script into JavaScript:
--
# Given
number1 = 1
number2 = 2

# When 
result = number1 + number2

# Then
print(result)
--

Then the result will be in ChatGPT:

code example in JavaScript

We can translate it into Groovy, C# or any other language!

It’s especially good, when you need to do something in one language, but don’t understand what this method does. Python code example:

Python
pn = str(n).zfill(5)

and put it into ChatGPT 3.5:

Can you please translate the following Python script into JavaScript:
--
pn = str(n).zfill(5)
--

and it gives the following result:

and same goes for the other languages:

Groovy:

C#:

How cool is that?

You are welcome to try the code out directly in the browser, by using web editors: 💻 Python / 💻 JavaScript 💻 Groovy / 💻 C#

You can also try yourself with PHP, Ruby, C, C++, whatever!

Part 2 of 2 – Translate between Code and Gherkin with AI

Read Part 2

Want to read more?

Follow the discussion on LinkedIn

Take the following lesson:

or the full course:

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit exceeded. Please complete the captcha once again.