SmashLang is a JavaScript-inspired programming language implemented in Rust that compiles to native binaries across all major platforms (desktop, mobile, server, WebAssembly, etc.). The language supports dynamic typing, native date/time, regular expressions, and control flow constructs like if
, for
, and while
.
- JavaScript-like Syntax: Familiar syntax for JavaScript developers
- Dynamic Typing: Flexible type system with runtime type checking
- Native Compilation: Compiles to native binaries for all major platforms
- WebAssembly Support: Compile to WebAssembly for web applications
- Cross-Platform: Works on Linux, macOS, Windows, iOS, Android, and more
- Standard Library: Built-in support for common operations
- Regular Expressions: Native regex support
- Date/Time Handling: Comprehensive date and time functionality
- Error Handling: Try/catch/finally mechanism
- Modern Language Features: Destructuring, pattern matching, async/await, and more
SmashLang is built using modern Rust crates:
- Lexer: Uses logos for efficient tokenization
- Parser: Uses pest for parsing with PEG grammar
- Interpreter: Custom interpreter with dynamic typing
- Compiler: Native code generation using cranelift
- Standard Library: Implemented using Rust's ecosystem (chrono, regex, etc.)
# Clone the repository
git clone https://github.com/profullstack/smashlang.git
cd smashlang
# Build the project
cargo build --release
# Install the binaries
cargo install --path .
curl -sSL https://raw.githubusercontent.com/profullstack/smashlang/refs/heads/master/install.sh | bash -s -- --master
Create a file named hello.smash
:
// hello.smash
print("Hello, SmashLang!");
Run it:
smash run hello.smash
smashc hello.smash -o hello
./hello
smashc hello.smash --wasm -o hello.wasm
Comprehensive documentation is available in the docs
directory:
- Getting Started Guide
- Language Reference
- Standard Library
- WebAssembly Support
- OS Hooks
- Process Management
SmashLang comes with a variety of examples to help you learn:
- Control Flow
- Error Handling
- Functions
- Modules
- Pattern Matching
- Syntax
- Types
- Destructuring
- Object Enhancements
Run all examples:
cd docs
./test_all_examples.sh
Run the test suite:
cargo test
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your 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
This project is licensed under the ISC License - see the LICENSE file for details.