Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Blogs / Programming Language Design

Design of a Programming Language for Beginners

Created: 2023/12/08 by The Wizard of Finity

A source code of a program for drawing a wheel
An example ZedLX program

This is the first article of a programming language design blog. In this blog I would like to present some of my thoughts concerning design of the ZedLX programming language.

ZedLX is intended to be a programming language with a specific purpose: to serve as a first language a beginner should learn. Two questions immediately arise:

  1. Is it necessary to have a separate programming language for that specific purpose?
  2. What specific features should such a language provide?

The answers to those questions can never be known for certain, as it is virtually impossible to create a controlled experiment that could provide the answers. Therefore, any answers to the two stated questions are just some people's opinions. As such, various people may give various opinions on the subject, with no certain way of discerning who is right and who is wrong.

From a historical perspective, the majority opinion on such 'hard to prove' issues has almost always been in the wrong. Even the opinions of experts were commonly highly biased, usually made just to suit the expert himself. For example, many doctors and other certified professionals were commonly selling snake-oil medicines in the past, and this practice is widespread even today. It is easy to sell snake-oil to a non-expert, as he lacks the knowledge required to recognize the snake-oil.

The best way to discern correct opinions from the incorrect ones is to scrutinize the arguments provided in support of each opinion. I would like to provide arguments from my side of the story; it is the story of a programming language designer. It is up to the reader to decide who is right and who is wrong.

The Case for Special-Purpose Programming Languages

At the outset, it should be immediately clear that special-purpose programming languages are the accepted and successful paradigm for many use-cases.

Can an all-purpose programming language even be imagined? Of course not, it is an absolutely ridiculous concept. Just try to imagine a language intended to serve both as a shell language (like bash, PowerShell, or and a high-performance language (like C++ and Rust). Even the features of distributed computing, and features of Matlab and SQL must be added to any supposed all-purpose language.

Obviously, an all-purpose programming language cannot exist. Any attempt to make such a language would only result in a complete disaster.

The kind of a programming language closest to an 'all-purpose' programming language is a 'general-purpose' language. A general-purpose language attempts to be good at many common use-cases, although it usually manages to be really good only at one or two use-cases. Here are a few examples:

C++ for high-performance local computing
Java for easy multi-platform deployment, especially concerning mobile applications
JavaScript for hypertext and web pages
Rust the same as C++ but with additional security, but less direct OS inter-operability
Python as a high-level scripting language and a quick-prototyping language

Stretching a General-Purpose Programming Language

It is always possible to slightly 'stretch' a programming language into territory of a new use-case. This method is especially useful if there is no other existing language that covers the new use-case very well.

A programming language that attempts to cover a wide range of use-cases has an obvious advantage of eliminating the task of integrating various components of a single program written in different languages. In other words, it allows for more monolithic programs, which is an important advantage. For that reason alone, most programming languages are commonly 'stretched' to cover even those use cases for which they are not well-suited.

Such purpose-stretching is in no way detrimental. Every additional use-case that a programming language can cover should be welcomed.

The true problem arises when people start thinking that a language excells at a purpose that is in reality a stretched-purpose, just because the language in question is a general-purpose language. Generally, no such inference can be directly made, more precisely, it is obvious that a language might or might not be well-suited for a particular stretched-purpose. It all depends on many details.

If no other good programming language exists for a certain purpose, then a certain stretched-purpose language might be the best existing language for that purpose. An obvious example is Python for the purpose of learning to program. Python was not initially intended to be a first language a beginner should learn.

Thirty years ago, when Python did not exist, the language for approximately the same set of use-cases was BASIC. While BASIC is a lousy language from a modern perspective, before Python existed it was the best language for certain purposes. BASIC was, for many years, the preferred language for the purpose of the first programming language a beginner should learn.

As the years went by, it became quite obvious that BASIC is not a very good language for beginners. As one of the oldest programming languages, it was promoting the use of many obsolete programming principles.

Features for Beginners: Graphics

There can be no controversy regarding the usefulness of computer graphics in a programming language for beginners. The immediately-available built-in graphics is a top priority in a language for beginners, and the ZedLX provides it, in the best and simplest way possible.

The built-in graphics are not just a likeable visual gimmick. Graphics allows beginners to easily visualize values, variables, changes of values, program flow and the passage of time. Such visualizations are employed almost everywhere throughout the ZedLX tutorial, for example in the chapter Simple Motion and in the chapter Variables. Easy to use computer graphics is an absolute necessity in a language for beginners.

The built-in and immediately available computer graphics is a huge advantage for ZedLX when compared to most other programming languages.

Features for Beginners: Commonality

The between-language 'commonality' of features allows a beginner to easily learn another programming language. ZedLX was designed with a goal of high feature commonality with most popular languages.

The syntax of ZedLX is a mix of common syntactic elements of the most popular programming languages. The idea is the following: after a beginner learns the syntax of ZedLX, he can easily learn any other popular language. ZedLX language is intended as a starting point that allows a beginner to easily overcome the most common beginner's obstacles. After a beginner has mastered the basics with ZedLX, he can easily switch over to some other language of his preference.

That is the reason why ZedLX requires statements to end with a semicolon. The semicolon is, in most cases, superfluous, but it is required by most other languages. Yes, the semicolon is probably a relic of the past, where both Python and BASIC easily do without it. The semicolon-kind of syntax was invented in the 1970's. Most programmers have become accustomed to the semicolon-kind of syntax to such a degree, that they will simply reject any language lacking semicolons as 'not serious'. As a programming language designer, I can tell you that semicolons are in most cases unnecessary, and that programming languages would be better without them. ZedLX uses semicolons just to 'imitate' other popular languages.

Let's make a comparison with another popular language for beginners: Scratch. While the syntax of Scratch was certainly designed for beginners, it is, at the same time, an odd syntax. This creates a serious issue: a beginner accustomed to Scratch can experience problems when trying to learn other languages. It is my opinion that a beginner's language should not be 'radical' with features to such a degree as Scratch is, and for that reason alone I don't recommend Scratch as the first programming language.

ZedLX attempts to advance beginners' ability to switch to another programming language. It can be very advantageous for a beginner to experience more than one programming language. It can be advantageous to have diminished fear of switching between languages. It can be advantageous to experience differences of concepts, opinions and paradigms, to be able to escape from an echo-chamber, a bubble commonly created by practitioners of only one programming language.

To advance the language-switching abilities of beginners, ZedLX strives to provide commonality with popular programming languages.

Features for Beginners: Syntax

A programming language for beginners certainly needs to have a clear and simple syntax. However you turn this requirement around, it always ends up giving an advantage to a special-purpose language. The syntax of a special-purpose language can be tailored for that special purpose. A special-purpose language will always have a significant advantage over the general-purpose language when the language syntax is concerned.

Another design goal of ZedLX syntax was to reduce the number of symbols required to write a statement, especially regarding the non-alphabetic symbols. This feature should make it easier for beginners to write statements, and it should reduce the number of errors made by beginners. For that reason, the parentheses for conditions in conditional statements have been rendered optional (as they are superfluous). Also, the syntax of the for statement has been greatly simplified compared to other languages.

While Scratch takes a different approach to the problem of compliacted syntax, it is actually trying to overcome a beginner's obstacle in a bad way. It is not really the case that writing statements is too hard for beginners; the true problem is that beginners find it hard to learn the syntax of overly-complicated general-purpose languages. A better solution for the problem of complex syntax is to just simplify the syntax, not to throw it away completely as Scratch does.

For example, ZedLX supports C-style for loop syntax. However, as that syntax is deemed too complicated for beginners, ZedLX also supports a simplified form of for loop syntax, used widely throughout the tutorial. The simplified for loop requires less characters than a C-style for loop, and it increases the clarity of the source code.

A quick look at a few example programs from the ZedLX tutorial is all the evidence an experienced programmer needs to ascertain the high level of clarity and simplicity of the ZedLX syntax.

Features for Beginners: The Type System

The issue of the 'best' kind of type system is usually very contentious, but it also commonly results in misguided opinions. Why? There is no 'best' kind of type system per se. The 'best' kind of type system commonly depends on the purpose of the language. For different kinds of purposes, different kinds of type systems are better ones.

What features should a type system have in a language for beginners? The type system should certainly attempt reduce the number of hard-to-find errors that beginners make. It should also make the source code of programs clearer.

It can be immediately noticed that those are common features of a static type system. However, one of the most popular languages for beginners, Python, uses a dynamic type system. A dynamic type system is suitable for fast prototyping, which is one of the use-cases where Python excels the best. Python was not originally intended for beginners, so it should not be surprising that it uses a dynamic type system. A dynamic type system is sub-optimal for beginners, but they get used to it, in the same manner as they would get used to BASIC in the past.

Most teachers and 'influencers' have become so accustomed to a dynamic type system in a language for beginners, that a claim is commonly being made of dynamic type systems being 'obviously' better, accompanied by a few weak arguments. Such arguments are nothing but bad excuses, so that teachers can boast why some language of their choice is 'a perfect' one for beginners.

To reduce the amount of effort a beginner expends when typing in a program, ZedLX employs some simple forms of type inference. For example, the type of a for loop's control variable is usually inferred. Nameless initialiters, described in the chapter The Type color, also use a a kind of type inference.

This is sufficient to make explicit type names rarely required in a source code, except in those places where explicit type names significantly contribute towards clarity.


Since this article is becoming quite long I'll just wrap it up.

ZedLX attempts to improve on several important features of programming languages for beginners. In this article, a few of those features were briefly discussed:

  • computer graphics, immediately available
  • commonality with popular programming languages
  • syntax, must be simple and clear
  • type system, static vs. dynamic

A quick discussion of each feature was made in the article, with a few examples and comparisons.

ZedLX has many other features that cater to beginners.

Unrelated note 1: This is a low frequency blog. Expect just a few posts per year.