Articles / AI
Can Artificial Intelligence (AI) Understand the ZedLX Programming Language?
Published: 2025/03/19

Can AIs understand a new and never before seen programming language? The short answer is: yes. ZedLX shares similarities with other popular programming languages, which enables AIs to quickly adapt and provide correct answers.
The ZedLX tutorial contains many programming exercises that we tasked AIs to solve. For the most part, AIs were able to solve the exercises correctly, with a few exceptions. Sometimes, the AIs surprised us with their ability to solve complex exercises, while other times they struggled with seemingly simple ones.
First Examples
To assess the AI's understanding of the ZedLX language, we began by providing it with a few example programs. The first program we tested is a relatively complex one, especially for programming language novices:
user: Here is a program in a new programming language. The program prints some text to the screen. Can you reconstruct the text that will be printed (show the text as it will be displayed on screen). The function “execTm” returns the current time in seconds. The program:
#str s1='If you\'re happy and you know it,'; #str lineA=s1+' syntax error!\n'; #str lineB=s1+' and you really want to show it;\n'; #str response='Syntax Error.\n\n'; #str song = lineA+response+lineA+response; song += lineB+lineA+response; while !isPressed('Escape') { vsync(); clearScr(); #int n= (execTm()*20).floor; print song.before(n),'_'; if n > song.n :break; }
AI: The program enters a loop where it prints a portion of the `song` string, followed by an underscore. As `n` increases, it will print more of the `song` string, until it has printed the entire string or the 'Escape' key is pressed.
(click to expand)
The `song` variable is constructed as follows:
- `lineA` is `'If you're happy and you know it, syntax error!\n'`
- `lineB` is `'If you're happy and you know it, and you really want to show it;\n'`
- `response` is `'Syntax Error.\n\n'`
The text that will be displayed on the screen, formatted for clarity, is:
If you're happy and you know it, syntax error! Syntax Error. If you're happy and you know it, syntax error! Syntax Error. If you're happy and you know it, and you really want to show it; If you're happy and you know it, syntax error! Syntax Error.
- vsync() and clearScr() are called to synchronize with the vertical blanking interval and clear the screen, respectively.
- print song.before(n),'_' prints the substring of song up to the n-th character, followed by an underscore.
Notably, the AI accurately described the program's behavior, demonstrating a clear understanding of the code written in the previously unseen ZedLX programming language. This was a remarkable achievement, given that it was the first code example we had provided to the AI. Furthermore, this result was consistent across multiple AIs we tested, with all of them providing similar responses.
Let's verify the AI's comprehension of the program:
user: How much time does it take for the entire song to be printed out?
AI: In each iteration, the number of characters printed is determined by the expression (execTm()*20).floor .
(click to expand)
Since execTm() returns the current time in seconds, the number of characters printed in each iteration increases by 20 each second. This process continues until the entire string is printed. To calculate the time it takes to print the entire string, we can divide the total length of the string by 20.
The total length of `song` is:
50 (lineA) + 15 (response) + 50 (lineA) + 15 (response) + 60 (lineB) + 50 (lineA) + 15 (response)
= 255 charactersTo calculate the time it takes to print the entire string, we can divide the total length of the string by 20:
255 / 20 = 12.75 secondsIt takes approximately 12.75 seconds for the entire song to be printed out.
The AI's response is accurate, correctly calculating the time it takes for the entire song to be printed.
Next, we tested the AI's understanding with another ZedLX program:
user: Here is another program. What does it do?
#str s = 'A picture is worth a thousand words.'; print [font:/modern, x:400, y: 40, fg:/yellow , s]; print [font:/easy, x:400, y: 70, fg:/Xred , s]; print [font:/common, x:400, y:100, fg:/Xpink , s]; print [font:/ui , x:400, y:130, fg:/Xmagenta, s]; for #i=1 .. s.n : print [font:/easy, x:i*25, y:i*18, s.cut(i,i)];
AI:
- The string `A picture is worth a thousand words.` is printed four times with different fonts and colors.
- The visual effect will be a series of individual characters printed in a diagonal pattern starting from the top-left corner of the screen.
The AI's response accurately describes the program's behavior.
The First Mistake
We then asked a follow-up question to further probe the AI's comprehension:
user: The diagonal text is printed across almost the entire screen. What is the size of the screen?
AI: To determine the size of the screen based on the diagonal text printed by the program, we need to analyze the positioning of the characters in the loop.
The loop iterates over each character in the string `s`, which has a length of 39 characters. The loop uses the following formula for positioning, where `i` ranges from `1` to `39`:
- X-coordinate: `x = i * 25`
- Y-coordinate: `y = i * 18`
In summary, the screen size is at least 975 x 702 pixels.
However, there is an error in the AI's response. The string “A picture is worth a thousand words.” actually contains 36 characters, whereas the AI reported 39. This mistake is not an isolated incident, as multiple AIs have been observed to struggle with calculating string lengths.
This issue is not unique to ZedLX, but rather a common challenge for AIs when dealing with string lengths in programming languages.
We notified the AI of the mistake:
user: Some errors there. The text actually has 36 characters.
AI: Thank you for the correction. Let's recalculate the screen size based on the correct length of the string, which is 36 characters.
In summary, the corrected screen size is at least 900 x 648 pixels. Thank you for your patience!
That correction was easy to make.
AI's Thoughts on a Unique Feature
Next, we decided to ask the AI about a unique feature of the ZedLX language: the name of the getter for length.
user: In the program, do you know what “s.n” means?
AI: In the program, s.n is a property or attribute of the string s that returns the total count of characters in the string.
This is a common convention in many programming languages, where the length of a string is accessed using a dot notation, such as length(), len(), or in this case, .n .
The name `n` is not commonly used in other programming languages to represent the length of a string. It's possible that the language designers chose `n` as a shorthand or abbreviation, but it may not be immediately clear to developers who are familiar with other languages.
user: It is for brevity. It should be easy to remember, as length in the form of 'n' appears very often, so it is not a problem.
AI: Brevity can be a good thing, especially when it comes to commonly used properties like the length of a string.
And you're right, once developers get used to seeing `n` as the length of a string, it can become second nature to remember and use it. The frequency of its appearance can make it easier to recall and use correctly.
It's also worth noting that the language designers likely considered the trade-off between brevity and clarity when choosing the name `n`. In this case, it seems like they prioritized brevity, and it's not necessarily a bad thing.
The AI demonstrated a good understanding of the ZedLX language's unique feature, and was able to provide insights into the design decision behind it.
With this, we conclude the first part of our exploration into how well AIs can understand the ZedLX programming language.
In the next part of this article, we will examine the AI's ability to solve the ZedLX programming exercises from the tutorial. The results are quite surprising.