4 ms·
ChatGPT is very good at two tasks(and many more): 1. Taking pseudo-code for a well defined task and making a function 2. Translating said function into multip
by sireat 4y ago
ChatGPT is very good at two tasks(and many more):
1. Taking pseudo-code for a well defined task and making a function
2. Translating said function into multiple other languages using idiomatic code.
Prompted: "Solve the following problem in Python: Write a function that takes three unsorted lists of integers and returns a median value from the three combined lists"
Got the Python function.
Then the prompts were: Write the same function in APL, C, etc
Final prompt was: Show a sorted list of the programming languages I have mentioned so far
Here's a sorted list of the programming languages you have mentioned so far:
Ada
APL
C
C#
Clojure
Go
Haskell
Java
JavaScript
Kotlin
Lua
Perl
PHP
Prolog
Python
Ruby
Rust
Scala
Nim
(just noticed ChatGPT forgot C++ for which it did give a fine idiomatic answer using standard library)
What was impressive not that ChatGPT solved the problem.
what was impressive:
ChatGPT chose the right data structure automatically(ie, regular C array for C, std::vector for C++, tables for Lua, etc),
dealt with type conversion problems
used correct style of function naming depending on language
Sure tools like C# <-> Java translators are relatively easy and have been around for a while.
However to cover such a wide spectrum of programming languages in different programming paradigms is quite fascinating.