This chapter gets a TalkTalk program running. We will build the compiler, run one file, and then create a small project. For now, building from the repository is the dependable way to install it.
Install
curl -fsSL https://tlk.sh/install | sh
or if you want to install it somewhere else:
curl -fsSL https://tlk.sh/install | INSTALL_DIR="$HOME/.local/bin" sh
Make sure to check which talk to make sure it returns the bin you just installed. Some systems already have a talk executable on the PATH1.
Run one file
Create hello.tlk:
Then run it:
talk run hello.tlkHello, TalkTalk!
A source file may contain declarations and top-level statements. The value of the final top-level expression is printed when it is not Void:
This prints 36.
Use talk check when you only want diagnostics:
talk check hello.tlk
Both commands accept - as standard input where a source filename is accepted.
Create a package
talk new hellocd hellotalk runHello, Talk!talk test
The generated package contains:
hello/
package.tlk
package.lock
src/main.tlk
tests/hello.test.tlk
package.tlk declares the package's build products and dependencies. package.lock records the resolved dependency graph and should be checked in. Inside a package, talk run chooses the package binary and talk check checks the package targets and tests.
Arguments after -- are passed to the program:
talk run -- one two three
They are available through OS.argc() from the os standard-library module.
Editor support
The compiler includes an LSP server and plain Neovim runtime files:
talk setup nvimtalk lsp --stdiotalk completions fish
talk completions also supports Bash, Elvish, PowerShell, and Zsh. The repository includes a VS Code extension under dev/editors/vscode.
Where to next
Read Syntax and Values and Types for the language's basic shape. Data and Patterns, Generics and Protocols, and Effects cover the features that most distinguish TalkTalk.
-
If you use the
talkthat comes with BSD.. uh, well, maybe talktalk isn't for you. ↩