PromptHub
Back to Blog
Developer Tools Web Development

Stop Writing Boilerplate Code! Unit Is the 2D CLI Revolution

B

Bright Coding

Author

16 min read 84 views
Stop Writing Boilerplate Code! Unit Is the 2D CLI Revolution

Stop Writing Boilerplate Code! Unit Is the 2D CLI Revolution

What if everything you hate about coding—endless boilerplate, cryptic terminal commands, the mental gymnastics of visualizing data flow through text—could vanish overnight? What if you could see your program breathe, watch data pulse through connections like blood through veins, and manipulate live virtual objects with the same directness as rearranging furniture in a room?

Here's the painful truth: we've been trapped in 1D thinking for decades. The command line interface, born in the 1970s, still dominates how we build modern web applications. We pipe text streams through invisible channels, mentally simulating what happens between each | symbol. We write thousands of lines of configuration just to connect two services. We debug by printing logs and praying. This isn't engineering—it's archaeological excavation through layers of abstraction.

Enter Unit, the visual programming system that's making seasoned developers abandon their text editors for something radically different. Created by Samuel Timbó and developed as an open-source project at samuelmtimbo/unit, Unit isn't another drag-and-drop toy for beginners. It's a general-purpose visual programming language and environment built with one obsessive focus: Developer Experience.

Unit reimagines the Unix philosophy for the modern era—where commands become manipulable nodes, pipes become visible connections, and your entire program exists as a living, breathing graph that you can directly manipulate. Think of it as the 2D evolution of the CLI that you've been waiting for, but never knew existed.

Ready to have your assumptions shattered? Let's dive deep.


What Is Unit? The Visual Programming System Developers Are Secretly Switching To

Unit is a next-generation visual programming system that combines the power of multiple programming paradigms into a unified, graph-based environment. Born from the mind of developer Samuel Timbó and nurtured through years of careful design, Unit represents a fundamental rethinking of how we interact with code.

At its mathematical core, Unit programs are formally defined as Multi Input Multi Output (MIMO) Finite State Machines (FSM). Every program in Unit is represented as a graph—not as text files, not as abstract syntax trees hidden behind editors, but as a visible, manipulable network of connected units. This isn't cosmetic visualization; it's the actual execution model.

The system draws heavy inspiration from Live Programming, Data Flow, Reactive Programming, Functional Programming, and Object-Oriented Programming. But unlike academic experiments that force you to choose, Unit synthesizes these paradigms into something that actually works for real web development↗ Bright Coding Blog.

What makes Unit genuinely revolutionary is its tight coupling between language and environment. The Unit Programming Language was developed simultaneously with the Unit Programming Environment—a web application designed for effortless composition of new units. The environment feels visual and kinesthetic, giving you the perception of Direct Manipulation of Live Virtual Objects. It's minimalistic, ergonomic, works on mobile, and supports multiple input devices including drawing, gesture, and even voice commands.

The Unix connection runs deep. For experienced programmers, Unit should feel familiar yet liberating: units are like commands, their inputs and outputs are like stdin/stdout/stderr, and connecting them creates scripts. But instead of chaining text through invisible pipes, you see and touch the connections. It's the Unix Philosophy reborn for modern software engineering and web development.

The project's ambition doesn't stop at programming. Unit is evolving toward a sandboxed Web Operating System that enables unprecedented software sharing and collaboration—potentially unifying our fragmented computing experience across devices and platforms.


Key Features That Make Unit Insanely Powerful

Graph-Based Program Representation

Unlike traditional code that hides structure in indentation and brackets, Unit exposes your program's architecture as a visible graph. Every unit is a node. Every connection is an edge. Data flow is immediately comprehensible without mental parsing. This isn't just prettier—it's cognitively transformative for understanding complex systems.

MIMO Finite State Machine Foundation

Units are formally Multi Input Multi Output Finite State Machines. This mathematical rigor means your programs have predictable, analyzable behavior. You can reason about state transitions visually, identify deadlocks by inspection, and compose complex behaviors from simple, verifiable components.

Live, Reactive Programming Environment

Changes propagate automatically through the graph. Modify a unit's configuration and watch dependent units update in real-time. This isn't hot-reloading—it's live programming where the system maintains continuous execution state while you edit.

Multi-Modal Input Support

Unit breaks the keyboard monopoly. Edit through traditional input, drawing connections between nodes, gesture commands, or voice control. The environment adapts to your context—mobile, desktop, tablet—without sacrificing capability.

Web-Native Architecture

Built for the browser first, Unit leverages modern web capabilities. The programming environment runs entirely locally via unit.land, with complete isolation through subdomain sandboxing. Any *.unit.land subdomain represents a fully independent Unit system instance.

Dual Runtime: Browser and Node.js

Unit doesn't trap you in the browser. The same code runs on web and Node.js platforms, with specific APIs for each. Build frontend interfaces, backend services, or full-stack applications within the same visual paradigm.

Bundle-Based Distribution

Programs compile to JSON bundles that can be rendered, shared, and executed anywhere. The build system produces deployable websites from your visual programs, generating optimized JavaScript↗ Bright Coding Blog that loads into standard HTML.


Real-World Use Cases Where Unit Destroys Traditional Coding

1. Rapid API Prototyping and Microservice Composition

Need to wire together three APIs, transform data formats, and handle error fallback? In traditional development, that's hours of boilerplate: HTTP clients, parsers, retry logic, circuit breakers. In Unit, you drag units representing each API, draw connections for data flow, and visually configure transformation nodes. The graph is the documentation. New team members understand the integration in seconds, not days.

2. Interactive Data Visualization Dashboards

Building live dashboards traditionally requires coordinating frontend frameworks, WebSocket connections, state management libraries, and charting components. Unit's reactive graph naturally maps to this problem: data sources are input units, transformations are processing nodes, visual outputs are rendering units. The live programming model means your dashboard updates as you build it—no compile cycles, no manual refreshes.

3. Educational Programming Environments

Teaching programming concepts through text requires students to simultaneously learn syntax, semantics, and execution models. Unit's visual representation separates these concerns. Students see data flow, understand state machines intuitively, and experiment fearlessly. The drawing and gesture inputs make programming accessible to younger learners and those with different cognitive styles.

4. Complex Workflow Automation

CI/CD pipelines, ETL processes, and business workflows often become incomprehensible YAML forests. Unit's graph representation makes dependencies explicit, parallel execution visible, and error paths traceable. When a workflow fails, you see exactly where the data stopped flowing—not which line in a 2000-line configuration file.

5. Collaborative System Design

The visual nature of Unit programs makes them inherently discussable. Screen sharing becomes effective collaboration because both parties see the same structure. Code reviews transform from line-by-line text scrutiny into architectural discussions about graph topology and data flow patterns.


Step-by-Step Installation & Setup Guide

Getting started with Unit is straightforward, whether you want the full development environment or just to experiment with the visual programming system.

Prerequisites

First, ensure you have Node.js (with npm) and Git installed on your system. Unit is built on modern JavaScript and requires these foundations.

Method 1: Full Development Setup

Clone the repository and install dependencies:

# Clone the Unit repository from GitHub
git clone git@github.com:samuelmtimbo/unit.git

# Navigate into the project directory
cd unit

# Install all dependencies
npm install

# Run the setup script to configure the environment
npm run setup

Start the local development server:

# Start the production server
npm start

# Or start in development mode with file watching
npm run watch

Your local Unit environment will be available at http://localhost:4000.

Method 2: Quick Server via npx

For the fastest path to a running environment:

# Launch a local Unit server without cloning
npx @_unit/unit

Then visit http://localhost:4000 in your browser.

Need a different port? Specify it directly:

# Run on a custom port
npx @_unit/unit --port 8042

Method 3: Library Integration

Add Unit to existing JavaScript projects:

# Install as a project dependency
npm install --save @_unit/unit

# Or install globally for CLI access
npm install --global @_unit/unit

Running Tests

Verify your installation:

npm test

REAL Code Examples: Unit in Action

Let's examine actual code from the Unit repository, showing how this visual programming system works under the hood.

Example 1: Rendering a Unit Bundle in the Browser

This example demonstrates how to programmatically render a Unit JSON bundle into a web page—essential for embedding visual programs in existing applications:

// Import the bundle renderer from the web platform module
import { renderBundle } from '@_unit/unit/client/platform/web/render'

// Get a reference to your DOM container
const root = document.getElementById('root')

// Define a Unit bundle as a JavaScript object
// This represents the visual program structure
const bundle = {
  spec: {
    units: {
      // Define a 'helloworld' unit with a unique identifier
      helloworld: {
        id: 'a9cbed12-9a53-11eb-8c2e-f3146b36128d',
      },
    },
    render: true,  // Enable automatic rendering of this unit
    component: {
      // Define the component hierarchy for rendering
      subComponents: {
        helloworld: {},  // Register helloworld as a sub-component
      },
      children: ['helloworld'],  // Specify render order
    },
  },
}

// Render the bundle and receive the system and graph handles
const [system, graph] = renderBundle(root, bundle)

// Retrieve the instantiated unit from the graph
const helloworld = graph.getUnit('helloworld')

// Push a style update to the unit—live modification!
helloworld.push('style', {
  color: '#ffdd00',  // Change text color to golden yellow
})

What's happening here? The renderBundle function takes a DOM element and a bundle specification, then constructs the entire Unit system within that container. The bundle defines a single helloworld unit with a UUID, component structure, and render configuration. After rendering, we obtain handles to both the system (the runtime environment) and graph (the unit network). The graph.getUnit() call retrieves our specific unit instance, and push() sends live data into its 'style' input—demonstrating Unit's reactive, live programming model where modifications propagate immediately through the graph.

Example 2: Booting a System and Running a Merge Sort Unit

This example shows Node.js server-side execution, instantiating a complex algorithm from a JSON bundle:

// Import system boot function for Node.js platform
import { boot } from '@_unit/unit/client/platform/node/boot'

// Import bundle deserializer
import { fromBundle } from '@_unit/unit/spec/fromBundle'

// Import built-in system specifications
import _specs from '@_unit/unit/system/_specs'

// Initialize the Unit runtime system
export const [system] = boot()

// Load a MergeSort algorithm from a JSON bundle file
const bundle = require('./MergeSort.json')

// Deserialize the bundle into an executable unit class
const MergeSort = fromBundle(bundle, _specs, {})

// Instantiate the MergeSort unit with our system
const mergeSort = new MergeSort(system)

// Start execution of the unit
mergeSort.play()

// Push unsorted data into the 'a' input port
mergeSort.push('a', [2, 1])

// Extract the sorted result from the 'a' output port
console.log(mergeSort.take('a')) // Output: [1, 2]

The power revealed: This demonstrates Unit's MIMO (Multi Input Multi Output) architecture in practice. The MergeSort.json bundle contains a complete visual program—likely a graph of comparison and merge units—that implements sorting. We boot a Node.js system, deserialize the bundle against built-in specs, and instantiate it. The play() method activates the state machine. Data enters through push('a', ...) on an input port, flows through the graph's state transitions, and emerges sorted via take('a') from the corresponding output port. This is not calling a function—it's feeding data into a live finite state machine and extracting results from its evolving state.

Example 3: Building a Deployable Website from a Unit Bundle

Unit compiles visual programs to standalone web assets:

# Build a Unit bundle into optimized JavaScript
unit build bundle.unit

This generates an index.js file. Embed it in standard HTML:

<body>
  <!-- The root container for the Unit system -->
  <div
    id="__SYSTEM__ROOT__"
    style="
      display: block;
      position: absolute;
      top: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
    "
  ></div>
  <!-- Load the compiled Unit program -->
  <script type="text/javascript" src="index.js"></script>
</body>

Deployment simplicity: Your entire visual program—potentially hundreds of connected units, complex state machines, reactive data flows—compiles to a single JavaScript file. The __SYSTEM__ROOT__ div becomes the canvas where your program executes. This is how unit.software and other Unit applications deploy: visual programs as standard web content, no runtime dependencies, no special hosting requirements.


Advanced Usage & Best Practices

Leverage Info Mode for Self-Documenting Code

Unit's environment includes Info Mode—access documentation about any unit by interacting with it directly. This makes your programs self-documenting. When sharing graphs, recipients can explore functionality without external docs.

Use unit.moe for Debugging Production Systems

The debugging URL pattern https://unit.moe#<your-url> loads any Unit-based site into the graph editor. Debug unit.software with https://unit.moe#https://unit.software. This exposes the live program structure of any deployed Unit application—incredibly powerful for understanding production behavior.

Design for MIMO Composition

When creating custom units, explicitly design multiple inputs and outputs. The power of Unit emerges from graph connectivity. Single-input, single-output units are possible but waste the compositional potential. Think Unix philosophy: small, focused units that do one thing and connect elegantly.

Sandbox Exploration with Subdomains

Every *.unit.land subdomain is isolated. Use this for safe experimentation—spin up temporary instances without affecting your main environment. This architectural decision reflects Unit's OS-like ambitions.

Version Your Bundles as JSON

Since programs are JSON bundles, standard version control applies. But consider visual diff tools—the graph structure may reveal changes that text diffs obscure. The community is evolving practices here; contribute your findings.


Unit vs. The Competition: Why Visual Programming Finally Works

Feature Unit Node-RED Scratch Traditional Code
Target Audience Professional developers IoT/Automation enthusiasts Beginners/Education Everyone
Paradigm MIMO FSM, Multi-paradigm Flow-based, event-driven Block-based, imperative Text-based, varies
Runtime Browser + Node.js Node.js (server) Browser only Varies by language
Live Programming Native reactive execution Deploy and run Immediate visual feedback Hot reload (limited)
Code Representation Executable graph + JSON bundles JSON flows Proprietary format Text files
Unix Philosophy Core design principle Partial (nodes as commands) None Cultural, not enforced
Mobile Editing Full support Limited Tablet apps only Difficult
Input Modalities Keyboard, drawing, gesture, voice Mouse/keyboard Drag-and-drop Keyboard dominant
Deployment Compiled to static JS Requires Node-RED runtime Scratch ecosystem Compiled/interpreted
Mathematical Foundation MIMO FSM formalism Informal None Varies

The decisive difference: Node-RED visualizes flows but remains event-driven and informal. Scratch teaches concepts but doesn't scale to professional development. Traditional code offers power but buries structure in text. Unit uniquely combines formal mathematical foundations, professional scalability, live execution, and multi-modal interaction—the visual programming system that doesn't ask you to grow out of it.


FAQ: Your Burning Questions Answered

Is Unit a no-code tool for non-programmers?

No. Unit is designed for developers, by developers. The visual representation serves professional needs—comprehension, debugging, live manipulation—not elimination of programming concepts. You still design algorithms, manage state, and compose systems; you just do it through a more powerful interface.

Can I use Unit with my existing JavaScript/TypeScript codebase?

Absolutely. Unit publishes as the @_unit/unit npm package. Import functions like renderBundle, boot, and fromBundle into existing projects. Use Unit for specific visual components while keeping your current architecture.

How does Unit handle version control and collaboration?

Programs are JSON bundles, so Git works naturally. However, the visual environment enables new collaboration patterns: shared graph editing, live pair programming through synchronized environments, and transparent program structure. The roadmap includes deeper OS-level collaboration features.

Is Unit production-ready?

The environment at unit.land is in beta, as is the unit.tools marketplace. The core system is functional and under active development. Evaluate for your use case—the MIT license permits experimentation and contribution.

What makes Unit different from other "visual programming" attempts?

Most visual tools either sacrifice power for accessibility (Scratch) or add visual complexity without conceptual gains (many enterprise tools). Unit's MIMO FSM formalism, Unix philosophy inheritance, live reactive execution, and multi-modal input create genuine capability advantages, not just cosmetic differences.

Can I contribute to Unit's development?

Yes! The project welcomes pull requests. Follow the workflow: iterate solutions locally, open PRs with clear problem/solution explanations, and align with Unit's design vision. Contact Samuel Timbó at @io_sammt or sam@ioun.it for deeper involvement.

Where is Unit development headed?

The roadmap focuses on UI/UX robustness, Web API parity, and Node.js subsystem support (TCP, HTTP). Long-term vision evolves toward a complete Web Operating System with sandboxed software sharing. Read Evolution for details.


Conclusion: The Future of Programming Is Visible

We've explored something rare in developer tools: a genuine paradigm shift that doesn't discard hard-won wisdom. Unit takes the Unix Philosophy—small composable tools, text streams, explicit connections—and elevates it into two dimensions where we can finally see what we've been doing all along.

The MIMO Finite State Machine foundation provides mathematical confidence. The live reactive environment eliminates the edit-compile-run cycle that wastes hours. The multi-modal inputs acknowledge that we're human beings with hands, voices, and spatial reasoning—not just typing fingers. The web-native, sandboxed architecture points toward a future where software sharing becomes as natural as sharing links.

Is Unit perfect? No—it's beta software with evolving documentation and a growing community. But the direction is unmistakable. When experienced developers feel genuine relief using a new tool, when complex systems become comprehensible at a glance, when programming becomes kinesthetically satisfying—something important is happening.

The command line served us brilliantly for fifty years. But we're not terminal-bound hackers in 1970s basements anymore. We're building interconnected, reactive, visual systems for billions of users. We deserve tools that match the dimensionality of our problems.

Stop writing boilerplate. Start seeing your code. Visit unit.land to experience the beta, explore unit.tools for community creations, and star the repository at samuelmtimbo/unit to join the revolution. The 2D CLI isn't coming—it's here, and it's waiting for you to connect your first units.


Follow Unit's development on X: @io_unit
Questions or collaboration? Contact Samuel: @io_sammt | sam@ioun.it

Comments (0)

Comments are moderated before appearing.

No comments yet. Be the first to share your thoughts!

All tools