Bringing Fortran to Cloudflare Workers via WebAssembly
Cloudflare Workers has supported WebAssembly natively since 2020, when the platform first demonstrated COBOL compilation. Since then, the WebAssembly ecosystem has matured significantly, opening the door for more languages to run server-side. Thanks to recent LLVM developments, Fortran—a language that predates the space age—can now compile to WebAssembly and run on Cloudflare's edge network.
To illustrate the capability, Cloudflare built a handwritten digit classifier: draw a number from 0 to 9 in your browser, and Fortran code executing on Cloudflare's network predicts the digit. The underlying implementation is adapted from a client-side Fortran on WebAssembly demo, with inference running server-side on a Worker.
Why Fortran Still Matters
Fortran (originally FORmula TRANslator) remains a critical tool for scientific computing due to its native support for arrays, matrices and arithmetic operations. Its relevance is measurable: the TOP500 supercomputer rankings are determined by the LINPACK benchmark, originally written in Fortran, which solves systems of linear equations. The benchmark code remains available in Fortran, plus C and Java ports.
NASA's FUN3D computational fluid dynamics software is also written in Fortran, and the language even powers the Voyager probes, which have been running a mix of assembly and Fortran since their 1977 launch. For numerical workloads, Fortran's performance is still hard to beat—there's even CUDA Fortran for GPU programming.
Introducing Fortiche
To streamline Fortran development on Workers, Cloudflare created Fortiche—French for "smart"—a Docker-packaged toolchain that wraps Flang, the LLVM frontend for Fortran, alongside Emscripten. A small LLVM patch is currently required to work around a few unresolved issues. The resulting WebAssembly output is compatible with Cloudflare Workers' V8 runtime.
Fortiche exposes two libraries via build flags: --with-BLAS-3-12-0 for the BLAS linear algebra package, and --with-LAPACK-3-12-0 for LAPACK.
A Minimal Fortran Worker Example
Consider a simple subroutine that adds two integers and stores the result:
fortran subroutine add(a, b, res) integer, intent(in) :: a, b integer, intent(out) :: res res = a + b end subroutine addCompile it with Fortiche, passing --export-func=add to expose the subroutine to JavaScript:
The output directory contains the compiled WebAssembly module, Emscripten's JavaScript glue code, and a Fortiche-generated JavaScript bindings file. The Worker itself is minimal:
javascript import { add } from "./public/add.js"; export default { async fetch(request) { const url = new URL(request.url); // Example: /add?a=3&b=4 const a = parseInt(url.searchParams.get("a")); const b = parseInt(url.searchParams.get("b")); const result = add(a, b); return new Response(`${a} + ${b} = ${result}`); }, };An important detail: all values passed to Fortran are pointers. Each argument—including the result—must be allocated with enough space for a four-byte Fortran integer, and the pointers are handed to the add subroutine. The complete example is available in the Fortiche repository.
Real-World Inference in Fortran
The digit classifier goes beyond simple arithmetic, running a neural network implemented with BLAS routines in Fortran. The full source shows how the same compilation pipeline handles a substantially larger scientific workload—proof that FORTRAN's 1957 beginnings haven't prevented it from finding a home on a modern serverless edge platform.



