ABS 1.2: background commands & the ability to import files

A few weeks ago the ABS team managed to pull together a new minor release of the language, 1.2.0, which includes loads of interesting features — let’s get to them!

~/.absrc

ABS will now look for a default ~/.absrc file to preload everytime you run a script: this is especially useful if you’d like to dump “base” functions you’re likely to re-use across scripts in a common place. Your .absrc could look like:

1
2
3
tenth = f(x) {
    return x / 10
}

so that in any other abs script you can tenth(x).

~/.abs_history

We also introduced an history file in order to be able to repeat commands easily when using the ABS repl: this is, by default, located at ~/.abs_history and gets synced every time you close a repl session:

1
2
3
4
5
6
7
8
9
$ abs
Hello alex, welcome to the ABS (1.2.0) programming language!
Type 'quit' when you're done, 'help' if you get lost!
`sleep 1`

⧐  quit
Adios!
$ tail ~/.abs_history
`sleep 1`

require(file)

A big one here: you can now require external files through require(path/to/file.abs ). This is a stepping stone in order to allow creating base libraries that can be re-used across ABS scripts, and organize ABS code a tad better.

Background commands

Another big feature here: you can now issue “background” commands that won’t block your ABS script (these commands are executed within a Goroutine).

A background command differs from a regular one simply because it employs an & at the end of the command itself — let’s see them in action:

1
2
3
4
5
`sleep 10`
echo("Hello world!") # This will be printed after 10s

`sleep 10 &`
echo("Hello world!") # This will be printed immediately

You can check whether a background command is done with the .done property:

1
2
3
4
cmd = `sleep 10 &`
cmd.done # false
wait(10000)
cmd.done # true

and we’ve added the wait() function if you need to block until the command is done:

1
2
3
cmd = `sleep 10 &`
cmd.wait() # The script will be blocked for 10s
echo("Hello world!")

Misc

A few more features that made it into this release:

Bugfixes

As usual, we managed to fix some minor bugs along the way:

Now what?

Install ABS with a simple one-liner:

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

…and start scripting like it’s 2019!

PS: Again, many thanks to Erich, who’s been taking a larger role as the weeks went by. Without him, many of the stuff included in 1.2 wouldn’t be possible!

PPS: 1.3.0 is already well underway — expect it at some point in April. We’ll be introducing extremely interesting features such as the ability to kill background commands, so it’s going to be an exciting release!


In the mood for some more reading?

...or check the archives.