Why Easylang is easier than Python

Easylang was made to help beginners get started with programming. It is open source.

Easylang runs in the browser, but since it is a PWA, you can install it also locally.

As a programming beginner, it’s important to have fun. High entry hurdles - installation marathon, boilerplate code, inscrutable magic code, surprising results are contraporoductive there. Learning programming is getting more and more difficult, there are endless ways if you ask Google. Mostly it is recommended to use Python as a beginner language.


After getting Python running on your PC with some effort, you start with a simple program. Read in two numbers and output the sum:

a = input()
b = input()
print(a + b)
2
3
-> 23

A surprising result. Finding the right solution is not so easy for beginners:

a = float(input())
b = float(input())
print(a + b)

In Easylang the beginner makes the same error, but the parser says immediately when entering the program line that the variable a requires a number.

a = input

ERROR! since input returns a string, but a is a number variable - string variables end with $. Easylang is statically typed unlike Python. Here’s how it finally works:

a = number input
b = number input
print a + b

input reads a string - if the user does not enter a numeric string, the program should notice. In Python you need exceptions to do this:

while True:
    try:
        a = float(input)
        break
    except ValueError:
print(a * a)

In Easylang there is an error function that you can ask:

repeat
  a = number input
  until error = 0
end
print a * a

Array indices start at 0 in Python, for which there are good arguments, but also counter-arguments that are quite weighty in a beginner programming language. A consequence of 0-based arrays are half-open ranges, which are highly unintuitive, especially for beginners.

Some examples in Python:

a = [ 2, 3, 8, 11, 4 ]
# all elements
for i in range(0, len(a)):
    print(a[i])

# 2nd element
print(a[1])

# 2nd to 4th element
for i in range(1, 4):
    print(a[i])

# reverse
for i in range(len(a) - 1, -1, -1):
    print(a[i])

Easylang array indices are 1-based:

a[] = [ 2 3 8 11 4]
# all elements
for i = 1 to len a[]
    print a[i]
end

# 2nd element
print a[2]

# 2nd to 4th element
for i = 2 to 4
    print a[i]
end

# reverse
for i = len a[] downto 1
    print a[i]
end

Now to a concrete algorithm, the Knuth Shuffle:

One goes from the last to the 2nd position. On each pass, a random position including the current position is chosen and this content is swapped with the content at the current position.

In Python arrays start at 0 and ranges are exclusive at the end, so the 2nd position is mapped to 0:

from random import randrange

x = [10, 20, 30, 40, 50 ]
for i in range(len(x) - 1, 0, -1):
    r = randrange(i + 1)
    x[i], x[r] = x[r], x[i]

print(x)

The implementation in Easylang comes closer to the textual pseudocode, which results in a lower cognitive load:

a[] = [ 10 20 30 40 50 ]
for i = len a[] downto 2
    r = randint i
    swap a[i] a[r]
end
print a[]

The simple possibility of a graphical output can be very motivating for beginners. At least that was the case in the days of home computer BASIC.

In Python pygame is recommended for this purpose.

A blue circle on a gray background can be created this way:

import pygame

pygame.init()
screen = pygame.display.set_mode([500, 500])
screen.fill((128, 128, 128))
pygame.draw.circle(screen, (0, 0, 255), (250, 250), 75)
pygame.display.flip()

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

pygame.quit()

In Easylang:

background 555
clear
move 50 50
color 009
circle 15

The comparison was a bit unfair, because the event loop must always be present in the pygame program.


With a bouncing ball, the loop makes more sense in Python:

import pygame

pygame.init()
screen = pygame.display.set_mode([500, 500])
running = True
rad = 60 ; x = 150 ; y = 250
vx = 6 ; vy = 8
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    screen.fill((128, 128, 128))
    pygame.draw.circle(screen, (0, 0, 255), (x, y), rad)
    pygame.display.flip()
    x += vx ; y += vy
    if x > 500 - rad or x < rad:
        vx = -vx
    if y > 500 - rad or y < rad:
        vy = -vy
    pygame.time.Clock().tick(60)

pygame.quit()

In Easylang the animation is event-driven:

rad = 12 ; x = 50 ; y = 50
vx = 1.2 ; vy = 1.6
color 009
#
on animate
  clear
  move x y
  circle rad
  x += vx ; y += vy
  if x > 100 - rad or x < rad
    vx = -vx
  end
  if y > 100 - rad or y < rad
    vy = -vy
  end
end

In Python, there is no explicit block delimiter, which makes code more difficult to read, causes problems with mixing tabs and spaces, makes it difficult to move code blocks in the editor, and actually makes automatic formatting of code impossible.

Python is a great language, but for beginners Easylang is easier.