Gauntlet Documentation
  • 🏠Welcome
  • πŸ…Getting Started
    • 🧠Introduction To Gauntlet
  • ‼️Read before Proceeding
  • ⬇️Installation
  • πŸ‘¨β€πŸ’»VSCode Extension
  • πŸ“šBasics
    • πŸ’¨Running Gauntlet
    • πŸ“„File Setup & Hello World
  • πŸ” Scope Variables
  • πŸ–ΌοΈConstants
  • 🧩Functions
  • ↔️If Statements
  • πŸ”‘Ternary Operator
  • πŸ’ Switch-Case
  • πŸ“©Select-Case
  • ➰Loops
  • πŸ“Structs
  • 🧱Interfaces
  • πŸͺͺAliases
  • πŸ“ŽMethods
  • πŸ¦™Lambdas
  • πŸ•ΈοΈMiscellaneous
  • ⚑Advanced Features
    • πŸ”€When-Cases
    • 🚰Pipes
    • ⁉️Try-Statements
    • 🎭Force-Statements
    • 🌯Wrapper Types
Powered by GitBook
On this page
Export as PDF

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 ([]String, Error) getTrimmedFileLines(String fileName) {
  // 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 Unit main() {
  // 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)
  }

}
package main

import fmt "fmt"
import os "os"
import strings "strings"
import strconv "strconv"

func GetTrimmedFileLines(fileName string) ([]string, error) {
	fileContent, err := os.ReadFile(fileName)
	if err != nil {
		return nil, err
	}
	fileContentStrVersion := string(fileContent)
	trimmedLines := strings.Split(strings.TrimSpace(fileContentStrVersion), "\n")

	// Eliminates any 'unused variable' errors
	_, _, _, _ = err, fileContent, fileContentStrVersion, trimmedLines
	return trimmedLines, nil

}

func main() {
	a := 1
	lines, err := GetTrimmedFileLines("example.txt")
	if err != nil {
		panic(err)
	}
	properWord := (func() string {
		if len(lines) > 1 {
			return "lines"
		}
		return "line"
	})()
	stringLength := strconv.Itoa(len(lines))
	fmt.Println("There are " + stringLength + " " + properWord + ".")
	fmt.Println("Here they are:")
	for i, line := range lines {
		fmt.Println("Line " + strconv.Itoa(i+1) + " is:")
		fmt.Println(line)
		// Eliminates any 'unused variable' errors
		_, _ = i, line
	}
	// Eliminates any 'unused variable' errors
	_, _, _, _, _ = a, err, lines, properWord, stringLength

}
Whats
the
meaning
of 
life
There are 5 lines.
Here they are:
Line 1 is:
Whats
Line 2 is:
the
Line 3 is:
meaning
Line 4 is:
of 
Line 5 is:
life

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

NextIntroduction To Gauntlet

Last updated 2 days ago

πŸ