Language Support
This document contains basic configurations for many popular languages. If you don’t see your favorite language, please feel free to contribute to help those who share your affinity for that language.
Some languages here have built-in support, but others do not. Do not worry that these languages won’t work. They will! Basalt is designed to accomodate any language so long as you yourself can tell us how to use it.
For any language that doesn’t have built-in support, you really just need to
update the setup.install (perhaps also setup.init) to install and
initialize required tooling. Then just update languages to contain the
language definition. A great example for this can be found in the
OCaml example. You can also learn more about this in the
Languages and
Setup references.
These are all rather short examples, but if your competition supports several languages, you may want to break your configuration into multiple files using imports. See an example of an imported setup script.
A quick note on TOML Syntax
Section titled “A quick note on TOML Syntax”TOML is the file format we support for all Basalt configurations. We believe it strikes a unique balance between semantic expressiveness and human readability. The following definitions are all semantically equivalent.
[languages]rust = "latest"[setup]install = '''dnf install -y rust'''
[languages.rust]build = "rustc -o out main.rs"run = "./out"source_file = "main.rs"JavaScript
Section titled “JavaScript”How you configure Javascript will depend a bit on which toolchain/runtime you prefer.
Node has built-in support, so you can simply specify a version under languages.
[setup]init = '''alias nodejs="node-20"'''
[languages]javascript = "latest"[setup]install = '''curl -fsSL https://deno.land/install.sh | sh'''
[languages]javascript = { run = "deno run -A solution.js", source_file = "solution.js" }[setup]install = '''curl -fsSL https://bun.sh/install | bash'''
[languages]javascript = { run = "bun run solution.js", source_file = "solution.js" }TypeScript
Section titled “TypeScript”How you configure TypeScript will depend a bit on which toolchain/runtime you prefer.
[setup]install = '''dnf install nodejs20 -y'''
[languages]typescript = { run = "nodejs solution.ts", source_file = "solution.ts" }[setup]install = '''curl -fsSL https://deno.land/install.sh | sh'''
[languages]typescript = { run = "deno run --no-prompt solution.ts", source_file = "solution.ts" }[setup]install = '''curl -fsSL https://bun.sh/install | bash'''
[languages]typescript = { run = "bun run solution.ts", source_file = "solution.ts" }Python 3
Section titled “Python 3”Python 3 has built-in support, so you can simply specify a version.
[languages]python3 = "latest"Java has built-in support, so you can simply specify a major release version. Basalt supports the following versions out of the box (via OpenJDK):
81121
[languages]java = "8" # or "11" or "21"Naturally, Rust has built-in support.
[languages]rust = "latest"OCaml, my Caml! Enabling OCaml support in your Basalt competition is still fairly straightforward despite Opam having some runtime requirements some other toolchains will not.
[setup]install = '''dnf install -y opam# init Opam for the first timeopam init -y'''
init = '''eval $(opam env)'''
[languages.ocaml]build = "ocamlc -o out solution.ml"run = "./out"source_file = "solution.ml" }Simplicity is just better. Enabling Go support is easy as can be.
[setup]install = '''dnf install -y go'''
[languages]go = { build = "go build -o out main.go", run = "./out", source_file = "main.go" }Obviously the developer’s best friend works in Basalt. Ruby can be set up quite
easily. If you want to install any libraries, you can add additional commands
to install libraries using gem.
[setup]install = '''dnf install -y ruby'''
[languages.ruby]run = "ruby solution.rb"source_file = "solution.rb"React devs fear it; greybeards revere it. C is the grandfather of modern programming languages. How you configure C will depend a bit on which compiler you prefer.
[setup]install = '''dnf install -y gcc'''
[languages]c = { build = "gcc -o out main.c", run = "./out", source_file = "main.c" }[setup]install = '''dnf install -y clang'''
[languages]c = { build = "clang main.c -o out", run = "./out", source_file = "main.c" }How you configure C++ will depend a bit on which compiler you prefer.
[setup]install = '''dnf install -y gcc-c++'''
[languages]cpp = { build = "g++ main.cpp -o out", run = "./out", source_file = "main.cpp" }[setup]install = '''dnf install -y clang'''
[languages]cpp = { build = "clang++ main.cpp -o out", run = "./out", source_file = "main.cpp" }Haskell
Section titled “Haskell”Does a whitepaper even accompany your program? Haskell is rather simple to get up and running with.
[setup]install = '''dnf install -y ghc'''
[languages]haskell = { build = "ghc -o out solution.hs", run = "./out", source_file = "solution.hs" }OOP + FP = loads of fun… Maybe. Scala will require you have Java
already installed. If you’ve already enabled Java, you can simply piggy-back
off of that and avoid adding anything to install Java.
[setup]install = '''dnf install -y java-17-openjdk # Or whichever version you preferdnf install -y https://github.com/VirtusLab/scala-cli/releases/latest/download/scala-cli-x86_64-fedora.rpm'''
[languages]scala = { build = "scala-cli package main.scala -o out", run = "./out", source_file = "main.scala" }