Skip to content

yoshuawuyts/ge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

gé (earth)

Functional embedded programming language. Single threaded, fast FFI.

warning: this is a WIP fantasy language, vaporware at this stage

Features:

  • Not a silver bullet (do one thing well)
  • Fast interaction with {C,C++,Rust} libraries
  • Works well as glue code on top of native code
  • Small specification with familiar syntax
  • Sugar not included™
  • Single threaded & statically typed
  • Userland packages managed through Nix

Syntax

  1. variables and control flow
  2. functions
  3. tables
  4. packages

1. Variables and control flow

let fs = import fs
let io = import io

# This is a comment
# Variables are immutable by default using the `let` keyword.
let foo = 'bar'

# Variables can be made mutable by using `let mut`
let mut foo = 'bar'
foo = 'baz'

# Variables are bound scoped by closures
let str = import str
let io = import io

# Numbers
let num = 42      # all numbers are doubles

# Strings
let foo = 'bar'   # strings!
let bar = "baz"   # double quotes are fine too
let biz = `
  backticks delimit multiline strings
`

# Loops
let mut num = 0
while (num < 50) {
  io.log(str.fmt('The count is %n', num))
  num = num + 1
}

# Conditionals
fn size (num:num) {
  if (num > 50) {
    ret io.log('Number is big')
  }
  if (num > 30) {
    ret io.log('Number is medium-sized')
  }
  io.log('Number is small')
}

Functions

let str = import str

# functions support hoisting, e.g. can be called
# before declared
io.log(square(3))

# function parameters _must_ specify a type:
fn square (num:num) {
  ret num * num
}

Tables

Packages

The following packages are part of core:

  • ffi
  • io
  • os
  • fs

The following packages are considered standard, but developed outside the language:

  • str
  • math
  • table
# Imports
# There are no globals in ge. The standard library must be
# imported explicitly

Combining functions

Since ge doesn't have any built-ins, output must be passed from one place to another without modifying the original value. In order to achieve this, the pipe operator exists. This can take a single value, or multiple values over time. Values are modified whenever they are passed in:

[ 'hello', 'world' ]
  |> map       # iterate over each value in the array
  |> reverse   # reverse the sequence of each word
  |> join      # join all values together
  |> echo      # print to stdout
  # => ollehdlrow

About

Functional embedded programming language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published