🏠Welcome

Welcome to the official documentation for the Gauntlet Programming Language.

Gauntlet was made so you can overcome Golang's frustrating design choices. Have a look:

package main

// Seamless interop with the entire golang ecosystem
import "fmt" as fmt
import "os" as os
import "strings" as strings
import "strconv" as strconv


// Explicit export keyword
export fun getTrimmedFileLines(fileName: String): ([]String, Error) {
  // try-with syntax replaces verbose `err != nil` error handling
  let fileContent, err = try os.readFile(fileName) with (null, err)
  
  // Type conversion
  let fileContentStrVersion = (String)(fileContent) 

  let trimmedLines = 
    // Pipes feed output of last function into next one
    fileContentStrVersion
    |> strings.trimSpace(_)
    |> strings.split(_, "\n")

  // `nil` is equal to `null` in Gauntlet
  return (trimmedLines, null)
    
}


fun main(): Unit {
  // No 'unused variable' errors
  let a = 1 

  // force-with syntax will panic if err != nil
  let lines, err = force getTrimmedFileLines("example.txt") with err
  
  // Ternary operator
  let properWord = @String len(lines) > 1 ? "lines" : "line"

  let stringLength = lines |> len(_) |> strconv.itoa(_)

  fmt.println("There are " + stringLength + " " + properWord + ".")
  fmt.println("Here they are:")

  // Simplified for-loops
  for let i, line in lines {
    fmt.println("Line " + strconv.itoa(i + 1) + " is:")
    fmt.println(line)
  }

}

Like what you see? Hit the "Introduction To Gauntlet" button below.

Last updated