An LLM-powered programming language translator that bridges the gap between different programming languages through a semantic-focused intermediate representation.
Linguitect is an intermediate representation (IR) language designed specifically for translating code between programming languages. Unlike traditional transpilers that focus on syntax, Linguitect captures the semantic intent of code, enabling more accurate translations across different programming paradigms.
The project addresses a fundamental challenge in software development: the need to translate code between languages while preserving its meaning and intent. By focusing on what code does rather than how it's written, Linguitect enables developers to:
- Convert legacy codebases to modern languages
- Share algorithms across language boundaries
- Learn new languages by seeing familiar code translated
- Bridge different programming paradigms (OOP, functional, procedural)
graph TD
IR[Linguitect IR] --- IA[Import Adapters]
IR --- EA[Export Adapters]
IA --- PythonI[Python Import]
IA --- RustI[Rust Import]
IA --- JavaScriptI[JavaScript Import]
IA --- OtherI[Other Languages...]
EA --- PythonE[Python Export]
EA --- RustE[Rust Export]
EA --- JavaScriptE[JavaScript Export]
EA --- OtherE[Other Languages...]
TM[Translation Maps] --- IR
SC[Semantic Constructs] --- IR
NP[Navigation Protocols] --- IR
EM[Evolution Mechanisms] --- IR
Linguitect captures what code does rather than how it's written, preserving programmer intent across language boundaries. This approach enables more accurate translations, especially when moving between languages with different paradigms or features.
The intermediate representation supports multiple programming paradigms (procedural, object-oriented, functional) without bias, allowing for effective translation between languages that emphasize different paradigms.
Linguitect uses verbose, explicit tags that make structure obvious, enhancing readability for both humans and machines:
@FUNC calculate_total(items) -> int
@DOCS "Calculate the sum of all items in the list"
@BODY
@VAR total int = 0
@LOOP type="for" var=item in=items
@ASSIGN total <- @EXPR_ARITHMETIC type="+" operands=(total, item)
@ENDLOOP
@RETURN total
@END
@ENDFUNC
The hub-and-spoke architecture allows for adding new languages by creating just two adapters (import and export), instantly enabling translation to/from all existing supported languages.
For efficient processing, Linguitect offers an emoji-based representation that condenses complex constructs into single characters:
🔧calculate_total(items)→🔢{
📝📝"Calculate the sum of all items in the list"
📦{
📝total,🔢=0
🔁item:items{
←total=➕(total,item)
}
🔙total
}
}
Linguitect uses a hub-and-spoke architecture with the Linguitect Intermediate Representation (IR) at its center. This design enables efficient multi-language code translation through a common semantic representation.
-
Linguitect Intermediate Representation (IR)
- The central component that serves as the hub for all translations
- Represents code semantics rather than syntax
- Uses explicit tagging for clear structure
-
Language Adapters
- Import Adapters: Convert source language code to Linguitect IR
- Export Adapters: Convert Linguitect IR to target language code
-
Semantic Constructs
- Define core programming concepts represented in Linguitect
- Organized by programming paradigm
- Provide cross-language implementation examples
-
Translation Maps
- Provide guidance for mapping between languages and paradigms
- Cross-paradigm translation strategies
- Idiomatic pattern equivalents
-
Navigation Protocols
- Define processes for navigating the translation space
- Construct translation protocols
- Idiom translation protocols
sequenceDiagram
participant SC as Source Code
participant IA as Import Adapter
participant IR as Linguitect IR
participant EA as Export Adapter
participant TC as Target Code
SC->>IA: Parse
IA->>IA: Analyze
IA->>IR: Transform
IR->>IR: Optimize
IR->>EA: Transform
EA->>TC: Generate
The Linguitect repository is organized into the following key directories:
spec/: Detailed specifications for the Linguitect IR and emoji representationlanguage-adapters/: Implementation of language-specific adapterscontext-network/: Comprehensive documentation organized as a knowledge networkfoundation/: Core concepts, architecture, and principlessemantic-constructs/: Programming constructs and their representationslanguage-adapters/: Language-specific adapter documentationtranslation-maps/: Cross-language and cross-paradigm translation guidancenavigation-protocols/: Processes for navigating the translation spaceevolution-mechanisms/: Processes for adapting and expanding the system
- Node.js v16+
- Python 3.8+ (for Python adapter)
- Rust 1.56+ (for Rust adapter)
# Clone the repository
git clone https://github.com/jwynia/linguitect.git
cd linguitect
# Install dependencies
npm installconst linguitect = require('linguitect');
// Translate Python to JavaScript
const pythonCode = `
def calculate_total(items):
total = 0
for item in items:
total += item
return total
`;
const jsCode = linguitect.translate(pythonCode, 'python', 'javascript');
console.log(jsCode);Comprehensive documentation is available in the context-network directory, organized as a knowledge network designed for efficient navigation by both humans and LLM agents.
The documentation follows a consistent metadata structure:
# Document Title
## Purpose Statement
[Concise explanation of this document's function]
## Information Classification
- **Domain:** [Primary knowledge domain]
- **Stability:** [Static/Semi-stable/Dynamic]
- **Abstraction:** [Conceptual/Procedural/Detailed]
- **Confidence:** [Established/Evolving/Speculative]
- **Relevance:** [Primary use contexts]
## Core Content
[Primary information organized in a structured format]
## Relationship Network
- **Prerequisite Information:** [Documents that should be understood first]
- **Related Information:** [Documents with associative connections]
- **Dependent Information:** [Documents that build on this information]
- **Alternative Perspectives:** [Documents with different viewpoints]
- **Implementation Details:** [Documents with more specific information]
## Navigation Guidance
- **Access Context:** [When to use this information]
- **Common Next Steps:** [Typical navigation paths from here]
- **Related Tasks:** [Activities where this information is relevant]
- **Update Patterns:** [How and when this information changes]- Start with
context-network/foundation/linguitect-core.mdfor core concepts - Explore
context-network/foundation/architecture.mdfor system structure - Dive into
context-network/semantic-constructs/for programming constructs - Review
context-network/language-adapters/for language-specific implementations
- Python (import/export)
- Rust (import/export)
- JavaScript (partial support)
To add support for a new language:
- Follow the guide in
language-adapters/guide-to-making-language-adapters.md - Create import and export adapters for the language
- Document language-specific constructs and idioms
- Register any emoji extensions for the language
Contributions are welcome! Please check out our contribution guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Clone the repository
git clone https://github.com/jwynia/linguitect.git
cd linguitect
# Install dependencies
npm install
# Run tests
npm testPlease report issues using the GitHub issue tracker, providing:
- A clear description of the issue
- Steps to reproduce
- Expected vs. actual behavior
- Code samples if applicable
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2025 J Wynia
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
- The project draws inspiration from intermediate representations used in compiler design
- Special thanks to the open-source community for their contributions and feedback
- Emoji representation inspired by APL and other symbolic programming languages