Skip to content

chemicallang/chemical

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5,263 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Chemical logo

The Chemical Programming Language

Website | Docs | Changelog | Contributing & compiler design

Sponsor Patreon Discord X

πŸš€ Overview

Chemical is an innovative, performant, type-safe, and user-friendly programming language with a low memory footprint. It comes with first-class tooling out of the box, all customizable by developers.


Important

Chemical is in pre-alpha state, expect breaking changes and do not use in production.


βš™οΈ Installation

  1. Download & Extract the latest ZIP from the Releases page.
  2. Inside the folder, run ./chemical --configure or ./chemical.exe --configure
  3. Verify by running chemical -v

🌟 Features

  • Easy to Learn: Master in under a week.
  • Great IDE Support: LSP with syntax highlighting, completions, diagnostics, and more.
  • Compile-Time Evaluation: Powerful comptime features.
  • Low Memory Footprint: Tiny executables, no garbage collector.
  • Multiple Backends: LLVM & C (both fully functional).
  • C Interop: Translate between C & Chemical.
  • Flexible Build System: Custom DSL for builds and modules.

πŸ“Š Progress & Roadmap

Component Status
Lexer, Parser, Sym Res βœ…
Native Codegen (LLVM) βœ…
C Translation & TCC JIT βœ…
Basic Build System βœ…
Basic Multi-threading βœ…
Basic LSP βœ…
Standard Library & Docs πŸ”„ In Progress
Embedded Languages πŸ”„ In Progress
Advanced LSP Support πŸ”„ Planned
Memory Management & Safety πŸ”„ Partial
Advanced Build System Support πŸ”„ Planned
Comptime Features πŸ”„ Planned
Compiler Plugins πŸ”„ Planned
Mobile & Web Support πŸ”„ Planned

πŸ“š Language Features

These features should give you an idea about features I have worked on

  • C-like syntax with structs & namespaces
  • Arrays, enums, unions
  • Native lambdas (with capture)
  • Macros & annotations
  • Implicit & explicit casting
  • Extension functions (like Kotlin)
  • Raw pointers & memory control
  • Full constructors & destructors
  • Explicit copying (.copy() required)
  • Comptime support & generics
  • Overloading, variants, type aliases
  • Trait & impl (Rust-like)
  • Name mangling & conflict detection

πŸ› οΈ Build (From Source)

Quick Start

# 0. One-time setup (after cloning) β€” downloads dependencies & submodules
./scripts/setup.sh
# Or with LLVM support:
./scripts/setup.sh --with-llvm

# 1. Configure CMake
./scripts/configure.sh            # (use --no-llvm if you didn't pass --with-llvm to setup)

# 2. Build
./scripts/build.sh --tcc          # TCCCompiler (fast, no LLVM)

# 3. Test
./scripts/test.sh --tcc           # Build & run tests

Interactive TUI: ./scripts/tui.sh provides a curses menu to run all scripts, tweak options, and save/load configs.

For detailed instructions covering all platforms, IDEs, and scenarios, see the Building Chemical guide.

Requirements

  • 8–16β€―GB RAM
  • C++20 toolchain
  • LLVM (optional, for Compiler target)
  • CMake 3.15+

Scripts

Script Purpose
scripts/tui.sh Interactive TUI β€” curses-based menu to run all scripts, tweak options, save/load configs
scripts/setup.sh One-time setup after cloning: downloads libtcc, updates submodules, (optionally LLVM with --with-llvm)
scripts/configure.sh Configure CMake project (use --no-llvm to skip LLVM)
scripts/build.sh Build targets: --tcc, --llvm, --lsp, --all
scripts/test.sh Build & run tests: --tcc, --llvm, --libs, --no-run, --no-build

⚠️ --no-build: Skips rebuilding the C++ compiler β€” changes to .cpp/.h files are ignored. Only use when iterating on .ch test files without compiler changes.

LSP

  1. Clone chemical-vscode for the VS Code extension.
  2. Build the LSP server: ./scripts/build.sh --lsp
  3. Launch the LSP server before launching the extension.

Open an issue for any build errors.


🎯 Vision & Design Goals

Compiler plugins and language extensions β€” Scalability

Chemical exists to let you embed complex, domain-specific syntax into the language via compiler plugins. Extensions are first-class: add new syntax and behaviors without touching the core. Tooling (syntax highlighting, editor parsing) must continue to work for extended syntax. Scalability and extensibility are part of Chemical’s DNA.

Comprehensive features

Real projects frequently need features a language didn’t originally include. Chemical aims to provide the capabilities you actually need while avoiding β€œsyntax pollution.” Powerful, composable abstractions for library authors and power users come with sensible defaults and a gentle learning curve for beginners. The goal: lots of capability, minimal surprise.

Memory safety β€” without the cost of simplicity

Long-term, Chemical will promote memory safety while keeping the language simple to use. Safety is a priority but not yet fully enforced β€” the initial focus is on core functionality and tooling. Once the core is stable, compiler-enforced safety checks will be added progressively; the beta compiler will enforce baseline safety guarantees.


🀝 Contributing

We welcome all contributions! See CONTRIBUTING.md for guidelines.


πŸ“„ License

Chemical compiler is MIT-licensed and will remain open source. Use it freelyβ€”credit is appreciated but not required.


Sponsor this project

  •  

Packages

 
 
 

Contributors