ABS
by Alessandro Nadalin
ABS is a scripting language that works best when you're scripting on your terminal.

ABS is a scripting language that works best when you’re scripting on your terminal. It tries to combine the elegance of languages such as Python, or Ruby, to the convenience of Bash.

Far for bashing Bash (pun intended) or the generic shell command language, we believe there should be a more straightforward alternative to automating tasks.

We believe the pragmatic Python or the elegant Ruby haven’t been able to overcome Bash as the de-facto standard for shell scripting because of the inner simplicity of Bash. Running programs in parallel, interacting with the underlying system, ease of portability… …these are quick and easy wins when you’re writing those .sh files.

We believe, though, there could be an alternative where a programmer would combine the syntax and flexibility of general-purpose languages (Python, Ruby and JS, to name a few) with the benefits of Bash.

This is why we developed the ABS programming language: a language that is a joy to work with in the context of shell scripting: it isn’t here to replace the likes of PHP, Java or Python, neither it wants to diminish the importance of Bash.

ABS tries to mix a more modern syntax with the simplicity of Bash.

Let’s take a look a look at some practical ABS code. We will now call the API of nba.com in order to retrieve the stats for one of last year’s NBA games:

r = $(curl "http://data.nba.net/prod/v1/20170201/0021600732_boxscore.json" -H 'DNT: 1' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36' -H 'Accept: */*' -H 'Referer: http://stats.nba.com/' -H 'Connection: keep-alive' --compressed);

if !r.ok {
    echo("Could not fetch game data. Bummer!")
    exit(1)
}

doc = r.json()

arena = doc.basicGameData.arena.name
city = doc.basicGameData.arena.city

echo("The game was played at the %s in %s", arena, city)

highlight = doc.basicGameData.nugget.text
if highlight.len() {
    echo("The press said: \"%s\"", highlight)
}

# The game was played at the TD Garden in Boston
# The press said: "Thomas scores 19 of 44 points in 4th quarter"
Information updated 07/12/19
Note: This entry has not yet been moderated.
View Comments