https://github.com/alexeev-prog/morning.lang
Aesthetic programming language in C++ (llvm)
https://github.com/alexeev-prog/morning.lang
bnf clang cmake compiler cpp llvm llvm-clang llvm-frontend programming-language
Last synced: 2 months ago
JSON representation
Aesthetic programming language in C++ (llvm)
- Host: GitHub
- URL: https://github.com/alexeev-prog/morning.lang
- Owner: alexeev-prog
- License: gpl-3.0
- Created: 2025-05-26T14:53:16.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-06-28T00:20:27.000Z (3 months ago)
- Last Synced: 2025-07-05T09:40:39.103Z (3 months ago)
- Topics: bnf, clang, cmake, compiler, cpp, llvm, llvm-clang, llvm-frontend, programming-language
- Language: C++
- Homepage: https://alexeev-prog.github.io/morning.lang/
- Size: 2.63 MB
- Stars: 4
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# β‘ morning.lang - The Next-Gen Systems Programming Language
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
The Morning programming language is a low-level language with high-level parts. The syntax is based on S-expressions. The goal of the language is to explore low-level programming languages from a new perspective and with new constructs. The language has a medium-strict typing system and an evolving ecosystem.
## VSCode Extension
We have VS Code extension for code highlight and snippets. [Extension here](https://marketplace.visualstudio.com/items?itemName=alexeevdev.morning-language-syntax).
## Standards
For see Morning Standards, see [morning-standards](https://github.com/alexeev-prog/morning-standards).Last standards:
+ MCG-1 (Morning Coding Guidelines 1). [Read here](https://github.com/alexeev-prog/morning-standards/blob/main/standards/MCG1/index.md).
## π Technical Overview
Morning.lang is a statically-typed systems programming language designed for performance-critical applications.
Built on LLVM 19, it combines low-level memory control with expressive S-expression syntax.### Core Technical Features
| Feature | Technical Implementation | Performance Impact |
|---------|---------------------------|---------------------|
| **S-expression Syntax** | Lisp-inspired uniform code representation | Reduced cognitive load, enhanced metaprogramming |
| **LLVM19 Backend** | Direct LLVM IR generation via C++ API | Near-native execution speed, advanced optimizations |
| **Static Typing System** | Type annotations (!int, !ptr) with inference | Compile-time safety, zero-cost abstractions |
| **Memory Control** | Manual allocation (mem-alloc) with scope-based safety | Predictable performance, no GC pauses |
| **Bitwise Operations** | Native bit-and/bit-or/bit-shl instructions | Hardware-level efficiency |
| **Cross-Platform** | Single IR β Windows/Linux/macOS binaries | Consistent behavior across platforms |### Performance Benchmarks
```mermaid
graph TD
A[C] -->|100%| B[Baseline]
C[Rust] -->|98%| B
D[Morning.lang] -->|99%| B
E[C++] -->|101%| B
F[Go] -->|85%| B
G[Python] -->|15%| B
```*Comparative execution speed vs C baseline (higher is better)*
## βοΈ Language Components
### Primitive Types
| Type | Size | Description | Example |
|------|------|-------------|---------|
| **!int** | 64-bit | Default integer type | `[var (counter !int) 0]` |
| **!frac** | 64-bit | IEEE 754 floating point | `[var (pi !frac) 3.14159]` |
| **!bool** | 1-byte | Boolean value | `[var (flag !bool) true]` |
| **!str** | ptr + size | UTF-8 string | `[var (name !str) "Alice"]` |
| **!ptr** | arch-dependent | Raw memory pointer | `[var (buffer !ptr) (mem-alloc 256)]` |### Memory Operations
| Operation | Syntax | Description |
|-----------|--------|-------------|
| **Allocation** | `[mem-alloc size]` | Allocate raw memory block |
| **Deallocation** | `[mem-free ptr]` | Release allocated memory |
| **Memory Read** | `[mem-read ptr type]` | Read typed value from address |
| **Memory Write** | `[mem-write ptr value]` | Write value to memory location |
| **Address Of** | `[mem-ptr variable]` | Get address of variable |
| **Dereference** | `[mem-deref ptr type]` | Access value through pointer |### Control Flow Constructs
```morning
// Conditional execution
[if (> x 10)
(fprint "High value")
elif (> x 5)
(fprint "Medium value")
else
(fprint "Low value")]// Loop constructs
[while (> x 0)
(set x (- x 1))][for (var i 0) (< i 10) (set i (+ i 1))
(fprint "Iteration: %d" i)]// Ternary operator
[var result (check (> x 0) "Positive" "Non-positive")]
```## π¦ Installation & Usage
### System Requirements
- LLVM 19 development files
- C++17 compatible compiler
- CPU
- RAM (optional)### Build Instructions
```bash
# Clone repository with submodules
git clone --recurse-submodules https://github.com/alexeev-prog/morning.lang.git
cd morning.lang# Build full project
./build.sh all./build/bin/morningllvm -h
```### Command Line Interface
```
Usage: morninglang [options]MorningLLVM - Compiler for the Morning programming language
Options:
-h, --help Print this help message
-e, --expression Execute single expression
-f, --file Compile source file
-l, --lint Analyze code quality
-o, --output Output binary name
-k, --keep Retain intermediate files
-O0/-O1/-O2/-O3 Optimization level
--emit-llvm Output LLVM IR instead of binary
```## π‘ Language Highlights
### π§© Low Level
```morning
// Allocate memory for an integer and store pointer in 'ptr'
[var (ptr !ptr) (mem-alloc (sizeof !int))]
[fprint "Memory allocated at: %p\n" ptr]// Write value to allocated memory
[mem-write ptr 42]
[fprint "Value written: %d\n" 42]// Read value back from memory
[var (value !int) (mem-read ptr !int)]
[fprint "Value read: %d\n" value]// Pointer operations
[var (x !int) 100]
[var (x_ptr !ptr) (mem-ptr x)] // Get address of variable 'x'
[fprint "Address of x: %p\n" x_ptr]// Dereference pointer
[var (x_val !int) (mem-deref x_ptr !int)]
[fprint "Value of x via pointer: %d\n" x_val]// Modify value through pointer
[mem-write x_ptr 200]
[fprint "New value of x: %d\n" x]// Free allocated memory
[mem-free ptr]
[fprint "Memory freed\n"]// Raw byte operations
[var (buffer !ptr) (mem-alloc 4)] // Allocate 4-byte buffer
[byte-write buffer 0x41] // Write 'A' (ASCII 0x41)// Read bytes
[fprint "Byte 0: %c\n" (byte-read buffer)]// Size-constrained type declaration
[var (size_checked_int !size:8!int) 0] // 8-bit integer
```### π§© Input strings
```morning
[var (name !str) "Initial"][fprint "Enter your name: "]
[finput "%[^\n]" name][fprint "Hello, %s!\n" name]
```### π§© Arrays
```morning
[var (arr !array) (array 1 2 3)]// Access element
[fprint "Element 0: %d\n" (index arr 0)]// Modify element
[set (index arr 0) 10]
[var idx 0]
[fprint "Modified element 0: %d\n" (index arr idx)]
```### π§© Factorial
```morning
[func factorial (x) (scope
(check (== x 0)
1
(* x (factorial (- x 1)))
)
)](fprint "Factorial of 5: %d\n" (factorial 5))
```### For loops
```morning
(var sum 0)
(for (var i 1) (<= i 10) (set i (+ i 1))
(scope
(fprint "Result: %d\n" i)
(check (>= i 5)
(break)
)
)
)
(fprint "Result: %d\n" sum)
```### π§© Functions
```morning
[func square (x) (* x x)][fprint "square 10: %d\n" (square 10)]
[func sum ((first !int) (second !int)) <-> !int (+ first second)]
[fprint "sum 100 1: %d\n\n" (sum 100 1)]
```## π§© Number systems
```morning
[func square (x) (* x x)][fprint "square 10: %d\n" (square 10)]
[fprint "square 0xA: %d\n" (square 0xA)]
[fprint "square 012: %d\n" (square 012)]
[fprint "square 0b1010: %d\n" (square 0b1010)][func sum ((first !int) (second !int)) -> !int (+ first second)]
[fprint "sum 100 1: %d\n\n" (sum 100 1)]
```## π§© While Loop
```morning
(var x 1)
(while (> x 0)
(scope
(fprint "x = %d\n" x)
(check (== x 1)
[scope
[fprint "continue\n"]
[set x (+ x 1)]
(continue)
(continue)
]
)
(set x (+ x 1))
(check (== x 5)
(break)
)
)
)
(fprint "x = %d\n" x)
```## π§© Loops
```morning
[var counter 0]
[loop
[scope
[set counter (+ counter 1)]
[fprint "Π‘ΡΠ΅ΡΡΠΈΠΊ: %d\n" counter]
[check (== counter 5)
[break]
[]
]
]
]
```## π§© if-elif-else
```morning
[var x 11]
(if
(> x 10) (fprint "x > 10") // if branch
elif (> x 5) (fprint "x > 5") // elif branch
else (fprint "x <= 5") // else branch
)
```## π§© fcasn & fprint
```morning
(var height 0)(fprint "Enter height: ")
(finput "%d" height)
(fprint "%d\n" height)
```## π§© For Loop
```morning
[for (var i 0) (< i 6) (set i (+ i 1))
[scope
(fprint "Value: %d\n" i)
[check (== i 3)
(break)
]
]
]
```## π§© Check (if-then-else) conditions
```morning
[var b 100][var a (+ b 1)]
[check (== a 101)
[check (> a 100)
[set a 1000]
[set a -1]]
[set a 0]][fprint "A: %d\n\n" a]
```## π Documentation & Resources
### Official References
- [Language Specification (PDF)](https://alexeev-prog.github.io/morning.lang/spec.pdf)
- [Standard Library API](https://alexeev-prog.github.io/morning.lang/stdlib)
- [LLVM Integration Guide](https://alexeev-prog.github.io/morning.lang/llvm-integration)### Learning Path
1. **Language Essentials** - Syntax, types, control flow
2. **Memory Management** - Allocation strategies, safety
3. **Systems Programming** - Hardware interaction, low-level ops
4. **Concurrency Models** - Parallel execution, synchronization
5. **Performance Tuning** - Optimization techniques, profiling## π Community & Contribution
### Development Ecosystem
```mermaid
graph LR
A[Morning.lang] --> B[VSCode Extension]
A --> C[CLion Plugin]
A --> D[CI/CD Pipelines]
A --> E[Package Registry]
A --> F[Performance Profiler]
```### Contribution Guidelines
1. **Issue Tracking** - Report bugs via GitHub Issues
2. **Pull Requests** - Follow [CONTRIBUTING.md](CONTRIBUTING.md)
3. **Code Standards** - Adhere to MCG-1 specification
4. **Performance** - Validate changes with benchmarks
5. **Documentation** - Update relevant documentation## βοΈ License
```text
Aesthetic programming language in C++ (llvm)
Copyright (C) 2025 Alexeev BronislavThis program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with this program. If not, see .
```## Morning Manifesto
*"We reject the false choice between performance and expressiveness.
We reject the old methods imposed by backward compatibility with
long-dead legacy products. Morning is a new era in programming
that combines the simplicity of S-expressions with the functionality
of C++. Thanks to the purity of the project and its versatility,
you can create anything and everything you want."*