Go+: designed for data science


  1. A static typed language.
  2. Fully compatible with the Go language.
  3. Script-like style, and more readable code for data science than Go.

Go compatibility

Go+ supports bytecode backend and Go code generation.

Go enhancements

We introduce some features for enhancement.

Better error handling

We reinvent the error handling specification in Go+.

Unix shebang

You can use Go+ programs as shell scripts now.

Compatibility with Go

All Go features will be supported (including partially support cgo).

import (
    "fmt"
    "strings"
)

x := strings.NewReplacer("?", "!").Replace("hello, world???")
fmt.Println("x:", x)

Rational number: bigint, bigrat, bigfloat

We introduce the rational number as native Go+ types. We use suffix r to denote rational literals. For example, (1r << 200) means a big int whose value is equal to 2200. And 4/5r means the rational constant 4/5.

a := 1r << 65   // bigint, large than int64
b := 4/5r       // bigrat
c := b - 1/3r + 3 * 1/2r
println(a, b, c)

Range enhancements

We support list comprehension, which makes data processing easier.

sum := 0
for x <- [1, 3, 5, 7, 11, 13, 17], x > 3 {
    sum += x
}
println(sum)

resultMap := [k+","+s for k, s <- {"Hello": "xsw", "Hi": "Go+"}]
println(resultMap)

array := [1, 2, 3, 4, 5, 6]
resultArray := [[a, b] for a <- arr, a < b for b <- arr, b > 2]
println(resultArray)

Error handling

We reinvent the error handling specification in Go+, as is ErrWrap expressions.

expr! // panic if err
expr? // return if err
expr?:defval // use defval if err

Unix shebang

You can use Go+ programs as shell scripts now.

#!/usr/bin/env gop run

println("Hello, Go+")