Nussknacker integration with Functional Programming by Piotr Rudnicki

June 10, 2025

In the presentation Nussknacker integration with Functional Programming by Piotr Rudnicki — a mathematician-turned-developer — he shared how his team at Nussknacker is integrating functional programming (FP) into a complex, real-world system. The result? A pragmatic blend of Scala’s powerful FP ecosystem with the practical demands of building a low-code, real-time stream processing platform.

This blog post dives into the key takeaways from Piotr’s presentation, offering a comprehensive look at how functional principles like Cats Effect, Tapir, Tagless Final, and more are being used to improve maintainability, error handling, and system design in Nussknacker.

Whether you’re deep into FP or just exploring how it fits into large-scale systems, this post offers an honest look at both the benefits and challenges of bringing functional programming into production.

Nussknacker integration with Functional Programming: A comprehensive overview

What Is Nussknacker?

Nussknacker is a low-code platform that allows users to design real-time data processing workflows through visual diagrams, known as scenarios. These scenarios are then materialized into actual running applications — either as HTTP services or streaming jobs on Flink.

Its aim? Empowering domain experts — not just developers — to build and manage data pipelines using simple scripts and familiar tools like SQL or Spring Expression Language (SpEL).

 

Why Functional Programming?

While Nussknacker isn’t purely functional “under the hood,” it leverages functional programming principles and Scala’s powerful ecosystem in key areas of the platform. This hybrid approach — embedding FP code into a broader, often imperative system — illustrates both the advantages and integration challenges of using FP in a real-world codebase.

 

Key libraries & patterns in use

Cats Effect

Cats Effect provides an asynchronous runtime and IO monad support, powering side-effect management and resource safety in the system.

  • Resource: Used to manage lifecycles (e.g., classloaders) cleanly, ensuring resources are released properly.
  • Ref: Offers a safer, concurrent mutable reference without the need for manual locks or synchronization.

“Using these abstractions helps avoid resource leaks and simplifies reasoning about concurrency” – Piotr.

 

Validated for error accumulation

Unlike Either, which fails fast, Validated lets you collect multiple errors in a single pass — ideal for validating user inputs or configuration data from diagrams.

 

Lenses (Functional Optics)

Updating nested immutable structures in Scala can lead to what Piotr called the “triangle of death” — repetitive, verbose code. Lenses help compose and reuse accessors to deeply nested fields, streamlining transformations of immutable data.

 

Tapir for typed HTTP endpoints

Tapir is a declarative library for defining HTTP endpoints in a type-safe and backend-agnostic way. In Nussknacker, it allows endpoint definitions to be reused across the codebase, and also powers OpenAPI spec generation.

Tapir’s separation of definition and implementation also allows flexibility: developers can implement endpoints using different effect types like Future or IO.

 

Algebraic Data Types (ADTs)

Piotr emphasized the use of ADTs for precise domain modeling and compile-time exhaustiveness checking — for example, distinguishing between topic names used in data sources vs. sinks.

 

Tagless final for effect polymorphism

Tagless final style enables Nussknacker to abstract over effect types, making it easier to integrate newer FP code with legacy code that still uses Future. This allows gradual FP adoption without a full rewrite.

 

Lessons from the integration journey

Piotr was candid about the challenges of embedding functional patterns into a larger, non-functional codebase. Some parts of the application require “unsafe” effect evaluations, which must be handled carefully to preserve runtime integrity.

Despite the complexity, the FP elements have led to noticeable improvements in:

  • Code quality
  • Maintainability
  • Robustness of error handling
  • Separation of concerns

 

A functional future for Nussknacker

While not everything in Nussknacker is functional today, the direction is clear: functional principles are shaping the architecture more and more, offering a balance between real-world pragmatism and theoretical soundness.

As Piotr wrapped up, audience questions turned to his journey from Haskell to Scala, and how functional programming has tangibly benefited development at Nussknacker. His answer was simple but powerful:

“The quality of the code is better. Decisions like separating endpoint definitions with Tapir were very good ones. Scala and FP help us write maintainable, testable, and expressive code.” – Piotr.

 

Additional resources

Check out more from the MeetUp Func Prog Sweden. Func Prog Sweden is the community for anyone interested in functional programming. At the MeetUps the community explore different functional languages like Erlang, Elixir, Haskell, Scala, Clojure, OCaml, F# and more.