Skip to content

overview ​

ghūl (pronounced 'ghoul') is a statically typed programming language with three targets: .NET, WebAssembly and native executables through LLVM. The compiler is about 200,000 lines of ghūl, compiles itself, and runs on all three targets.

Every example on this site is a whole program. Press edit & run, change it, and run it in your browser.

drawing: a fractal tree
ghul
use Ghul.Math
use Raster.IMAGE
let spread = 0.4
let shrink = 0.76
let image = IMAGE(500, 500)
branch(
x: double, y: double,
angle: double, length: double,
depth: int
) is
if depth == 0 then
return
fi
let tip_x = x + length * cos(angle)
let tip_y = y + length * sin(angle)
image.stroke(0.6 * cast double(depth))
image.line(x, y, tip_x, tip_y)
branch(tip_x, tip_y, angle - spread, length * shrink, depth - 1)
branch(tip_x, tip_y, angle + spread, length * shrink, depth - 1)
si
image.view(0.0, 0.0, 500.0, 500.0)
image.color(60ub, 40ub, 20ub)
branch(250.0, 10.0, pi / 2.0, 110.0, 10)
image.write("tree.png")
image.show("tree.png")

choosing a target ​

The .NET target is the broadest. A ghūl project is an ordinary .NET SDK project, ghūl code can use any .NET library and NuGet package, and other .NET languages can call it.

The ghul command builds all three targets, and doesn't need .NET for WebAssembly and native programs. It installs without .NET on Linux, x64 and arm64. A WebAssembly program runs under Node.js, or in a browser that supports WasmGC, which is how the examples on this site run. A native program is a single statically linked executable for Linux on x64 or arm64.

.NETWebAssemblynative
build withdotnet build or ghul buildghul buildghul build
runs onthe .NET 10 runtimeNode.js, or a browserLinux x64 and arm64
librariesall of .NET and NuGetghūl's own libraryghūl's own library
calls intoany .NET APIfunctions the loading script supplies, with @externC, with @extern

WebAssembly and native programs use ghūl's own library, ghul-runtime, about 47,000 lines of ghūl, in place of .NET's. It builds the compiler and runs nearly all the Rosetta Code solutions on this site. It has no HTTP, XML or culture-aware formatting, and neither target compiles decimal. A native program calls C, and a WebAssembly program calls JavaScript, through @extern declarations; the JavaScript functions available are the ones the script that loads the program supplies. WebAssembly and native executables list how each target differs from .NET, and .NET integration lists what only .NET provides.

where to go next ​

  • Rosetta Code - about 1,700 tasks solved in ghūl, from one-liners to graphics and games, searchable and nearly all runnable here. The page opens on one picked at random.
  • the tour - the language a topic at a time, every example editable.
  • the online REPL - type ghūl a submission at a time and see each result, in your browser.
  • scripts, the REPL and notebooks - run a .ghul file directly, or type ghūl into an interactive session or a notebook. No project needed.
  • the source - real ghūl to read: the compiler, the runtime libraries, and the tools and smaller libraries around them, about twenty repositories.
  • getting started - ghūl on your own machine, with the .NET SDK or with the ghul command alone.

The language is under active development: whatever the compiler accepts is the definitive reference.