Skip to content

edefede/ascension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

37 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Ascension

A lightweight, interpreted programming language
C-like syntax โ€ข No explicit typing โ€ข Built-in GUI, Networking, Neural Networks

Version License Python C++

"Ascension IS the syntax" โ€” The same language, multiple implementations.

Ascension is an educational programming language with C-like syntax and dynamic typing. Write once, run on Python (reference implementation) or C++ (high-performance port).

๐ŸŽฏ Two Implementations, One Language

Ascension is the syntax. The implementation is just how you run it:

๐Ÿ Python (Reference Implementation)

# Run a program
python3 ascension_12_8.py examples/hello.asc

# Interactive shell
python3 ascension_shell_12_7.py

Full-featured, batteries-included, perfect for rapid development.

โšก C++ (High Performance)

# Compile
g++ -std=c++17 cpp/ascension.cpp -o ascension

# With optional features
g++ -std=c++17 -DHAS_CURSES -DHAS_NETWORK cpp/ascension.cpp -o ascension -lncurses

# Run
./ascension examples/hello.asc

Header-only modular design, 15% more compact, blazing fast.

Compile Flags:

  • -DHAS_CURSES โ€” Terminal UI support (requires ncurses)
  • -DHAS_NETWORK โ€” HTTP and socket networking

โœจ Features

  • C-like Syntax โ€” Familiar and easy to learn
  • No Explicit Typing โ€” Variables are dynamically typed
  • Stack-based VM โ€” Compiled to bytecode, then executed
  • GUI Support โ€” Built-in Tkinter integration
  • Networking โ€” HTTP requests and TCP sockets
  • File I/O โ€” Read, write, and manage files
  • Terminal UI โ€” Curses support for console apps
  • Math Functions โ€” Trigonometry, random, exponentials (v12.7)
  • Neural Networks โ€” Built-in library for ML experiments (v12.7)
  • Terminal Size Detection โ€” curses_rows(), curses_cols() for dynamic TUI layouts (v12.8)

๐Ÿ“ Examples

Variables and Output

name = "Ascension";
version = 12.8;
print("Welcome to", name, "v" + version);

Functions

func factorial(n) {
    if (n <= 1) {
        return 1;
    }
    return n * factorial(n - 1);
}

print("5! =", factorial(5));  // Output: 120

Control Flow

for (i = 0; i < 5; i += 1) {
    if (i % 2 == 0) {
        print(i, "is even");
    } else {
        print(i, "is odd");
    }
}

Structs

struct Person { name, age, city };

p = new Person;
p.name = "Alice";
p.age = 30;
p.city = "Rome";

print(p.name, "lives in", p.city);

Arrays and Matrices

// 1D Array
numbers = [10, 20, 30, 40, 50];
print("First:", numbers[0]);

// 2D Matrix
grid = matrix(3, 3, 0);
grid[1, 1] = 99;
print("Center:", grid[1, 1]);

File I/O

// Write to file
f = open("data.txt", "w");
write(f, "Hello, File!\n");
close(f);

// Read from file
f = open("data.txt", "r");
content = read_all(f);
print(content);
close(f);

HTTP Requests

response = http_get("https://api.github.com");
status = response_status(response);
body = response_body(response);
print("Status:", status);

TCP Sockets

sock = socket_open();
socket_connect(sock, "example.com", 80);
socket_send(sock, "GET / HTTP/1.0\r\n\r\n");
data = socket_recv(sock, 1024);
socket_close(sock);
print(data);

GUI with Tkinter

root = tk_root("My App", "400x300");
label = tk_widget(root, "label", "text=Hello GUI!");
tk_pack(label);
button = tk_widget(root, "button", "text=Click Me");
tk_pack(button);
tk_mainloop(root);

Terminal UI with Curses

scr = curses_init();
curses_print(scr, 0, 0, "Press any key...");
curses_refresh(scr);
key = curses_getkey(scr);
curses_end(scr);
print("You pressed:", key);

Error Handling

try {
    x = 10 / 0;
} catch {
    print("Caught an error!");
}

System Commands

result = exec("ls -la");
print(result);

system("echo 'Hello from shell!'");

String Operations

text = "Hello, World!";
print("Length:", len(text));
print("Substring:", substr(text, 0, 5));  // "Hello"
print("Char code:", ord("A"));             // 65
print("From code:", chr(65));              // "A"

๐Ÿงฎ Math Functions (v12.7)

// Random numbers
r = random();           // Float 0.0 - 1.0
r = random(100);        // Int 0 - 99
r = random(10, 20);     // Int 10 - 19

// Basic math
print(sqrt(16));        // 4
print(pow(2, 10));      // 1024
print(abs(-42));        // 42
print(floor(3.7));      // 3
print(ceil(3.2));       // 4

// Exponential and logarithm
print(exp(1));          // 2.718... (e)
print(log(E));          // 1.0

// Trigonometry
print(sin(PI / 2));     // 1.0
print(cos(0));          // 1.0
print(tan(PI / 4));     // 1.0
print(atan2(1, 1));     // 0.785... (PI/4)

// Constants
print(PI);              // 3.14159...
print(E);               // 2.71828...

๐Ÿง  Neural Network Library (v12.7)

Ascension includes neural_network.asc, a library for building and training neural networks:

include "lib/neural_network.asc";

// Sigmoid activation
print(sigmoid(0));      // 0.5
print(sigmoid(5));      // ~0.99

// Initialize MLP (2 inputs, 2 hidden, 1 output)
mlp_init();

// Train on XOR problem
// ... training loop ...

// Predict
result = mlp_predict(1, 0);  // ~0.99 (XOR: 1)
result = mlp_predict(1, 1);  // ~0.01 (XOR: 0)

// Save/Load weights
mlp_save_weights("xor_trained.weights");
mlp_load_weights("xor_trained.weights");

Features:

  • Activation functions: sigmoid, relu, step, tanh
  • Single neuron implementation
  • Perceptron with training (AND/OR gates)
  • Multi-Layer Perceptron (MLP) with backpropagation
  • XOR problem solver (2-2-1 architecture)
  • Weight persistence (save/load to file)

๐Ÿ”ง Built-in Functions

Category Functions
I/O print, read
Math sqrt, pow, exp, log, abs, floor, ceil, random
Trig sin, cos, tan, asin, acos, atan, atan2
String len, substr, chr, ord, to_int, to_float
Array matrix, rows, cols, dim, keys
File open, close, read_line, read_all, write
Network http_get, http_post, response_status, response_body
Socket socket_open, socket_connect, socket_send, socket_recv, socket_close, socket_bind, socket_listen, socket_accept, get_ip
GUI tk_root, tk_widget, tk_pack, tk_grid, tk_bind, tk_mainloop, tk_canvas_*, tk_dialog_*
TUI curses_init, curses_end, curses_print, curses_refresh, curses_getkey, curses_clear, curses_rows, curses_cols
System system, exec

๐Ÿ”‘ Keywords

Category Keywords
Control if, else, for, while, switch, case, default, break, continue
Functions func, return
Data struct, new, null, true, false
Error try, catch, throw
Module include
Constants PI, E

๐Ÿ† Stress Tests Passed

โœ… Sieve of Eratosthenes โ€” 1,000,000 numbers, found all 78,498 primes up to 999,983
โœ… Neural Network XOR โ€” MLP 2-2-1 with backpropagation
โœ… Recursive Fibonacci โ€” Deep recursion handling
โœ… Nested loops โ€” Complex iteration patterns

๐Ÿ—‚๏ธ Project Structure

ascension/
โ”œโ”€โ”€ ascension_12_8.py        # Main interpreter (v12.8 Atomo Edition)
โ”œโ”€โ”€ ascension_shell_12_7.py  # Interactive REPL shell
โ”œโ”€โ”€ cpp/                     # C++ implementation
โ”‚   โ”œโ”€โ”€ ascension.cpp        # Main C++ interpreter
โ”‚   โ”œโ”€โ”€ value.hpp            # Value types
โ”‚   โ”œโ”€โ”€ compiler.hpp         # Bytecode compiler
โ”‚   โ”œโ”€โ”€ vm.hpp               # Virtual machine
โ”‚   โ””โ”€โ”€ modules/             # Optional modules
โ”‚       โ”œโ”€โ”€ mod_fileio.hpp   # File I/O (always included)
โ”‚       โ”œโ”€โ”€ mod_curses.hpp   # Terminal UI (optional)
โ”‚       โ””โ”€โ”€ mod_network.hpp  # HTTP/Sockets (optional)
โ”œโ”€โ”€ ascension_examples/      # Example programs
โ”‚   โ”œโ”€โ”€ hello.asc
โ”‚   โ”œโ”€โ”€ calculator.asc
โ”‚   โ”œโ”€โ”€ fibonacci.asc
โ”‚   โ”œโ”€โ”€ sieve.asc            # Sieve of Eratosthenes (tested on 1M numbers!)
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ lib/                     # Libraries
โ”‚   โ”œโ”€โ”€ neural_network.asc   # Neural network library
โ”‚   โ””โ”€โ”€ nn_demo.asc          # Neural network demo
โ”œโ”€โ”€ docs/                    # Documentation
โ”‚   โ””โ”€โ”€ ascension_manual.pdf
โ”œโ”€โ”€ LICENSE                  # GPL v3
โ””โ”€โ”€ README.md

๐Ÿ“š Documentation

  • User Manual (PDF) โ€” Complete 21-chapter guide
  • Shell Guide โ€” Interactive REPL documentation
  • Examples โ€” Sample programs

๐Ÿ“œ Version History

Version Name Highlights
12.8 Atomo Edition curses_rows(), curses_cols() โ€” terminal size detection for dynamic TUI
12.7 Math Edition 17 math functions, neural network library, PI/E constants
12.6 Substr Edition substr(), chr() string functions
12.5 String Edition Enhanced string operations
12.4 System Edition system(), exec() commands
12.3 Matrix Edition 2D arrays, matrix() function

๐Ÿ‘ค Author

EdeFede โ€” GitHub

Created through "vibe coding" with LLMs, exploring programming language development and generative thinking patterns.

๐Ÿ“„ License

This project is licensed under the GPL v3 License. See LICENSE for details.


Remember: Whether you choose Python for rapid development or C++ for performance, you're writing the same Ascension language. The implementation is just a detail โ€” Ascension IS the syntax.

// The same code runs on both implementations
func main() {
    print("One language. Multiple runtimes. Infinite possibilities.");
}

About

Ascension is a lightweight, interpreted programming language written in Python, featuring a C-like syntax with built-in support for GUI, web requests, file I/O, and more.

Topics

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors