Skip to content

forthix/forthic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Forthic

Wrap. Compose. Abstract

A stack-based, concatenative language for wrapping existing code in composable transformations. Forthic provides both the module system to wrap your code and the standard operations to manipulate it cleanly.

Built with Category Theory in mind, proven through hundreds of engineering tools at LinkedIn, and powering new kinds of Agentic architectures.

Why Forthic? | Core Concepts | Get Started


What is Forthic?

Forthic makes your existing code composable by providing:

  1. A simple module system to wrap your code as Forthic words
  2. Standard operations for clean data transformations
  3. Stack-based composition that makes building higher-level abstractions trivial

The Core Insight: Solving software problems is fundamentally about understanding relationships and applying transformations. This is the essence of Category Theory--the concepts that that Forthic was designed around.

Wrap code in Forthic words, compose them as transformations, and unlock systematic approaches to solving complex problems.

Deep dive: Core Concepts β†’


Quick Example

Creating a Forthic Module

TypeScript:

import { DecoratedModule, Word } from '@forthix/forthic';

export class AnalyticsModule extends DecoratedModule {
  constructor() {
    super("analytics");
  }

  @Word("( numbers:number[] -- avg:number )", "Calculate average")
  async AVERAGE(numbers: number[]) {
    return numbers.reduce((a, b) => a + b, 0) / numbers.length;
  }

  @Word("( numbers:number[] stdDevs:number -- filtered:number[] )", "Filter outliers", "FILTER-OUTLIERS")
  async FILTER_OUTLIERS(numbers: number[], stdDevs: number) {
    return this.filterOutliers(numbers, stdDevs);
  }
}

Python:

from forthic import DecoratedModule, ForthicWord

class AnalyticsModule(DecoratedModule):
    @ForthicWord("( numbers -- avg )", "Calculate average")
    async def AVERAGE(self, numbers):
        return sum(numbers) / len(numbers)

Ruby:

class AnalyticsModule < Forthic::Decorators::DecoratedModule
  word :AVERAGE, "( numbers -- avg )", "Calculate average"
  def AVERAGE(numbers)
    numbers.sum.to_f / numbers.length
  end
end

Using Your Module

["analytics"] USE-MODULES

# Simple composition
raw-data 2 FILTER-OUTLIERS AVERAGE

# Define reusable transformations
: CLEAN-AVERAGE   2 FILTER-OUTLIERS AVERAGE ;

# Use it anywhere
dataset-1 CLEAN-AVERAGE
dataset-2 CLEAN-AVERAGE

Runtimes

Choose your language - all runtimes share the same Forthic semantics and can communicate via a gRPC-based multi-runtime architecture:

Runtime Status Repository Best For Multi-Runtime
TypeScript βœ… Production forthic-ts Node.js, browsers, web apps gRPC, WebSocket
Ruby βœ… Production forthic-rb Rails apps, web services gRPC, WebSocket
Python 🚧 In Progress forthic-py Data science, ML, analytics gRPC, WebSocket
Rust 🚧 In Progress forthic-rs Performance, systems programming gRPC (planned)
Java πŸ“‹ Planned forthic-java Enterprise applications TBD

🌐 Multi-Runtime Capabilities

Call code seamlessly across TypeScript, Python, Ruby, Rust, and more.

// TypeScript calling Python's pandas
import { GrpcClient, RemoteModule } from '@forthix/forthic/grpc';

const pythonClient = new GrpcClient('localhost:50051');
const pandas = new RemoteModule('pandas', pythonClient, 'python');

await interp.run(`
  ["pandas"] USE-MODULES
  [records] DF-FROM-RECORDS DF-ANALYZE
`);
# Ruby calling TypeScript's fs module
interp.run(%{
  "localhost:50052" CONNECT-RUNTIME
  ["fs"] USE-TS-MODULES
  "/app/data" DIR-EXISTS?
})

Why multi-runtime?

  • ✨ Use Python's data science libraries from TypeScript
  • ✨ Access Node.js's npm ecosystem from Ruby or Python
  • ✨ Call Rust's high-performance code from any runtime
  • ✨ Build polyglot systems without rewriting existing code using common, high-level Forthic

Learn more about multi-runtime β†’



Key Features

1. Category Theory Foundations

Mathematical foundations provide systematic thinking:

  • Morphisms - Words are transformations
  • Composition - Concatenation is function composition
  • Inverses/Adjoints - Systematic problem-solving patterns

Deep dive: Categorical Coding β†’

2. Easy Module Creation

Wrap your existing code with simple decorators:

@Word("( input -- output )", "Description")
async MY_WORD(input: any) { return yourCode(input); }

3. Rich Standard Library

Proven operations for clean data manipulation:

  • array - MAP, SELECT, SORT, GROUP-BY, ZIP, REDUCE (30+ operations)
  • record - REC@, <REC, MERGE, KEYS, VALUES
  • string - SPLIT, JOIN, UPPERCASE, LOWERCASE, TRIM
  • math - +, -, *, /, ROUND, ABS, MIN, MAX, AVERAGE
  • datetime - >DATE, >DATETIME, ADD-DAYS, FORMAT
  • json - >JSON, JSON>, JSON-PRETTIFY
  • boolean - ==, <, >, AND, OR, NOT, IN

Module Reference β†’

4. Multi-Runtime Execution 🌐

Call code across language boundaries seamlessly:

  • TypeScript ↔ Python ↔ Ruby ↔ Rust
  • Use the best library for each task
  • Build polyglot microservices
  • Migrate incrementally

Multi-Runtime Documentation β†’


Getting Started

Choose Your Runtime

Start with the runtime that matches your project:

Each runtime repository includes:

  • Installation instructions
  • Getting started guide
  • Runtime-specific examples
  • API documentation

Learn Core Concepts

Explore Multi-Runtime


Documentation

Language & Concepts

Philosophy

Standard Library

  • Module Documentation - Complete reference for all standard operations
    • array - Collection operations
    • record - Object/dictionary manipulation
    • string - String transformation
    • math - Mathematical operations
    • datetime - Date/time handling
    • json - JSON serialization
    • boolean - Comparisons and logic
    • core - Stack and interpreter operations
    • fs - File system operations (TypeScript)

Multi-Runtime


Philosophy

Core beliefs:

  • Software is fundamentally about transformations and relationships
  • Category Theory provides a systematic framework for viewing code
  • Existing code should be composable, not rewritten
  • Multi-runtime execution unlocks the best of each language ecosystem

Categorical thinking encourages you to ask:

  • How do transformations compose?
  • Can I think of what I want to do as a sequence of transformations?
  • If I can't construct a sequence that solves my problem, are there systematic ways to extend/modify the problem so it can be solved?

Read the full philosophy β†’


Use Cases

Forthic excels at:

  • Data transformation pipelines - Clean, composable ETL
  • Analytics and reporting - High-level abstractions over data
  • Polyglot microservices - Each service in its optimal language
  • Agentic architectures - Composable agent behaviors
  • Domain-specific languages - Wrapping business logic
  • Gradual migration - Incrementally modernize systems

See multi-runtime examples β†’


Community & Support

Related Projects


Contributing

We welcome contributions! Each runtime has its own contributing guide:

For general philosophy and community guidelines, see CONTRIBUTING.md.


License

BSD-2-Clause License - Copyright 2024 LinkedIn Corporation. Copyright 2025 Forthix LLC.


Forthic: Wrap. Compose. Abstract. Across Any Runtime.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published