ABS preview-3: loads of bugfixes prior to version 1.0

I just released the preview-3 version of ABS, a terse, pragmatic scripting alternative to Bash. This release is geared towards cleaning up bugs before 1.0, so I thought I’d spend some time going through the changes.

Backward-incompatible changes

We got 1 of them!

I first thought of implementing array destructuring with the very same syntax JavaScript uses:

1
[x, y] = [1, 2]

but this created a few issues with ABS’ parser. For example, when executing code such as:

1
2
x = 10
[y] = [1]

the parser would see x = 10[y], and throw a truckload of errors. A simple fix was to add a semicolon on the line right before a destructuring statement:

1
2
x = 10;
[y] = [1]

Now, considering I had to fix this as well as the fact that I’m always aiming to keep the language as terse as possible, I took some inspiration from Ruby and refactored destructuring to resemble Ruby’s multiple assignments.

In order to destructure an array, you will now have to:

1
x, y = [1, 2]

Easy peasy, with the added bonus of less typing!

Features

Only 1 new feature in this release of ABS: bitwise operators.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ abs
Hello alex, welcome to the ABS programming language!
Type 'quit' when you're done, 'help' if you get lost!
⧐  1 & 0
0
⧐  1 ^ 0
1
⧐  1 | 0
1
⧐  1 >> 0
1
⧐  1 << 0
1
⧐  ~1
-2

Bugfixes

Here’s where the bulk of changes happened:

In other news…

Travis-ci recently launched Windows builds, so I took the opportunity to configure ABS’ builds on Linux, OSX and Windows (#88).

What next?

Ever hoped a bash script could look like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Ask the user what is the best city in the world!
echo("What is the best city in the world?")
selection = stdin()

echo("You picked %s", selection)

tz = $(cat /etc/timezone)
continent, city = tz.split("/")

if selection == city {
    echo("You might be biased...")
} else {
    echo("You know, I heard %s is a nice place as well...", city)
}

# $ abs script.abs
# What is the best city in the world?
# "New York"
# You picked New York
# You know, I heard Rome is a nice place as well...

Hope no more! Simply

1
bash <(curl https://www.abs-lang.org/installer.sh)

and start hacking like it’s 2018!


In the mood for some more reading?

...or check the archives.