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
Forthic makes your existing code composable by providing:
- A simple module system to wrap your code as Forthic words
- Standard operations for clean data transformations
- 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.
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["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
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 |
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 β
Mathematical foundations provide systematic thinking:
- Morphisms - Words are transformations
- Composition - Concatenation is function composition
- Inverses/Adjoints - Systematic problem-solving patterns
Deep dive: Categorical Coding β
Wrap your existing code with simple decorators:
@Word("( input -- output )", "Description")
async MY_WORD(input: any) { return yourCode(input); }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
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 β
Start with the runtime that matches your project:
- TypeScript/JavaScript β -
npm install @forthix/forthic - Ruby β -
gem install forthic
Each runtime repository includes:
- Installation instructions
- Getting started guide
- Runtime-specific examples
- API documentation
- Core Concepts - Module creation, composition, standard operations
- Why Forthic? - Philosophy and motivation
- Getting Started Guide - Step-by-step tutorial
- Multi-Runtime Overview - Architecture and use cases
- Multi-Runtime Examples - Real-world scenarios
- Integration Tests - Cross-runtime test suite
- Why Forthic? - Philosophy and motivation
- Core Concepts - Module system, composition, standard operations
- Getting Started - Tutorial and first steps
- Language Guide - Syntax, stack operations, semantics
- Categorical Coding - Category Theory foundations
- History - From LinkedIn (1000+ apps) to open source
- 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 Overview - Architecture, protocols, use cases
- Multi-Runtime Examples - Cross-runtime scenarios
- gRPC Setup - Server-to-server communication
- WebSocket Setup - Browser-compatible communication
- Configuration - Connection management
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?
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 β
- Main Repository: github.com/forthix/forthic
- Discussions: GitHub Discussions
- Issues: Report bugs or request features in runtime-specific repos
- forthic-integration-tests - Cross-runtime test suite
- Forthix CLI - Interactive REPL with live stack visualization
We welcome contributions! Each runtime has its own contributing guide:
For general philosophy and community guidelines, see CONTRIBUTING.md.
BSD-2-Clause License - Copyright 2024 LinkedIn Corporation. Copyright 2025 Forthix LLC.
Forthic: Wrap. Compose. Abstract. Across Any Runtime.