GENO

Docs/Getting Started

Getting Started with Geno

Installation

For a published release:

pip install geno-lang

For an unpublished checkout or development:

git clone https://github.com/davidiach/geno-lang.git
cd geno-lang
pip install -e ".[dev]"

Your First Program

Create a file called hello.geno:

func greet(name: String) -> String
    example "Alice" -> "Hello, Alice!"
    return "Hello, " + name + "!"
end func

func main() -> String
    return greet("World")
end func

Run it:

geno run hello.geno
# => "Hello, World!"

The REPL

Start an interactive session:

geno repl

Try evaluating expressions:

geno> 2 + 3
=> 5
geno> let x: Int = 10
geno> x * 2
=> 20

Type Checking

Check a file for type errors without running it:

geno check hello.geno
# Type check passed: hello.geno
#   2 definitions

Compiling

To Python

geno compile hello.geno -o hello.py
python3 hello.py

To JavaScript

geno compile --target js hello.geno -o hello.js
node hello.js

Multi-File Projects

Geno supports importing modules from the filesystem. Given this structure:

project/
  Main.geno
  Utils.geno

Utils.geno:

func double(x: Int) -> Int
    example 3 -> 6
    return x * 2
end func

Main.geno:

import Utils

func main() -> Unit
    print(double(21))
    return ()
end func
geno run Main.geno --unsafe
# 42

In the 0.5 series main's result is the process's exit status rather than something the CLI displays, so a program that wants to show a value prints it. Had main been declared -> Int here, geno run would have exited 42 and printed nothing. See Entrypoint results and imports.

Import resolution looks for ModuleName.geno in the same directory as the importing file.

Capabilities

Some builtins require explicit capabilities for security. geno run --cap must be paired with --unsafe for direct interpreter execution, or with --json for embedding API execution:

# Print output
geno run myfile.geno --unsafe --cap print

# File I/O
geno run myfile.geno --unsafe --cap fs

# HTTP requests
geno run myfile.geno --unsafe --cap http

# Environment variables
geno run myfile.geno --unsafe --cap env

# Multiple capabilities (comma-separated)
geno run myfile.geno --unsafe --cap print,fs,env

What's Next?

Rendered from docs/guide/getting-started.md in the Geno repository.