ABS 1.5.0: file writers have landed!

A few hours ago I released a new minor version of the ABS programming language, 1.5.0, which includes a couple of interesting features — let’s get to them!

File writers

Probably one of the most exciting things coming out of this release are file writers: > and >>.

1
2
3
4
5
6
7
8
9
10
11
for x in 1..3 {
    x >> "file.txt"
}

`cat file.txt` // 1\n2\n3

for x in 1..3 {
    x > "file.txt"
}

`cat file.txt` // 3

These operators work as file writers when both the left and right arguments are strings, and proceed to either truncate and write (>) or append (>>).

[].unique()

Arrays now have a .unique() method, used to filter out duplicated elements:

1
[1, 2, 2, 3].unique() // [1, 2, 3]

An element is considered duplicate if both its type and string representation match:

1
[1, "1", 2, 2].unique() // [1, "1", 2]

For example, different hashes with the same content are considered duplicates:

1
2
3
a = {"key": "value"}
b = {"key": "value"}
[a, b].unique() // [{"key": "value"}]

Break and continue in for loops

We finally implemented break and continue within for loops: earlier on you could use return to exit a loop but it always felt a tad awkward — with this release this has been fixed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
x = 0

for v in 1..10 {
    if v < 10 {
        continue
    }

    x += v
}

x // 10

for v in 1..10 {
    if v > 1 {
        break
    }

    x += v
}

x // 11

for..in stackoverflow

We also fixed a bug that resulted in a stack overflow when looping a high number of times in a for..in loop:

1
2
3
$ for x in 1..10_000_000 { 1 & 2 }
runtime: goroutine stack exceeds 1000000000-byte limit
fatal error: stack overflow

This has been fixed. As a bonus point, for..in loops are also significantly faster with this change (especially noticeable on larger loops, at around 30% faster):

1
2
3
4
5
6
7
8
9
10
$ cat for-benchmark.abs
start = `echo $(($(date +%s%N)/1000000))`
for x in 1..1_000_000 { 1 & 2 }
end = `echo $(($(date +%s%N)/1000000))`
echo(end.int() - start.int())

$ abs1.4 for-benchmark.abs
820
$ abs1.5 for-benchmark.abs
546

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!


Hi there! I recently wrote an ebook on web application security, currently sold on leanpub, the Amazon Kindle store and gumroad.

It contains 160+ pages of content dedicated to securing web applications and improving your security awareness when building web apps, with chapters ranging from explaining how to secure HTTP cookies with the right flags to understanding why it is important to consider joining a bug bounty program.

Feel free to skim through some of the free chapters published on this blog and, if the content seems interesting enough to you, grab a copy on leanpub, the Amazon Kindle store, gumroad or simply checkout right down below!

Buy the Web Application Security ebook for $6.99

In the mood for some more reading?

...or check the archives.