100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Programming

Roc (language)

Created by Richard Feldman

IntermediateLanguage7.6K learners

Roc is a fast, statically typed, purely functional programming language designed for making it easy to write reliable, performant software, currently under active development with syntax inspired by Elm.

Definition

Roc is a fast, statically typed, purely functional programming language designed for making it easy to write reliable, performant software, currently under active development with syntax inspired by Elm.

Overview

Roc is a general-purpose functional programming language created by Richard Feldman, known previously as a core contributor to the Elm language and community. Roc borrows Elm's clean, expression-oriented syntax and emphasis on friendly compiler error messages, but extends it beyond Elm's browser-focused niche into a general-purpose language intended for command-line tools, servers, scripts, and embedded use cases. Its central design goal is combining the reliability of purely functional programming — no null, no runtime type errors, no uncaught exceptions from ordinary code paths — with runtime performance closer to systems languages like Rust or C than to typical garbage-collected functional languages. Roc achieves much of that performance through its compiler design: it compiles to native machine code (via LLVM), uses an automatic memory management scheme that avoids a traditional tracing garbage collector for many workloads (leaning on techniques like reference counting with compiler-driven optimizations), and specializes generic code at compile time. A distinctive architectural feature is the 'platforms and applications' model: a Roc 'platform' (written in a lower-level language such as Rust or Zig) supplies the runtime, effects, and I/O primitives, while application code written in pure Roc calls into that platform — meaning the same Roc application logic can, in principle, run under different platforms (e.g., a CLI platform, a web-server platform, or a WebAssembly platform) without modification. As of the mid-2020s, Roc remains pre-1.0 and under active development, with its compiler, standard library, and tooling evolving rapidly; it does not yet target production use in the way more mature languages do. It is nonetheless closely watched in the functional-programming community for its ambitious combination of Elm-like ergonomics, purity, and native-code performance, and for Feldman's public design-and-development livestreams that document the language's evolution.

Key Features

  • Purely functional with an Elm-inspired, expression-based syntax
  • Compiles to native machine code via LLVM for near-systems-language performance
  • No null, no runtime type errors, no uncaught exceptions in ordinary Roc code
  • Fast, whole-program type inference (Hindley-Milner-based) with friendly compiler error messages
  • 'Platforms and applications' architecture separates effectful runtime code (platform) from pure application logic
  • Automatic memory management tuned to avoid a traditional tracing garbage collector in many cases
  • Aims to support multiple deployment targets: CLI, web servers, scripting, and WebAssembly
  • Actively developed in the open, with public livestreamed design sessions

Use Cases

Writing command-line tools and scripts with functional guarantees
Building performance-sensitive application logic decoupled from its runtime platform
Experimenting with alternative memory-management strategies for functional languages
Prototyping server-side application logic intended to be reusable across platforms
Research and education in compiler design and functional-language ergonomics

Alternatives

Frequently Asked Questions