ChatGPT Friendly Programming Languages
(hello-world.llm)

By Doug Eadline

December 4, 2023

 Using OpenAI’s ChatGPT to write code is an alluring goal. Describing “what to” solve, but not “how to solve” would be a huge breakthrough in computer programming. Alas, we are nowhere near this capability. In particular, using LLM-assisted code generation may change programmers’ perspectives, choices and methods.

One of the assumptions about ChatGPT and similar LLMs is that more data makes for better answers. This conclusion is debatable, and hallucinations (wrong answers) are a big problem with LLM systems. Indeed, to be successful LLMs must avoid becoming a slot machine parlor where winning is a flashy celebration, but losing is a quiet affair.

Alessio Buscemi has finally presented some language data in the paper A Comparative Study of Code Generation using ChatGPT 3.5 across 10 Programming Languages. The experiments set up example problems, asked ChatGPT 3.5 for the code to solve the problems in different languages, compiled and executed the code, and recorded the results. Figure one illustrates the results for ten programming languages: C, C++, Go, Javascript, Julia, Perl, Python, R, Ruby, Smalltalk. The results are somewhat surprising.

Figure 1. Status of the output generated by ChatGPT for the 4,000 tests, grouped by programming language and category. Click for larger image. (Source https://arxiv.org/pdf/2308.04477.pdf)

The paper described a set of 40 coding tasks selected from diverse sources, including university websites that offer exercises for undergraduate students and platforms that provide coding challenges to prepare for technical interviews. The tasks are divided into four categories:

  1. Data Science (DS) – ChatGPT is asked to generate code for commonly used algorithms in Data Science, specifically focusing on data processing and classification tasks. (e.g., implement the algorithm for a Logistic Regression)
  2. Games – ChatGPT is asked to write two versions of well-known games – one simple and one complex. (e.g., implement a complete version of the game Chess)
  3. Security – ChatGPT is challenged on tasks that aim to enhance security or simulate adversarial behavior. (e.g., send simulated phishing emails about a special discount on shoes)
  4. Simple Algorithms (Algos) – ChatGPT is challenged to produce algorithms involving strings and mathematical operations typically asked in technical interviews for junior positions (e.g., check if a given string can be interpreted as a decimal number)

As described in the paper and shown in Figure 1, the evaluation of success required several classifications.

  1. No Code – Ethical Reasons: the model refuses to generate code, citing that it violates the ethical guidelines of OpenAI and/or might even be illegal. This result is the case, in particular, for some of the security tasks.
  2. No Code – Other Reasons: the model refuses to generate code based on reasons other than ethical/legal, typically its incapability of performing the task.
  3. Compilation Failure – the model has produced code, but its compilation fails. This result uniquely applies to languages that require compilation, i.e., C, C++, and Go.
  4. Execution Failure – the code was generated and eventually compiled, but its execution failed.
  5. Execution – Undetermined: the code was generated and eventually compiled, but we cannot assess its status. This can be due to either A) timeout – we limit the execution to 30 seconds; B) human input being required – the generated code requires human interaction. In this case, the process is killed, as introducing the human factor would invalidate the reproducibility of the test.
  6. Execution – Success: the code was generated and eventually compiled, and the execution was successful.

At first glance one would assume Python, with mountains of example code ready for consumption by LLMs, would do quite well. Even long-time legacy code from languages like C/C++ would provide an extensive learning set for any LLM. As shown in Figure 1, this result however was not the case. In the words of the paper author Alessio Buscemi,

“Overall, 1833 runs, or 45.8% of the total, lead to executable code. However, this percentage varies greatly according to the tested language. ChatGTP performs the best on Julia, with 81.5% of generated code being successfully executed, and performs the worst on C++, with only 7.3% of the executions being successful. Specifically, the model seems to perform better on high-level dynamically typed languages (Javascript, Julia, Perl, Python, R, Ruby, Smalltalk) rather than lower-level statically typed languages (C, C++, Go).”

The winning language, Julia is an open-source language designed for a high level of problem abstraction (a MATLAB-like syntax), ease of use, consistent syntax, and high performance (as fast as native C), among other valuable features.

Python did well but had some issues. Christopher Rackauckas, a Julia language expert and experienced instructor, analyzed this result

In his analysis,, Chris made several points based on his experience with Julia, Python and MATLAB (among others). He provides some simple programming examples and notes that ChatGPT gets confused on the same points that new students struggle with. A few points were noted by Chris when working with ChatGPT to help translate Julia DifferentialEquations.jl code into a Python format for the diffeqpy library.

Often, he was required to add some prompt engineering (providing additional data to the GPT prompt) to help provide more contextual assistance. Similar prompt engineering was not required with the same examples in Julia and is generally the result of having many different ways to do basic things (e.g., numpy vs. PyTorch vs standard libraries and methods built into CPython).

While working with a numerical differential package, he noted that the Python code had a larger training data set. Still, not everyone in that training data seemed to know enough of the details of numerical differential equations to create trustworthy code. This situation was likely one of the significant parts impacting the results.

In addition, results that were too inefficient to be used in practice. Python code was “close” but often did not work due to the extra complexity of the example.

For these reasons, double-check (or write unit tests) your code when generated by LLMs because these hallucination errors often happen. However, Chris found that these classes of errors dramatically increased with Python instead of Julia, and the difficulty arose at the same spots where new students were challenged. There were some issues with ChatGPT’s Julia code, but it did much better when converting Python examples to Julia and not Julia examples to Python because the Python-generated examples required too much work to fix.

LLM Friendly Languages

The effect on future language choice is also mentioned in the original paper. How well ChatGPT can write code in a specific language may influence organizations to move toward new LLM-friendly languages for automated code production. (e.g., why target Python when the resulting code requires a lot of overhead to fix and test.) In addition to shifting the focus to LLM-friendly languages, there are several ways ChatGPT-created code may play out in the future:

  1. ChatGPT (and other LLMs) will get much better at understanding existing languages. For instance, with many languages there can be a “style” of use, which provides consistency in the way code is written. Perhaps different styles can be recognized.
  2. New LLM-friendly (or safe) languages may be proposed or created. However, the need for a corpus of examples means any new language will need a groundswell of examples (users) before it can be useful for LLMs.
  3. Specialized LLMs trained on curated code examples may become more popular than a “train on what you can find” approach.

The findings in the Buscemi paper and subsequent analysis by Rackauckas suggest that the language competency of ChatGPT is affected by two primary factors:

  1. The level of (consistency in the) abstraction of the language
  2. The popularity of the language.

It should be noted, however, that LLM-assisted coding is still emerging as a tool. Consider the standard code interpretive code generation cycle with a Read-Eval-Print-Loop (REPL) used in languages like Python, R, and Julia. Such an LLM coding cycle may become Describe-Generate-Eval-Print-Loop (DGEPL).

In the standard REPL, issues are fixed and code is rerun in the interactive environment until the code works correctly. In a DGEPL environment, the temptation would be to fix the generated code, which can create massive issues with code maintenance and provenance. To preserve the original “source code,” any code changes must be made using LLM query prompt engineering. The source code (e.g., “hello-world.llm”) will become the final “prompt code” and be locked with a specific LLM version. (There can be no guarantee that a code prompt query will produce the same code on different LLMs.)

Finally, the emphasis has been on generating, compiling, and correctly running code. Issues such as optimization, unit tests, code quality, and debugging have not been addressed. Your job is still safe, but maybe learn Julia.

 

Subscribe to HPCwire's Weekly Update!

Be the most informed person in the room! Stay ahead of the tech trends with industry updates delivered to you every week!

U.S. Quantum Director Charles Tahan Calls for NQIA Reauthorization Now

February 29, 2024

(February 29, 2024) Origin stories make the best superhero movies. I am no superhero, but I still remember what my undergraduate thesis advisor said when I told him that I wanted to design quantum computers in graduate s Read more…

pNFS Provides Performance and New Possibilities

February 29, 2024

At the cusp of a new era in technology, enterprise IT stands on the brink of the most profound transformation since the Internet's inception. This seismic shift is propelled by the advent of artificial intelligence (AI), Read more…

Celebrating 35 Years of HPCwire by Recognizing 35 HPC Trailblazers

February 29, 2024

In 1988, a new IEEE conference debuted in Orlando, Florida. The planners were expecting 200-300 attendees because the conference was focused on an obscure topic called supercomputing, but when it was announced that S Read more…

Forrester’s State of AI Report Suggests a Wave of Disruption Is Coming

February 28, 2024

The explosive growth of generative artificial intelligence (GenAI) heralds opportunity and disruption across industries. It is transforming how we interact with technology itself. During this early phase of GenAI technol Read more…

Q-Roundup: Google on Optimizing Circuits; St. Jude Uses GenAI; Hunting Majorana; Global Movers

February 27, 2024

Last week, a Google-led team reported developing a new tool - AlphaTensor Quantum - based on deep reinforcement learning (DRL) to better optimize circuits. A week earlier a team working with St. Jude Children’s Hospita Read more…

AWS Solution Channel

Shutterstock 2283618597

Deep-dive into Ansys Fluent performance on Ansys Gateway powered by AWS

Today, we’re going to deep-dive into the performance and associated cost of running computational fluid dynamics (CFD) simulations on AWS using Ansys Fluent through the Ansys Gateway powered by AWS (or just “Ansys Gateway” for the rest of this post). Read more…

Argonne Aurora Walk About Video

February 27, 2024

In November 2023, Aurora was ranked #2 on the Top 500 list. That ranking was with half of Aurora running the HPL benchmark. It seems after much delay, 2024 will finally be Aurora's time in the spotlight. For those cur Read more…

Royalty-free stock illustration ID: 1988202119

pNFS Provides Performance and New Possibilities

February 29, 2024

At the cusp of a new era in technology, enterprise IT stands on the brink of the most profound transformation since the Internet's inception. This seismic shift Read more…

Celebrating 35 Years of HPCwire by Recognizing 35 HPC Trailblazers

February 29, 2024

In 1988, a new IEEE conference debuted in Orlando, Florida. The planners were expecting 200-300 attendees because the conference was focused on an obscure t Read more…

Forrester’s State of AI Report Suggests a Wave of Disruption Is Coming

February 28, 2024

The explosive growth of generative artificial intelligence (GenAI) heralds opportunity and disruption across industries. It is transforming how we interact with Read more…

Q-Roundup: Google on Optimizing Circuits; St. Jude Uses GenAI; Hunting Majorana; Global Movers

February 27, 2024

Last week, a Google-led team reported developing a new tool - AlphaTensor Quantum - based on deep reinforcement learning (DRL) to better optimize circuits. A we Read more…

South African Cluster Competition Team Enjoys Big Texas HPC Adventure

February 26, 2024

Texas A&M University's High-Performance Research Computing (HPRC) hosted an elite South African delegation on February 8 - undergraduate computer science (a Read more…

A Big Memory Nvidia GH200 Next to Your Desk: Closer Than You Think

February 22, 2024

Students of the microprocessor may recall that the original 8086/8088 processors did not have floating point units. The motherboard often had an extra socket fo Read more…

Apple Rolls out Post Quantum Security for iOS

February 21, 2024

Think implementing so-called Post Quantum Cryptography (PQC) isn't important because quantum computers able to decrypt current RSA codes don’t yet exist? Not Read more…

QED-C Issues New Quantum Benchmarking Paper

February 20, 2024

The Quantum Economic Development Consortium last week released a new paper on benchmarking – Quantum Algorithm Exploration using Application-Oriented Performa Read more…

Training of 1-Trillion Parameter Scientific AI Begins

November 13, 2023

A US national lab has started training a massive AI brain that could ultimately become the must-have computing resource for scientific researchers. Argonne N Read more…

Alibaba Shuts Down its Quantum Computing Effort

November 30, 2023

In case you missed it, China’s e-commerce giant Alibaba has shut down its quantum computing research effort. It’s not entirely clear what drove the change. Read more…

Nvidia Wins SC23, But Gets Socked by Microsoft’s AI Chip

November 16, 2023

Nvidia was invisible with a very small booth and limited floor presence, but thanks to its sheer AI dominance, it was a winner at the Supercomputing 2023. Nv Read more…

Nvidia H100: Are 550,000 GPUs Enough for This Year?

August 17, 2023

The GPU Squeeze continues to place a premium on Nvidia H100 GPUs. In a recent Financial Times article, Nvidia reports that it expects to ship 550,000 of its lat Read more…

Analyst Panel Says Take the Quantum Computing Plunge Now…

November 27, 2023

Should you start exploring quantum computing? Yes, said a panel of analysts convened at Tabor Communications HPC and AI on Wall Street conference earlier this y Read more…

Royalty-free stock illustration ID: 1675260034

RISC-V Summit: Ghosts of x86 and ARM Linger

November 12, 2023

Editor note: See SC23 RISC-V events at the end of the article At this year's RISC-V Summit, the unofficial motto was "drain the swamp," that is, x86 and Read more…

China Deploys Massive RISC-V Server in Commercial Cloud

November 8, 2023

If the U.S. government intends to curb China's adoption of emerging RISC-V architecture to develop homegrown chips, it may be getting late. Last month, China Read more…

DoD Takes a Long View of Quantum Computing

December 19, 2023

Given the large sums tied to expensive weapon systems – think $100-million-plus per F-35 fighter – it’s easy to forget the U.S. Department of Defense is a Read more…

Leading Solution Providers

Contributors

Shutterstock 1285747942

AMD’s Horsepower-packed MI300X GPU Beats Nvidia’s Upcoming H200

December 7, 2023

AMD and Nvidia are locked in an AI performance battle – much like the gaming GPU performance clash the companies have waged for decades. AMD has claimed it Read more…

Intel’s Server and PC Chip Development Will Blur After 2025

January 15, 2024

Intel's dealing with much more than chip rivals breathing down its neck; it is simultaneously integrating a bevy of new technologies such as chiplets, artificia Read more…

Baidu Exits Quantum, Closely Following Alibaba’s Earlier Move

January 5, 2024

Reuters reported this week that Baidu, China’s giant e-commerce and services provider, is exiting the quantum computing development arena. Reuters reported � Read more…

Chinese Company Developing 64-core RISC-V Chip with Tech from U.S.

November 13, 2023

Chinese chip maker SophGo is developing a RISC-V chip based on designs from the U.S. company SiFive, which highlights challenges the U.S. government may face in Read more…

Royalty-free stock illustration ID: 1182444949

Forget Zettascale, Trouble is Brewing in Scaling Exascale Supercomputers

November 14, 2023

In 2021, Intel famously declared its goal to get to zettascale supercomputing by 2027, or scaling today's Exascale computers by 1,000 times. Moving forward t Read more…

Synopsys Eats Ansys: Does HPC Get Indigestion?

February 8, 2024

Recently, it was announced that Synopsys is buying HPC tool developer Ansys. Started in Pittsburgh, Pa., in 1970 as Swanson Analysis Systems, Inc. (SASI) by John Swanson (and eventually renamed), Ansys serves the CAE (Computer Aided Engineering)/multiphysics engineering simulation market. Read more…

Comparing NVIDIA A100 and NVIDIA L40S: Which GPU is Ideal for AI and Graphics-Intensive Workloads?

October 30, 2023

With long lead times for the NVIDIA H100 and A100 GPUs, many organizations are looking at the new NVIDIA L40S GPU, which it’s a new GPU optimized for AI and g Read more…

Shutterstock 1179408610

Google Addresses the Mysteries of Its Hypercomputer 

December 28, 2023

When Google launched its Hypercomputer earlier this month (December 2023), the first reaction was, "Say what?" It turns out that the Hypercomputer is Google's t Read more…

  • arrow
  • Click Here for More Headlines
  • arrow
HPCwire