O2l
O²L** is a modern object-oriented programming language that balances pure object-oriented design with practical programming constructs.
Install / Use
/learn @zombocoder/O2lREADME
🌟 O²L Programming Language
O²L is a modern object-oriented programming language that balances pure object-oriented design with practical programming constructs. Built with C++23, O²L eliminates primitives and null values while providing essential control flow like while loops, comprehensive arithmetic operations, and extensive string manipulation capabilities for real-world programming needs.
📚 Complete Documentation | 🚀 Getting Started Guide | 📖 Language Reference
🆕 Latest Features
- 🔗 Enhanced Foreign Function Interface (FFI): Complete FFI system with advanced type support, SQLite integration, and comprehensive C library interoperability
- 🌐 HTTP Client Library: Complete
http.clientlibrary with 30+ methods, multipart file upload, platform-specific implementations (Windows/Linux/macOS), and cross-platform libcurl fallback - 🔄 JSON Library: Revolutionary
jsonlibrary with 30+ methods including auto-detection parsing, fixed path navigation bug, and seamless native Map/List integration - 🌐 URL Library: Complete
urllibrary with 26 methods for URL parsing, construction, manipulation, and validation - 🔄 Regular Expressions: Complete
regexplibrary with 12 methods for pattern matching, text searching, and string manipulation - 🔀 Control Flow Enhancement:
else ifsyntax support for complex conditional logic with proper AST chaining - 🛑 Break Statements:
breakstatement for early exit from while loops, enabling search patterns and safety limits - ⏭️ Continue Statements:
continuestatement for skipping iterations in while loops, perfect for filtering and validation - 📏 Text Length Method:
Text.length()method for string length calculation with full type integration - 📐 Math Library: Comprehensive mathematical functions library with 40+ methods including trigonometry, logarithms, statistics, and constants (
import math) - ✨ Comprehensive Text Methods: 48 string manipulation methods including case conversion, search, validation, formatting, and advanced utilities
- 🔄 Variable Mutability: Method-scope variables are mutable while object properties remain immutable
- 🧠 Logical Operators: Full
&&,||,!support with proper precedence and short-circuit evaluation - 📁 Filesystem Operations: Complete
system.fsmodule for file/directory management - 🔗 Expression Enhancements: Parentheses support for complex expression grouping
- 🧪 Complete Test Suite: 282+ comprehensive tests covering all language features with Google Test framework
🧠 Philosophy & Design Vision
Everything is an Object
In O²L, there are no primitives. Numbers, booleans, strings—everything is an object with methods and behaviors. This creates a unified, consistent programming model where all values follow the same patterns. For example, Text objects provide 47 comprehensive methods for manipulation, validation, and formatting, treating strings as first-class objects rather than simple data.
Immutability by Design
All objects in O²L are immutable. Once created, an object's state cannot be changed. This eliminates entire classes of bugs related to shared mutable state, race conditions, and unexpected side effects.
Selective Procedural Constructs
O²L adopts a pragmatic approach by supporting essential control flow like while loops for iteration alongside object-oriented patterns. This enables practical programming while maintaining the language's object-centric philosophy through iterators and method dispatch.
Elimination of Null
There are no null pointers or undefined values. Optional values are handled through explicit Optional<T> types, making null-pointer exceptions impossible and forcing developers to handle all cases explicitly.
Behavior-Driven Architecture
Rather than thinking in terms of data structures and algorithms, O²L encourages thinking in terms of objects that collaborate to solve problems. Each object has clear responsibilities and well-defined interfaces.
🚀 Quick Start
macOS Installation (Homebrew)
The easiest way to install O²L on macOS:
# Add the O²L tap
brew tap zombocoder/o2l
# Install O²L
brew install o2l
# Verify installation
o2l --version
# Create your first project
mkdir my-project && cd my-project
o2l-pkg init
o2l run src/main.obq
Manual Installation
For other platforms or if you want to build from source:
Looking at your CMakeLists.txt, the only external dependency you need to install is libffi (with pkg-config support).
Required Libraries
-
libffi → Used for the Foreign Function Interface (
src/Runtime/FFI/...).-
On Ubuntu/Debian:
sudo apt-get install libffi-dev pkg-config -
On Fedora:
sudo dnf install libffi-devel pkg-config -
On Arch Linux:
sudo pacman -S libffi pkgconf -
On macOS (Homebrew):
brew install libffi pkg-config -
On Windows (MSYS2/MinGW):
pacman -S mingw-w64-x86_64-libffi pkg-config
-
Optional / System-Provided
dl(dynamic linking) → usually provided byCMAKE_DL_LIBSon Linux/macOS.ws2_32,wininet→ provided by Windows SDK, no need to install separately.
Build Dependencies
-
A C++23-capable compiler:
- GCC ≥ 12
- Clang ≥ 15
- MSVC ≥ 19.35 (Visual Studio 2022 17.5)
-
CMake ≥ 3.20
Build from Source
# Clone the repository
git clone https://github.com/zombocoder/o2l.git
cd o2l
# Build the interpreter
mkdir build && cd build
cmake ..
make
# Run your first O²L program
./o2l run ../examples/hello_world.obq
Creating a New O²L Project
O²L provides a powerful package manager tool o2l-pkg to scaffold and manage projects:
# Create project directory
mkdir my-project
cd my-project
# Initialize the O²L project
o2l-pkg init
# Run your project
o2l run src/main.obq
Project Structure
The o2l-pkg init command generates a complete project structure:
my-project/
├── .o2l/ # Package manager directory
│ ├── lib/ # Downloaded libraries
│ └── cache/ # Build cache
├── src/
│ ├── calc/
│ │ └── Calculator.obq # Calculator module
│ ├── greeters/
│ │ └── BasicGreeter.obq # Greeter module
│ ├── tests/
│ │ ├── calc/
│ │ │ └── CalculatorTest.obq
│ │ ├── greeters/
│ │ │ └── GreeterTest.obq
│ │ └── main_test.obq # Test runner
│ └── main.obq # Entry point
├── o2l.toml # Project configuration
└── .gitignore # Git ignore rules
Package Manager Commands
# Initialize new project in current directory
o2l-pkg init
# Create new objects with namespace structure
o2l-pkg create com.mycompany.utils Utils
o2l-pkg create data.models User
# List installed libraries
o2l-pkg list
# Clean cache directory
o2l-pkg clean
# Show help
o2l-pkg help
Running Your Project
Use the standard o2l command to run your programs:
# Run main program
o2l run src/main.obq
# Run all tests
o2l run src/tests/main_test.obq
# Run specific tests
o2l run src/tests/calc/CalculatorTest.obq
o2l run src/tests/greeters/GreeterTest.obq
# Run with arguments
o2l run src/main.obq arg1 arg2
Project Configuration (o2l.toml)
The initialization process creates an interactive configuration:
[package]
name = "my-project"
version = "0.1.0"
description = "An O²L project"
authors = ["Your Name <your.email@example.com>"]
[dependencies]
# Libraries added with o2l-pkg add will appear here
# collections = "latest"
# com.example.math = "1.2.0"
Your First Program
Create hello.obq:
import system.io
Object Greeter {
property message: Text
constructor(greeting: Text) {
this.message = greeting
}
@external method greet(name: Text): Text {
io.print("%s, %s!", this.message, name)
return this.message
}
}
Object Main {
method main(): Int {
greeter: Greeter = new Greeter("Hello")
greeter.greet("World")
return 0
}
}
Run it:
o2l run hello.obq
# Output: Hello, World!
🌍 Philosophy in Practice
Why No If Statements?
Traditional if statements lead to complex branching logic. O²L encourages object-based dispatch:
Related Skills
openpencil
2.0kThe world's first open-source AI-native vector design tool and the first to feature concurrent Agent Teams. Design-as-Code. Turn prompts into UI directly on the live canvas. A modern alternative to Pencil.
HappyColorBlend
HappyColorBlendVibe Project Guidelines Project Overview HappyColorBlendVibe is a Figma plugin for color palette generation with advanced tint/shade blending capabilities. It allows designers to
Flyaro-waffle-app
Waffle Delight - Full Stack MERN Application Rules & Documentation Project Overview A comprehensive waffle delivery application built with MERN stack featuring premium UI/UX, admin management, a
ui-ux-pro-max-skill
57.0kAn AI SKILL that provide design intelligence for building professional UI/UX multiple platforms
