Getting Started

Installation

See the Downloads page for platform-specific installers. The fastest way:

curl -fsSL https://raw.githubusercontent.com/jdalang/jda-lang/main/install.sh | sh

Verify:

jda version

Hello World

Create hello.jda:

fn main() -> i64 {
    print("Hello, world!\n")
    ret 0
}

Compile and run:

jda build hello.jda -o hello
./hello

Or compile and run in one step:

jda run hello.jda

CLI Usage

jda build hello.jda              # compile (output: hello)
jda build hello.jda -o myapp     # compile with explicit output
jda run hello.jda                # compile and execute
jda fmt hello.jda                # format source code
jda test tests/                  # run test suite
jda doc stdlib/                  # generate HTML documentation
jda repl                         # interactive REPL
jda --version                    # show version

Using the Standard Library

Jda ships with 114 packages. Use import to include them:

import "vec"
import "sort"
import "json"
import "net/http"

Or use the --include flag for backward compatibility:

jda build --include stdlib/vec.jda --include stdlib/sort.jda myapp.jda

Install packages locally with the package manager:

jda pkg install vec
jda pkg install sort
jda pkg search hash
jda pkg list

Variables and Types

let x = 42               // integer (i64)
let name = "hello"        // string (&i8)
let flag = true           // boolean
let ch = 'A'              // char literal (i64 65)
const MAX = 100           // compile-time constant
TypeDescription
i6464-bit signed integer (default)
i3232-bit signed integer
i88-bit signed integer (byte)
f6464-bit floating point
&TPointer/reference to type T
boolBoolean (true / false)

Build a CLI Tool

Here’s a simple word-count tool:

import "file_io"
import "string"

fn count_words(text: &i8) -> i64 {
    let count = 0
    let in_word = 0
    for i in range(str_len(text)) {
        let c = byte_at(text, i)
        if c == 32 or c == 10 or c == 9 {
            in_word = 0
        } else if in_word == 0 {
            in_word = 1
            count += 1
        }
    }
    ret count
}

fn main() -> i64 {
    let content = file_read_all_str("input.txt")
    let words = count_words(content)
    print("Words: ")
    print_i64(words)
    print("\n")
    ret 0
}

Compile:

jda build --include stdlib/file_io.jda --include stdlib/string.jda wc.jda -o wc
./wc

Next Steps