github abs-lang/abs 2.0.0
v2.0.0

latest releases: 2.6.0, 2.5.2, 2.5.1...
4 years ago

A fresh new major release of ABS: always be shipping! 🚢

This release was originally intended to be out as 1.13.0, but a backward-incompatible change forced us to shift gears. Don't fear the upgrade as the incompatible changes are extremely easy to address -- and there's only 3 of them.

Let's get rollin'!

Introducing the ABS standard library

🚀 🚀 🚀 this is a big one! 🚀 🚀 🚀

We've started to integrate a standard library within ABS, with modules such as runtime and cli to help you build apps with ease. Requiring a module from the standard library is extremely simple:

runtime = require('@runtime')
runtime.version # 2.0.0

Standard modules are required through the @ prefix. To learn more about ABS's standard library visit the documentation.

Building CLI applications with the @cli module

As part of the initial rollout of the standard library, we've included a @cli module that helps you building CLI applications. It has a simple API that takes advantage of decorators:

#!/usr/bin/env abs
cli = require('@cli')

@cli.cmd("ip", "finds our IP address", {})
f ip_address(arguments, flags) {
    return `curl icanhazip.com`
}

@cli.cmd("date", "Is it Friday already?", {"format": ""})
f date(arguments, flags) {
    format = flags.format
    return `date ${format}`
}

cli.run()

You can save this script as cli and make it executable with chmod +x ./cli. Then you will be able to use the CLI app:

$ ./cli 
Available commands:

  * date - Is it Friday already?
  * help - print this help message
  * ip - finds our IP address

$ ./cli help
Available commands:

  * date - Is it Friday already?
  * help - print this help message
  * ip - finds our IP address

$ ./cli ip  
87.201.252.69

$ ./cli date
Sat Apr  4 18:06:35 +04 2020

$ ./cli date --format +%s
1586009212

Fresh new decorators

Decorators have gone through a major revamp and are now 100% compatible with Python's ones, which we find extremely powerful:

f uppercase(fn) {
    return f() {
        return fn(...).upper()
    }
}

@uppercase
f stringer(x) {
    return x.str()
}

stringer({}) # "{}"
stringer(12) # "12"
stringer("hello") # "HELLO"

The revamp was needed in order to allow any kind of expression to be used as a decorator, and not just plain functions -- for example:

  • @decorator
  • @decorator()
  • @module.decorator()

Deprecated functions

We have removed the functions slice and contains, which were available on both arrays and strings. They have been deprecated for a while and can be easily replaced by the index notation ([1, 2, 3].slice(0, 1) is equivalent to [1, 2, 3][:1]) and the in operator ([1, 2, 3].includes(1) is equivalent to 1 in [1, 2, 3]).

Upgrade guide to ABS 2

We've recapped these 3 backwards-incompatible changes in a simple upgrade guide.

Misc

  • fixed a panic when converting index ranges to strings (#364)

See ya! 👋

Don't miss a new abs release

NewReleases is sending notifications on new releases.