DEV Community

Alex Spinov
Alex Spinov

Posted on

Roc Has a Free Fast Functional Language — Here's Why It's the Most Interesting New Language in 2026

Haskell is powerful but impractical for most teams. Elm is limited to the browser. Roc takes the best ideas from both and makes them practical.

What is Roc?

Roc is a fast, friendly, functional language. It compiles to machine code, has no runtime exceptions, and is designed for building reliable software quickly.

Key Design Decisions

  • No runtime exceptions — every error is in the type system
  • No null, no undefined — Result and Option types instead
  • Fast compilation — incremental builds in milliseconds
  • Platforms — Roc apps run on platforms (web server, CLI, WASM)
  • Managed effects — side effects are explicit and controlled

Basic Syntax

app [pf]
    imports [pf.Stdout, pf.Task]
    provides [main] to pf

main =
    Stdout.line! "Hello from Roc!"
Enter fullscreen mode Exit fullscreen mode

Functions and Types

# Type annotation
greet : Str -> Str
greet = \name ->
    "Hello, $(name)!"

# Records
User : { name : Str, age : U32, email : Str }

createUser : Str, U32, Str -> User
createUser = \name, age, email ->
    { name, age, email }

# Pattern matching
describeAge : U32 -> Str
describeAge = \age ->
    when age is
        0 -> "newborn"
        1 .. 12 -> "child"
        13 .. 19 -> "teenager"
        _ -> "adult"
Enter fullscreen mode Exit fullscreen mode

Tag Unions (Enums on Steroids)

Shape : [Circle F64, Rectangle F64 F64, Triangle F64 F64]

area : Shape -> F64
area = \shape ->
    when shape is
        Circle radius -> 3.14159 * radius * radius
        Rectangle width height -> width * height
        Triangle base height -> 0.5 * base * height
Enter fullscreen mode Exit fullscreen mode

Error Handling (No Exceptions)

parseAge : Str -> Result U32 [InvalidNumber]
parseAge = \input ->
    when Str.toU32 input is
        Ok age if age <= 150 -> Ok age
        Ok _ -> Err InvalidNumber
        Err _ -> Err InvalidNumber

# Chain with Result
validateUser : Str, Str -> Result User [InvalidAge, InvalidEmail]
validateUser = \ageStr, email ->
    age = parseAge? ageStr  # ? propagates errors
    if Str.contains email "@" then
        Ok { name: "User", age, email }
    else
        Err InvalidEmail
Enter fullscreen mode Exit fullscreen mode

Pipelines

result =
    "  Hello, World!  "
    |> Str.trim
    |> Str.split ","
    |> List.map Str.trim
    |> List.map Str.toUpper
Enter fullscreen mode Exit fullscreen mode

Roc vs Elm vs Haskell

Feature Roc Elm Haskell
Target Native + WASM Browser JS Native
Speed Very fast N/A (JS) Fast
Learning Easy Easy Hard
Effects Platforms Elm Architecture Monads
Null No No Maybe
Ecosystem Growing Mature (small) Large

Who Should Try Roc?

  • Developers who want functional programming without the PhD
  • Teams tired of null pointer exceptions and runtime crashes
  • Anyone building CLI tools, web services, or WASM modules

Need reliable data processing? Check out my web scraping actors on Apify Store — functional, reliable data extraction. For custom solutions, email spinov001@gmail.com.

Top comments (0)