Hedy is a pedagogical language designed to simplify learning programming. In this article we are going to see how it can improve teaching programming to students and can inspire language designers to create languages that are simpler to learn.

It is a language that proposes a new approach to teaching programming. It is really interesting especially when it comes to teaching children, something for which many communities are striving for.

The language was created by Felienne Hermans, who also wrote the book the Programmers’ Brain. It has been proven effective, with more than 250 000 programs created by children worldwide. She also gave a presentation in our community: Virtual Meetup: Hedy, a gradual programming language which is clearly the better proof of her success.

Why We Need Hedy

Hedy was designed to solve a problem: to improve the teaching of programming languages. The issue is that many students have a hard time learning even the syntax of a new language. This is a combination of a few problems: it takes time to learn syntax and the syntax itself is confusing.

If you think about it, when learning a natural language you first spend a lot of time on learning the syntax of the language. Only after you have understood the syntax, you learn how to analyze and write sentences in a given language. Instead when learning your first programming language, you learn syntax and semantics at the same time.

The second problem is that the syntax required to create well-functioning programs is much more complex than the one necessary for sentences in natural language. You do not have stringent requirements for newlines and matched parentheses in English or French.

The end result is this:

It was also found that Java and Perl are not easier to understand than a programming language with randomly generated keywords, stressing the difficulties that novices face in understanding syntax.

Hedy: A Gradual Language for Programming Education

What Kind of Programming Language Hedy Is

Hedy Code, from the official GitHub repository

Given what we just said, it should be also clear what Hedy is not. It is not a pedagogical language designed for computer science courses and to teach advanced concepts. It is not a language with a clear organization and, say, support for metaprogramming. So, it is not a language like Racket, that started with that objective.

It is also not a toy language or a graphical language. It is a programming language designed to make it easier to learn the syntax: it starts from nothing and brings people to understand a Python-like language. The target audience of the language are novices from the age of about 11.

This is an important point for both motivation and effectiveness. The second point is more obvious. Alternatives for teaching programming to children, like Scratch, gave students skills that are less transferable to your average language. While the basics concepts of programming are transferable, it is not immediately clear how to transfer your knowledge from Scratch to Python.

Hedy also provides better motivation to students. It looks like a real language and it effectively is. Students actually learn a syntax that is immediately transferable to real programming languages. As they learn more of Hedy, they actually learn Python and they can easily try to build real programs that interest them.

A Gradual Programming Language

The innovation of Hedy is that it takes inspiration from the way we teach natural languages to create a gradual language. That is a language with an increasingly complex syntax, based on how punctuation is taught to novice readers in natural language education. 

Basically, Hedy is designed and taught with levels. Each level adds a new syntax, a concept or it refines and improves upon a known syntax. An example of the last case is a level that replaces the keyword “is” for assignment with the operator “=”.

The paper behind the language shows an example of how the language evolves at different levels:

For example, printing at Level 1 is done by simply using the command print followed by text: 

print Hello !

print Welcome to your first programming lesson

In Level 2, variables are added as a concept, but quotes still are not needed:

print name is Jason

print Welcome to your first programming lesson name

In Level 3, quotation marks are introduced in the print statement, and the code to print is then:

print name is Jason

print ‘Welcome to this programming lesson ‘ name 

In short, Hedy is both a programming language and a teaching approach. Technically, the Hedy compiler is just a transpiler that transpiles Hedy to Python. So, you could download Hedy and use it in your IDE or code editor. However it does not make much sense to do that. That is because Hedy provides an integrated learning environment with many stages. And when the students do not need a restricted environment anymore… Well at that point they know Python, so they can directly use that.

The Learning Experience

The HedyCode website

Effectively, Hedy is implemented in its official website hedycode.com, this is the way to experience Hedy. The website implements the level-based teaching of Hedy in an accessible way.

Nowadays, you can try many languages in a similar web-based way. They are usually called online playgrounds and are available even for traditional complex languages such as Kotlin, C#, Ruby, etc. These platforms are similar to the Hedy experience in the sense that they offer the chance to learn the basic syntax without writing a whole program. For instance, you can learn expressions or how to print to console without writing a main function.

The innovation of Hedy is that it provides a theoretical framework to support more structured learning than just trying simple things out. And it extends this gradual approach to learning the whole language, including more advanced concepts. Hedy is designed to be taught this way, while traditional languages can just be explored using an online playground. However, an online playground does not allow you to use the full power of Kotlin.

On HedyCode you can instead learn the whole language starting from Level 1. You can progress through the levels, going through typical programming problems. Actually, they are a bit more inspired than typical programming problems, but they are equally useful to learn programming.

Hedy Is Great but Still a Work in Progress

Hedy is still a work in progress. For example, the paper mentions 13 levels of learning, but the website has already 23 of them. Furthermore, the starting levels are more well-thought, with several examples and a learning curve that seems sensible. Later levels instead are still worked on and, at the moment, they are a bit rushed and feel more like an addition.

For example, the starting levels are designed to bring you one step further: they show a more complex syntax or a new concept. Instead later levels show more a variation of a previous concept. So, Level 22 teaches you how to combine ! and = in !=, while level 23 teaches you how to combine < or > and =. It does not seem that you need different levels to explain what is essentially the same concept.

Obviously we are not saying this to nitpick, Hedy is already a useful and proven tool. We are saying this to make you aware that Hedy can change. So, if you are a teacher that want to use it in your courses, you must be ready to handle some variations.

Update: after we published the article, they actually merged these particular levels. That is further proof that Hedy is continually improving, which is great for users, but might require you to do some work to keep up. We leave the example mentioned to get you an idea of the small changes that you can expect from time to time.

The Benefits of Learning Levels

Advanced learners can also activate programmer’s mode. It is also useful for teacher giving exercises since it removes hand-holding

The paper mentions a few benefits of levels. Some of which might be more of use in a classroom setting, rather than in a professional one. For example, differentiating between learners of different levels is more useful to keep the attention of students, but it is probably less useful when teaching a DSL to professionals.

Personally, I think that the most unexpected benefit of levels is allowing more precise error messages. For example, if a user mistype prnt instead of print at Level 1, the compiler can understand the error and communicate to the user how to fix it. Namely, it can tell the user that the name of the function is print rather than prnt. A traditional error message instead would be something like prnt not defined, which is both less clear and less useful.

If you think about it, traditional error messages require a computer science-like frame of find. They make sense if you are already familiar with programming or its theoretical foundations. Instead Hedy gives error messages that are meaningful to everybody that is learning the language in that environment.

In other words, the importance of Hedy is not necessarily the language itself, but the teaching approach to introduce newcomers to programming.

This approach can be used in the learning phase for every language, even a DSL. For example, to teach a DSL to a new user you could create a tutorial that gradually introduces new concepts and also uses meaningful error messages. Messages that make sense to people just learning that language.

Conclusion

Hedy is a pedagogical language that proposes a novel way of teaching. We think that this method can also be useful for teaching traditional programming languages and even DSLs.

If you want to know more about Hedy you can: