Skip to content

GriffinCanCode/Polyglot

Repository files navigation

Polyglot Framework

Polyglot Framework

A radical rethinking of desktop application development that treats multilingual programming as a first-class citizen.

Overview

Polyglot enables developers to use the absolute best language for each component while maintaining a cohesive, type-safe development experience. Built with Go as the orchestrator, it embeds language runtimes directly into a single process with true parallel execution via goroutines.

Architecture

polyglot/
├── core/           # Core orchestrator, config, types, memory, profiler, HMR
├── runtimes/       # Language runtime integrations
│   ├── python/     # Python runtime with CGO bindings (Phase 1)
│   ├── javascript/ # JavaScript/TypeScript runtime with V8 (Phase 1)
│   ├── rust/       # Rust integration with shared library loading (Phase 2)
│   ├── java/       # Java integration with JNI bindings (Phase 2)
│   ├── cpp/        # C++ integration with CGO bindings (Phase 2)
│   ├── php/        # PHP integration with embedded interpreter (Phase 3)
│   ├── ruby/       # Ruby integration with CGO bindings (Phase 3)
│   ├── lua/        # Lua integration with state management (Phase 3)
│   ├── zig/        # Zig integration with C ABI (Phase 3)
│   └── wasm/       # WebAssembly runtime (Phase 3)
├── webview/        # Native webview integration
├── build-system/   # Build tooling, selective compilation, and binding generation
├── cli/            # CLI tool for project management
├── marketplace/    # Package registry and template management (Phase 4)
├── cloud/          # Cloud build infrastructure (Phase 4)
├── signing/        # Code signing for all platforms (Phase 4)
├── updates/        # Differential update system (Phase 4)
├── tests/          # Comprehensive test suite
├── types/          # Shared type definitions
├── security/       # Security and sandboxing
└── examples/       # Example applications

Features

Phase 1 (✅ Complete & Fully Operational)

  • Core Orchestrator: Go-based runtime coordinator with goroutine pooling
  • Python Integration: ✅ FULLY OPERATIONAL - Full CPython embedding with:
    • Real CGO bindings (#cgo pkg-config: python3-embed)
    • Proper GIL management and thread safety
    • Worker pool architecture for concurrency
    • Auto-detection build system (no manual flags needed)
    • Comprehensive CI testing on Ubuntu, macOS, Windows
    • Works with standard pip/PyPI installations
  • JavaScript/TypeScript: V8 runtime integration
  • Memory Coordinator: Zero-copy shared memory architecture
  • Webview: Native webview with bidirectional bridge
  • CLI Tool: Project initialization, build, dev, and test commands
  • Build System: Selective compilation with automatic runtime detection
  • Test Suite: Comprehensive unit and integration tests

Phase 2 (✅ Complete)

  • Rust Integration: Shared library loading with dlopen/dlsym
  • Java Integration: JNI bindings with JVM management
  • C++ Integration: Direct CGO bindings with dynamic loading
  • Binding Generator: Automatic type definitions for TypeScript/Python/Rust
  • Profiler: Cross-runtime performance tracking with detailed metrics
  • Hot Module Replacement: File watching with runtime-specific reload handlers

Phase 3 (✅ Complete)

  • PHP Integration: Embedded PHP interpreter with SAPI
  • Ruby Integration: CGO bindings to libruby with worker pools
  • Lua Integration: Lightweight Lua state management
  • Zig Integration: C ABI compatibility with dynamic loading
  • WASM Runtime: WebAssembly bytecode execution engine
  • Security Sandboxing: Platform-specific enforcers (Landlock, App Sandbox, AppContainer)

Phase 4 (✅ Complete)

  • Marketplace: Package registry with search, caching, and validation
  • Cloud Services: Remote build infrastructure with authentication
  • Cross-Platform Compilation: Parallel builds for multiple platforms
  • Code Signing: Platform-specific signing (macOS, Windows, Linux)
  • Update System: Differential patching with rollback support

Phase 5 (Planned)

  • Mobile runtime exploration (iOS/Android)
  • Embedded systems support
  • Plugin architecture for custom runtimes

Quick Start

Installation

go install github.com/griffincancode/polyglot.js/cli@latest

Python Runtime Setup (Optional)

The Python runtime is automatically detected and enabled if you have Python installed via pip/PyPI. To ensure it's available:

# Check if Python runtime is detected
make verify-python

# If not detected, install dev headers
make setup-python

Create a New Project

polyglot init myapp
cd myapp
polyglot dev

Project Structure

myapp/
├── src/
│   ├── backend/
│   │   └── main.go      # Go orchestrator
│   └── frontend/
│       └── index.html   # Frontend UI
└── dist/                # Build output

Configuration

Configure your application in main.go:

config := core.DefaultConfig()
config.App.Name = "myapp"
config.EnableRuntime("python", "3.11")
config.EnableRuntime("javascript", "latest")

Performance

  • Startup: Sub-10ms with multiple runtimes
  • Memory: ~30MB minimum (Python-only), ~70MB full-stack
  • Inter-language calls: 0.05-0.5 microseconds
  • True parallelism: Genuine multi-core utilization via goroutines

Development

Build from Source

git clone https://github.com/griffincancode/polyglot.js.git
cd polyglot.js
make build

The build system automatically detects available runtimes (like Python) and enables them. No build flags needed!

Enable Python Runtime

If Python runtime isn't automatically detected:

# Install Python development headers
make setup-python

# Build with auto-detection
make build

That's it! The Python runtime will be automatically enabled if the dev headers are found.

Run Tests

# Run all tests (auto-detects Python)
make test

# Run only Python runtime tests
make test-python

# Or with Go directly
go test ./...

Build Examples

cd examples/01-hello-world
make example  # Auto-detects Python
./dist/hello-world

Or run tests:

cd examples/01-hello-world
go test -v

Manual Build Tags (Advanced)

If you need explicit control:

# Force native Python (fails if unavailable)
go build -tags=runtime_python -o polyglot ./cli

# Or use stub runtimes explicitly
go build -o polyglot ./cli

Design Principles

  • Extensible: Modular runtime architecture
  • Testable: Comprehensive test coverage with mocks
  • Compact: One-word file names, short functions
  • Type-safe: Strong typing throughout
  • Zero-debt: Clean architecture, readable code

License

MIT License - See LICENSE file for details.

Contributing

See CONTRIBUTING.md for guidelines.

Links

About

(in progress) Multi-lingual application framework, not tied to Rust, more convenient than Electron.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published