Skip to content

nearly complete version of supercode compiler (scc) written in C for linux only. Deppendent on gcc and nasm

Notifications You must be signed in to change notification settings

ahamedrashid-me/SuperCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SuperCode - Systems Programming Language

Version Functions Tests License

SuperCode is a lean, fast systems programming language that compiles directly to x86-64 with zero external dependencies. Built for developers who want full control over their code without bloatware.

πŸš€ Features

Zero Bloatware Philosophy

  • 88 functions covering essential systems programming
  • No garbage collection - direct memory control
  • Single-file executable output (~100KB runtime)
  • Direct x86-64 compilation via NASM and GCC
  • Zero external dependencies (except pthread for threading)

Core Capabilities

Phase 1: Synchronization (14 functions)

  • Mutexes, semaphores, condition variables
  • Atomic compare-and-swap operations
  • Lock-free primitives for concurrent code

Phase 2: Concurrency (10 functions)

  • Go-style channels with bounded queues
  • Thread pool with task distribution
  • FIFO task scheduling

Phase 3: System I/O (16 functions)

  • BSD socket API (TCP/UDP)
  • File I/O with POSIX semantics
  • Memory mapping (mmap/munmap)
  • Hardware I/O (port and MMIO access)

Phase 4: Advanced Functions (4 functions)

  • Direct Linux syscall wrapper
  • Interrupt control (enable/disable)
  • Signature verification framework
  • Benchmarking infrastructure

Phase 5: String & Math (44 functions)

  • PHP-style string manipulation
  • Mathematical operations and bit manipulation
  • Error handling framework
  • Process/resource control
  • Date/time operations
  • Sorting and searching algorithms

πŸ“¦ What You Get

supercode/
β”œβ”€β”€ src/              # Compiler source (lexer, parser, codegen)
β”œβ”€β”€ runtime/          # Runtime libraries (strings, math, sync, etc)
β”œβ”€β”€ include/          # Builtin function definitions
β”œβ”€β”€ builtin/          # Test suite (25 test files)
└── scc               # SuperCode compiler (ready to use)

⚑ Quick Start

Installation

git clone https://github.com/ahamedrashid-me/SuperCode.git
cd SuperCode
make

First Program

Create hello.su:

fnc main[]::int {
    show["Hello, World!\n"];
    get[0];
}

Compile and run:

./scc hello.su -o hello
./hello

String Manipulation (PHP-style)

fnc main[]::int {
    str text = "hello world";
    
    str upper = @upper[text];
    str trimmed = @trim[text];
    str substring = @substr[text, 0, 5];
    int pos = @index[text, "world"];
    str replaced = @replace[text, "world", "SuperCode"];
    
    show[upper];      /* HELLO WORLD */
    show[replaced];   /* hello SuperCode */
    
    get[0];
}

Concurrent Programming

fnc main[]::int {
    int pool = @pool_create[4];
    
    loop[int i = 0; i < 16; i = i + 1] {
        @pool_submit[pool, 0, i];
    }
    
    @pool_wait[pool];
    @pool_destroy[pool];
    
    get[0];
}

Memory Management

fnc main[]::int {
    int ptr = @alloc[1024];
    @poke[ptr, 42];           /* Write to memory */
    int value = @peek[ptr];   /* Read from memory */
    @free[ptr];
    
    get[0];
}

Systems Programming

fnc main[]::int {
    int sock = @socket[1, 0];           /* TCP socket */
    @connect[sock, 127000001, 8080];    /* localhost:8080 */
    
    int bytes_sent = @send[sock, buffer, 1024];
    int bytes_recv = @recv[sock, buffer, 1024];
    
    @close[sock];
    get[0];
}

πŸ“š Core Builtins

String Manipulation (@)

@len[str]              - String length
@substr[str, pos, len] - Extract substring
@upper[str]            - Uppercase
@lower[str]            - Lowercase
@trim[str]             - Remove whitespace
@split[str, delim]     - Split into array
@join[arr, delim]      - Join array
@index[str, substr]    - Find position
@replace[str, old, new]- Replace all

Math Operations (@)

@sqrt[x]      - Square root
@pow[x, y]    - Exponentiation
@abs[x]       - Absolute value
@min[a, b]    - Minimum
@max[a, b]    - Maximum
@clz[x]       - Count leading zeros

Memory (@)

@alloc[size]           - Allocate heap memory
@free[ptr]             - Free memory
@realloc[ptr, size]    - Reallocate
@peek[addr]            - Read value
@poke[addr, value]     - Write value
@memcpy[dst, src, len] - Copy memory
@memset[addr, val, len]- Fill memory

Concurrency (@)

@mutex_create[]           - Create mutex
@mutex_lock[id]           - Lock
@mutex_unlock[id]         - Unlock
@semaphore_create[count]  - Create semaphore
@channel_create[size]     - Create channel
@pool_create[workers]     - Create thread pool

I/O (@)

@socket[type, proto]    - Create socket
@connect[sock, addr, p] - Connect
@send[sock, buf, len]   - Send data
@recv[sock, buf, len]   - Receive data
@fopen[path, flags]     - Open file
@fread[fd, buf, len]    - Read file
@fwrite[fd, buf, len]   - Write file

System (@)

@syscall[num, arg...]   - Direct syscall
@fork[]                 - Create process
@exec[path, args]       - Execute program
@exit[code]             - Exit process
@sleep[ms]              - Sleep
@clock[]                - Get time

πŸ”§ Building from Source

Requirements

  • GCC 7+
  • NASM 2.14+
  • Linux x86-64

Build

make clean
make

Run Tests

cd builtin
for test in t{1..25}_*.su; do
    echo "Testing $test..."
    ../scc "$test" -o /tmp/test
    /tmp/test
done

πŸ“Š Statistics

Phase Functions Tests Status
1: Sync 14 2 βœ… Complete
2: Concurrency 10 2 βœ… Complete
3: System I/O 16 4 βœ… Complete
4: Advanced 4 1 βœ… Complete
5: String/Math 44 7 βœ… Complete
Total 88 25 βœ… 92%

🎯 Design Principles

  1. Lean & Fast - Minimal overhead, maximum control
  2. Zero Bloat - Only essential functionality
  3. Direct Compilation - NASM + GCC, no intermediates
  4. Systems Ready - Fork, sockets, syscalls, hardware I/O
  5. PHP-like Strings - Intuitive, easy string handling

πŸ“– Documentation

πŸ’‘ Example Programs

Hello World

fnc main[]::int {
    show["Hello, World!\n"];
    get[0];
}

Fibonacci

fnc fib[int n]::int {
    if[n <= 1] {
        get[n];
    } or {
        get[fib[n - 1] + fib[n - 2]];
    }
}

fnc main[]::int {
    int result = fib[30];
    show[result];
    show["\n"];
    get[0];
}

Thread Pool

fnc main[]::int {
    int pool = @pool_create[4];
    
    loop[int i = 0; i < 100; i = i + 1] {
        @pool_submit[pool, 0, i];
    }
    
    @pool_wait[pool];
    @pool_destroy[pool];
    show["All tasks done\n"];
    get[0];
}

Network Server

fnc main[]::int {
    int server = @socket[1, 0];
    @bind[server, 0, 8080];
    @listen[server, 5];
    
    show["Listening on port 8080\n"];
    
    int client = @accept[server];
    int bytes = @recv[client, buf, 1024];
    
    @send[client, buf, bytes];
    @close[client];
    @close[server];
    
    get[0];
}

πŸ› Known Limitations

  • Threading functions require proper runtime linking
  • Cryptographic functions are stubs (not implemented)
  • No GUI/graphics support
  • x86-64 Linux only

πŸ”’ Security

  • No buffer overflow protection
  • Direct memory access
  • No type safety enforcement
  • Use with caution in untrusted code

πŸ“ License

MIT License - See LICENSE file for details

🀝 Contributing

Contributions welcome! Focus areas:

  • Remaining 8 functions (8%)
  • Cryptographic implementation
  • Optimization passes
  • Windows/macOS support

πŸ‘¨β€πŸ’» Author

Rashid Ahmed - GitHub

πŸ“ž Support

  • GitHub Issues: Report bugs and feature requests
  • Documentation: See builtin/ directory for guides
  • Examples: Check builtin/t*.su test files

SuperCode v0.2 - Lean systems programming without the bloat

πŸ”— Repository: https://github.com/ahamedrashid-me/SuperCode

About

nearly complete version of supercode compiler (scc) written in C for linux only. Deppendent on gcc and nasm

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages