Skip to content

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.

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.

basalt.toml
[languages]
rust = "latest"
basalt.toml
[setup]
install = '''
dnf install -y rust
'''
[languages.rust]
build = "rustc -o out main.rs"
run = "./out"
source_file = "main.rs"

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.

basalt.toml
[setup]
init = '''
alias nodejs="node-20"
'''
[languages]
javascript = "latest"

How you configure TypeScript will depend a bit on which toolchain/runtime you prefer.

basalt.toml
[setup]
install = '''
dnf install nodejs20 -y
'''
[languages]
typescript = { run = "nodejs solution.ts", source_file = "solution.ts" }

Python 3 has built-in support, so you can simply specify a version.

basalt.toml
[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):

  • 8
  • 11
  • 21
basalt.toml
[languages]
java = "8" # or "11" or "21"

Naturally, Rust has built-in support.

basalt.toml
[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.

basalt.toml
[setup]
install = '''
dnf install -y opam
# init Opam for the first time
opam 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.

basalt.toml
[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.

basalt.toml
[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.

basalt.toml
[setup]
install = '''
dnf install -y gcc
'''
[languages]
c = { build = "gcc -o out main.c", run = "./out", source_file = "main.c" }

How you configure C++ will depend a bit on which compiler you prefer.

basalt.toml
[setup]
install = '''
dnf install -y gcc-c++
'''
[languages]
cpp = { build = "g++ main.cpp -o out", run = "./out", source_file = "main.cpp" }

Does a whitepaper even accompany your program? Haskell is rather simple to get up and running with.

basalt.toml
[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.

basalt.toml
[setup]
install = '''
dnf install -y java-17-openjdk # Or whichever version you prefer
dnf 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" }