Goose Lang 101: Install the Compiler and Print One Line
Part 2 of Goose lang and Flisk.sh 101. The Flisk CLI stays closed. Goose is a whole-program compiler. It writes one C file and can run that C inside its own process through TinyCC. There is no package manager step and no go.mod . Install a release, do not clone yet Prebuilt compilers are on the releases page . Unpack one and put that directory on PATH . The compiler finds its standard library…
Goose Lang 101 delves into the installation of the Goose compiler and demonstrates printing a single line of code. Goose is a full-program compiler that generates a single C file and executes it within its own process using TinyCC. There is no package manager step, no go.mod file, and the installation process involves downloading a prebuilt compiler from the releases page and placing it on the PATH.
The compiler locates its standard library alongside itself, and the build cache is stored under ~/.goose or the GOOSE_HOME directory if set. On macOS, additional quarantine clearance steps may be necessary.
To confirm the language installation, check for the presence of the 'goose' command using the 'which' command. The Goose command requires a .goose file as input; if the help output focuses on LLM providers, rename or remove the binary from PATH and launch a new shell. On Linux, install libc6-dev prior to the first run, while macOS users need to install the Xcode command-line tools.
The Goose compiler needs a C compiler; suitable options include gcc, clang for Linux and macOS, and Visual Studio 2022 or clang for Windows. Since this version lacks threading capabilities, the in-process TinyCC path suffices. Running 'goose hello.goose' is sufficient to execute the code.
The 'print' function in Goose can accept multiple arguments, rendering each argument individually and outputting a single line. The 'print' function does not support format strings. In the example 'hello.goose', the 'print' function outputs "hello, goose". Additional print statements can include variables, such as "answer= ", 42, "ratio= ", 0.75, "yes= ", 3 2.
To create a binary with a name distinct from 'goose', use the 'goose build' command with the '-o' flag specifying the desired output filename. The compiler's C compiler selection can be verified using 'goose toolchain'. The compiler's intermediates are stored under the ~/.goose or GOOSE_HOME directory. If Goose cannot locate a C compiler, it will halt the build process and prompt for installation.
Optional: a VS Code extension is included in the release archive, providing language support through the 'code' command and the 'vscode/goose-language.vsix' extension. The Goose language server facilitates features such as diagnostics, hover information, go to definition, code completion, and renaming. Skip this step if time is limited.
The current installation process does not involve listening on a port, responding to port queries, or handling HTTP requests. Flisk cannot route a process that exits after a single print, which is acceptable for this introductory level. For further details, refer to the official Goose tour documentation and the '01_tour.goose' sample located in the Goose repository's 'docs' and 'samples' directories, respectively.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.