Skip to content

Chace-Berry/Alterion-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

70 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Alterion Logo

License: APULv2.0 C++ Build Status Version

Support the development of Alterion:
Buy Me A Coffee GitHub stars

A modern, expressive programming language with native compilation, component-based architecture, and universal NativeUI rendering.

🌟 What is Alterion?

Alterion is a revolutionary systems programming language designed for modern cross-platform application development. It combines the performance of native compilation with the simplicity of component-based architecture and powerful async programming patterns.

Key Features

  • 🎯 Component-First Architecture - Build applications as reusable, native components
  • ⚑ Async-Native - Built-in async blocks with try/catch/finally support
  • 🎨 NativeUI System - Universal UI rendering across desktop, mobile, and web
  • οΏ½ Native Compilation - Direct compilation to machine code (x86_64, ARM, RISC-V)
  • πŸ›‘οΈ Memory Safety - Rust-inspired ownership system with lifetime analysis
  • πŸ“¦ Modern Syntax - Clean, readable syntax with type inference

🎯 Why Alterion?

// Traditional C++ Desktop Application
#include <windows.h>
#include <iostream>

class UserProfile {
    HWND window;
    HWND label;
    HWND button;
    
public:
    void create() {
        window = CreateWindow(...);
        label = CreateWindow(L"STATIC", ...);
        button = CreateWindow(L"BUTTON", ...);
        // 50+ lines of Win32 boilerplate...
    }
    
    void loadUser(int userId) {
        // Manual async handling, error management
        std::thread([=]() {
            try {
                auto user = ApiService::getUser(userId);
                // Update UI on main thread...
            } catch (...) {
                // Handle errors...
            }
        }).detach();
    }
};
// Equivalent Alterion Component
component UserProfile {
    user: object = null
    loading = true
    error= null
    
    @async
    loadUser(userId: int) {
        loading = true
        async {
            [user = await ApiService.getUser(userId)]
            [catch(err) error = err.message]
            [finally loading = false]
        }
    }
    
    render:
        loading ? <div>Loading...</div> :
        error ? <div>Error: {error}</div> :
        <div center>
            <h2>{user.name}</h2>
            <p>{user.email}</p>
        </div>
}

πŸš€ Quick Start

Prerequisites

  • Windows: MinGW-w64 or Visual Studio 2019+
  • macOS/Linux: GCC 7+ or Clang 8+
  • Build Tools: CMake 3.15+

Installation

git clone https://github.com/Chace-Berry/Alterion.git
cd alterion

# Windows
scripts\build.bat

# macOS/Linux
chmod +x scripts/build.sh
./scripts/build.sh

Your First Alterion Program

Create hello.alt:

component HelloWorld {
    name = "Alterion" // Inferred as String
    count: Int = 0    // Statically declared
    increment {
        count += 1
    }

    render:
        <div center>
            <h1>Hello, {name}!</h1>
            <p>Clicked {count} times</p>
            <button onClick={increment}>
                Click me!
            </button>
        </div>
}

Compile and run:

# Compile to native executable
alterion build hello.alts --target native

# Compile for web (NativeUI β†’ DOM)
alterion build hello.alts --target web

# Compile for mobile (NativeUI β†’ native mobile UI)
alterion build hello.altx --target mobile

# Development mode with hot reload
alterion dev hello.altx

πŸ“š Language Features

🧩 Component System

component TodoApp {
    todos = []
    newTodo = ""
    addTodo {
        if (newTodo.trim() != "") {
            todos.push({ text: newTodo, completed: false })
            newTodo = ""
        }
    }

    toggleTodo(index: Int) {
        todos[index].completed = !todos[index].completed
    }

    render:
        <div class="todo-app">
            <input 
                value={newTodo} 
                onChange={updateInput}
                placeholder="Add a todo..."
            />
            <button onClick={addTodo}>Add</button>
            <ul class="todo-list">
                for todo, index in todos[
                    <TodoItem 
                        todo={todo} 
                        onToggle={() => toggleTodo(index)}
                    />
                ]
            </ul>
        </div>
}

⚑ Async Programming

component DataFetcher {
    data= []
    loading = false
    
    @async
    fetchData {
        loading = true
        
        async {
            [
                let response = await fetch('/api/data')
                data = await response.json()
            ]
            [catch(error) 
                console.error('Failed to fetch:', error)
            ]
            [finally 
                loading = false
            ]
        }
    }
}

πŸ”„ Enhanced Control Flow

processItems(items) {
    // Numeric loop
    for i (items.length)[
        print("Processing item " + i + ": " + items[i])
    ]

    // For-in loop
    for item in items[
        if (item.active) {
            item.process()
        }
    ]

    // Range loop
    for i (0, 100)[
        if (i % 2 == 0) {
            print("Even: " + i)
        }
    ]
}

🎨 Universal UI Rendering

component ResponsiveLayout {
    isMobile: boolean = window.innerWidth < 768
    
    render:
        <div class={isMobile ? "mobile-layout" : "desktop-layout"}>
            <header center>
                <h1>My App</h1>
            </header>
            
            <main flex="column" gap="20px">
                <UserProfile />
                <TodoList />
                <Footer />
            </main>
        </div>
}

πŸ› οΈ Development Tools

CLI Compiler

# Basic compilation
alterion build src/ --output dist/ --target native

# Development mode
alterion dev src/ --target native --hot-reload

# Cross-platform compilation
alterion build app.alt --targets native,web,mobile

# With optimizations
alterion build app.alt --optimize --target native

Language Server Protocol (LSP)

  • VS Code Extension: Full IntelliSense support
  • Syntax Highlighting: Rich syntax coloring
  • Error Detection: Real-time error checking
  • Auto-completion: Smart code completion
  • Go to Definition: Navigate your codebase easily

Build System Integration

// alterion.toml (Project configuration)
[project]
name = "my-app"
version = "1.0.0"

[build]
target = "native"
optimize = true

[dependencies]
# External C libraries via FFI
openssl = "1.1"
sqlite = "3.0"

πŸ—οΈ Project Structure

alterion/
β”œβ”€β”€ core/                   # Core language implementation
β”‚   β”œβ”€β”€ lexer/             # Tokenization and lexical analysis
β”‚   β”œβ”€β”€ parser/            # Syntax analysis and AST generation
β”‚   β”œβ”€β”€ semantic/          # Type checking and semantic analysis
β”‚   └── codegen/           # Code generation and optimization
β”œβ”€β”€ include/               # Header files and API definitions
β”œβ”€β”€ runtime/               # Runtime system and standard library
β”‚   β”œβ”€β”€ nativeui/          # Cross-platform UI rendering engine
β”‚   └── ffi/               # Foreign function interface
β”œβ”€β”€ stdlib/                # Alterion standard library
β”œβ”€β”€ tools/                 # Development tools
β”‚   β”œβ”€β”€ cli/               # Command-line compiler
β”‚   β”œβ”€β”€ lsp/               # Language server protocol
β”‚   └── debugger/          # Debug support
β”œβ”€β”€ tests/                 # Test suite
β”‚   β”œβ”€β”€ unit/              # Unit tests
β”‚   β”œβ”€β”€ integration/       # Integration tests
β”‚   └── benchmarks/        # Performance benchmarks
β”œβ”€β”€ examples/              # Example Alterion programs
β”œβ”€β”€ documentation/         # Language documentation
└── scripts/               # Build and utility scripts

πŸ§ͺ Testing

# Run all tests
alterion test

# Run specific test suite
alterion test --suite lexer
alterion test --suite parser
alterion test --suite codegen

# Generate coverage report
alterion test --coverage

# Performance benchmarks
alterion benchmark

πŸ“– Documentation

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

git clone https://github.com/Chace-Berry/Alterion.git
cd alterion

# Install development dependencies
npm install -g cmake
npm install

# Build development version
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug
make -j4

# Run tests
ctest --verbose

Roadmap

  • Phase 1: Lexical Analysis & Tokenization
  • Phase 2: Syntax Analysis & AST Generation
  • Phase 3: Semantic Analysis & Type Checking
  • Phase 4: Code Generation & Optimization
  • Phase 5: NativeUI Rendering Engine
  • Phase 6: CLI Tools & Language Server
  • Phase 7: Advanced Optimizations
  • Phase 8: Package Manager & Registry
  • Phase 9: Debugger & Profiler
  • Phase 10: IDE Extensions & Tooling

πŸ“Š Performance

My goals for Alterions' designed for performance:

  • Fast Compilation: Multi-threaded compilation with intelligent caching
  • Optimized Output: Generated code is optimized for target platforms
  • Memory Efficient: Minimal runtime overhead
  • Bundle Size: Tree-shaking and dead code elimination
Metric Value
Compile Time ~1.8s for 10k LOC
Memory Usage ~32MB peak
Binary Size 60% smaller than equivalent C++
Runtime Performance Native machine code speed

🌍 Community

  • οΏ½ Contact - Questions and discussions
  • πŸ› Report Issues - Bug reports and feature requests

πŸ“„ License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

What this means:

  • βœ… Free to use
  • βœ… Free to modify
  • βœ… Free to contribute to open source projects
  • ❌ Cannot be used in proprietary software without releasing source code
  • ❌ Cannot be monetized without explicit permission from the author

For commercial licensing options, please contact chaceberry686@gmail.com.

πŸ™ Acknowledgments

  • Inspired by modern languages like Rust, TypeScript, and Swift
  • Built with love for the developer community
  • Special thanks to all contributors and early adopters

Made with ❀️ by Chace Berry

Contact: chaceberry686@gmail.com

About

Alterion is a new programming language i wanna develop combining my favorite aspects from multiple diffrent languages and some concepts i thought of into 1 ultimate language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors