Serdar Yegulalp
Senior Writer

New functional programming language can generate C, Python code for apps

news analysis
Apr 25, 20163 mins

The open source Futhark makes it easier to program for GPUs that speed up machine learning and other math-intensive apps

fingers keyboard code hands programming
Credit: Thinkstock

Researchers at the University of Copenhagen’s Department of Computer Science recently unveiled Futhark, an open source functional programming language designed for creating code that runs on GPUs, for use in machine learning and other high-performance applications.

Futhark is meant to be more convenient to use than standard C/C++ frameworks for programming GPUs. It can automatically generate both C and Python code to be integrated with existing apps.

Most GPU programming involves using frameworks like OpenCL or CUDA, both of which use variations of C or C++ to generate code that runs on the GPU. Futhark can generate C code, but is its own language, more similar to Haskell or Standard ML than C. (Futhark is itself written in Haskell.)

Futhark’s creators claim that the expressiveness of the language makes it easier to describe complex operations that use parallelism. This includes the ability to support nested parallelizations (parallel operations inside other parallel operations). Futhark can do this “despite the complexities of efficiently mapping to the flat parallelism supported by hardware, as a great many programs depend on this feature,” say the language’s creators.

Preliminary benchmarks pitting Futhark GPU programs against other GPU libraries showed mixed but promising results. For a maximum segment sum test, Futhark was nearly twice as fast as a competing open source project. In other cases, it matched or was only slightly slower than the competition. Futhark’s developers attributed this to the newness of the language and its unrefined approach to allocating and reusing memory.

The current Futhark toolchain can generate code capable of running on either the CPU or GPU, with a variety of targets. For the former, it generates C code compiled by the GCC; for the latter, it generates C code that uses the OpenCL platform. Thus, the same code run on whatever hardware is available to support it, in much the same manner GPU-accelerated apps like the MapD database can fall back to using the CPU if needed.

Python users who want a speed boost can generate code with Futhark wrapped automatically in a Python module. The GPU code runs via PyOpenCL, which is a library for interfacing with GPUs. There are examples of this, such as a Futhark-driven GPU implementation of Conway’s Game of Life.

Because Futhark is still fundamentally a research project, it is not yet as polished or complete as other languages. The documentation is incomplete, but both docs and language are open source on GitHub.

Serdar Yegulalp

Serdar Yegulalp is a senior writer at InfoWorld. A veteran technology journalist, Serdar has been writing about computers, operating systems, databases, programming, and other information technology topics for 30 years. Before joining InfoWorld in 2013, Serdar wrote for Windows Magazine, InformationWeek, Byte, and a slew of other publications. At InfoWorld, Serdar has covered software development, devops, containerization, machine learning, and artificial intelligence, winning several B2B journalism awards including a 2024 Neal Award and a 2025 Azbee Award for best instructional content and best how-to article, respectively. He currently focuses on software development tools and technologies and major programming languages including Python, Rust, Go, Zig, and Wasm. Tune into his weekly Dev with Serdar videos for programming tips and techniques and close looks at programming libraries and tools.

More from this author