Every syntax rule. Every mode. Every benchmark. One page. Built for developers and AI assistants.
When writing SymbolCore code, follow these rules exactly:
.sym — alwaysfn name(param: type) -> return_type — NOT deflet x = value — NOT bare assignmentimport py.numpy as np — the py. prefix is REQUIRED"Hello {name}" — no f prefix neededprint and sort are keywords: print "hello", sort data — no parentheses0..100 — two dots, exclusive end(x) => x * 2 — fat arrow, not lambdatry/catch — NOT try/excepttrue false none — lowercaseand or not — words, not && || !SymbolCore compiles to Python (for library access) and C (for speed). Pure functions auto-compile to native C via gcc. Python library calls stay as Python. The compiler decides — you write one file.
# hello.sym — this is all you need print "Hello from SymbolCore!" let name = "World" print "Hello, {name}!"
# Run it
sym run hello.sym
let x = 42 let name = "Abir" let pi = 3.14159 let active = true let items = [1, 2, 3]
const MAX = 1000 const URL = "https://api.example.com"
let x: int = 42 let name: str = "Abir"
let x = 10 x = 20 # no let for reassignment x += 5 # compound: += -= *= /=
let. Subsequent reassignments don't. const cannot be reassigned.Types are optional. Adding them enables better C compilation and catches errors early.
| SymbolCore | Description | C Type |
|---|---|---|
int | 64-bit integer | int64_t |
i32 | 32-bit integer | int32_t |
float | 64-bit float | double |
f32 | 32-bit float | float |
bool | Boolean | int |
str | UTF-8 string | char* |
list<T> | Dynamic array | Python list |
dict<K,V> | Hash map | Python dict |
T? | Optional (nullable) | — |
name: type. Return types use arrow: -> type.fn add(a: int, b: int) -> int return a + b
fn double(x: int) -> int => x * 2
fn greet(name: str) print "Hello {name}"
fn connect(host: str, port: int = 8080) print "Connecting to {host}:{port}"
fn factorial(n: int) -> int if n <= 1 return 1 return n * factorial(n - 1)
fn, NOT def. No colon after signature. No parentheses around body. 4-space indent. Return type uses ->.if score >= 90 grade = "A" elif score >= 80 grade = "B" else grade = "F"
if/elif/else. No parentheses around condition. Body indented 4 spaces.for i in 0..10 print i # 0 through 9 (exclusive end)
for item in items print item
for i, val in enumerate(data) print "{i}: {val}"
let x = 0 while x < 100 x += 1
for i in 0..100 if i == 50 break if i % 2 == 0 continue print i
start..stop (exclusive end). Two dots. No colon after for/while. range() also works.let name = "Abir" let age = 28 print "Name: {name}, Age: {age}" # auto f-string print "2 + 2 = {2 + 2}" # expressions work let msg = "Score: " + str(score) # concatenation
{expr} auto-interpolates. No f"..." prefix needed. Both "double" and 'single' quotes work.let nums = [1, 2, 3, 4, 5] let first = nums[0] # indexing let slice = nums[1:3] # slicing nums.append(6) # methods work
let user = {"name": "Abir", "age": 28} print user["name"]
let point = (3.0, 4.0)
struct Point x: float y: float fn distance(self, other: Point) -> float let dx = self.x - other.x let dy = self.y - other.y return sqrt(dx * dx + dy * dy) let p1 = Point(0.0, 0.0) let p2 = Point(3.0, 4.0) print p1.distance(p2) # 5.0
struct Config host: str = "localhost" port: int = 8080
self as first param. Structs stay in Python mode (not compiled to C).trait Printable fn to_string(self) -> str impl Printable for Point fn to_string(self) -> str return "Point({self.x}, {self.y})"
Use ANY pip package. The py. prefix tells the compiler it's a Python library. Missing packages are auto-installed.
import py.numpy as np import py.pandas as pd import py.matplotlib.pyplot as plt import py.requests as req import py.sklearn.ensemble as sk import py.torch as torch import py.bs4.BeautifulSoup as BS import py.json as json import py.os as os import py.sys as sys
import py.numpy as np let data = np.array([1, 2, 3, 4, 5]) print "Mean: {np.mean(data)}"
When a package is missing: pip install --user → pip3 install --user → sudo apt install python3-pkg → prints manual instructions.
| Module | Pip Package |
|---|---|
cv2 | opencv-python |
PIL | Pillow |
sklearn | scikit-learn |
bs4 | beautifulsoup4 |
yaml | pyyaml |
docx | python-docx |
serial | pyserial |
Crypto | pycryptodome |
py. prefix. import numpy will NOT work. Use import py.numpy as np.Always available. No import needed.
| Function | Usage | Notes |
|---|---|---|
print | print "Hello {x}" | Keyword — no parens needed |
sort | sort data | Keyword — in-place, adaptive algorithm |
len(x) | len(data) | Function call syntax |
map(coll, fn) | map(data, (x) => x*2) | Returns new list |
filter(coll, fn) | filter(data, (x) => x>0) | Returns filtered list |
range(a, b) | range(0, 100) | Same as 0..100 |
enumerate(x) | enumerate(items) | Index + value pairs |
zip(a, b) | zip(keys, vals) | Combine collections |
type(x) | type(42) | Get type |
clone(x) | clone(data) | Deep copy |
str(x) | str(42) | Convert to string |
sqrt(x) | sqrt(16) | Square root |
sin cos tan | sin(3.14) | Trig functions |
log log2 log10 | log(100) | Logarithms |
floor ceil | floor(3.7) | Round down/up |
Constants: PI, E, INF
try let data = read_file("config.json") catch e print "Error: " + str(e) # With type try let r = py.requests.get(url) catch e: Exception print "Failed"
try/catch, NOT try/except. No colons.match command "start" => run() "stop" => shutdown() "help" => show_help() _ => print "Unknown"
=> fat arrow between pattern and action. _ is wildcard/default.let sq = (x) => x * x let add = (a, b) => a + b let evens = filter(data, (x) => x % 2 == 0)
let result = data |> filter((x) => x > 0) |> map((x) => x * 2)
(params) => expr, not lambda. Pipe |> passes left as first arg to right.benchmark fn test_algo() let result = fibonacci(30) print result test_algo() # prints timing automatically
Smart sort picks algorithm by data size:
| Size | Algorithm |
|---|---|
| <16 | Insertion sort |
| Nearly sorted | Timsort |
| Large | qsort (C) / Timsort (Python) |
All three compile to the same AST — zero performance difference. Choose your style.
print "Hello!" let x = 42 print "x = {x}"
#compact >> "Hello!" @ x = 42 >> "x = {x}"
#symbol ⊕ "Hello!" ∂ x = 42 ⊕ "x = {x}"
fn fib(n: int) -> int if n <= 1 return n return fib(n-1) + fib(n-2)
#compact f fib(n: int) -> int ? n <= 1 <- n <- fib(n-1) + fib(n-2)
#symbol ƒ fib(n:ℤ)→ℤ ? n ≤ 1 ← n ← fib(n-1) + fib(n-2)
for i in 0..10 print i while x > 0 x -= 1
#compact ~ i in 0..10 >> i ~~ x > 0 x -= 1
#symbol ∀ i in 0..10 ⊕ i ⟳ x > 0 x -= 1
import py.numpy as np
#compact << py.numpy as np
#symbol ⊂ py.numpy as np
Start file with #compact on the first line.
| Normal | Compact | Meaning |
|---|---|---|
fn | f | Define function |
let | @ | Variable declaration |
return | <- | Return from function |
if | ? | If condition |
elif | ?? | Else-if |
else | ! | Else block |
for | ~ | For loop |
while | ~~ | While loop |
print | >> | Print output |
import | << | Import module |
Everything else (operators, types, strings, structs, etc.) stays the same.
Start file with #symbol. Inherits ALL compact mode shortcuts plus Unicode operators.
| Normal | Symbol | Unicode Name |
|---|---|---|
fn | ƒ | Latin Small F with Hook (U+0192) |
let | ∂ | Partial Differential (U+2202) |
return | ← | Leftwards Arrow (U+2190) |
for | ∀ | For All (U+2200) |
while | ⟳ | Clockwise Arrow (U+27F3) |
import | ⊂ | Subset Of (U+2282) |
print | ⊕ | Circled Plus (U+2295) |
-> | → | Rightwards Arrow (U+2192) |
!= | ≠ | Not Equal To (U+2260) |
<= | ≤ | Less-Than or Equal (U+2264) |
>= | ≥ | Greater-Than or Equal (U+2265) |
= | ≔ | Colon Equals (U+2254) |
int | ℤ | Double-Struck Z (U+2124) |
float | ℝ | Double-Struck R (U+211D) |
bool | 𝔹 | Double-Struck B (U+1D539) |
str | 𝕊 | Double-Struck S (U+1D54A) |
Symbol mode also supports compact shortcuts: ? for if, ! for else, ~ for for, ~~ for while, >> for print, << for import, <- for return.
sym run file.sym automatically:
py.* libraries?.so).so via ctypes, calls native C functions.so is cached — subsequent runs skip compilationpy.* importsbenchmark functionssym check file.sym # ✅ file.sym: 7 statements # Functions: 5 total # → C: 4 (fibonacci, is_prime, count_primes, sum_cubes) # → Python: 1
All benchmarks run on the same machine, same test (fib(35) + sum_squares(1M) + count_primes(100K)).
| Mode | Command | Use when |
|---|---|---|
| Python | sym run --python file.sym | Debugging, or code uses only Python libs |
| Hybrid (default) | sym run file.sym | Mixed code — auto-splits C and Python |
| Native binary | sym build -t native file.sym | Pure computation, no Python libs needed |
| Category | Operators |
|---|---|
| Arithmetic | + - * / // (floor div) % (modulo) ** (power) |
| Comparison | == != < > <= >= |
| Logic | and or not |
| Assignment | = += -= *= /= |
| Range | .. (exclusive end) |
| Arrow | -> (return type) => (lambda / match) |
| Pipe | |> (pass left as first arg to right) |
| Membership | in |
| Access | . (member) [] (index) [:] (slice) |
| Command | What it does |
|---|---|
sym run <file.sym> | Run (hybrid C+Python, automatic) |
sym run -v <file> | Verbose — shows C vs Python split |
sym run --python <file> | Force pure Python mode |
sym run --emit <file> | Show generated C + Python code |
sym run --tokens <file> | Show lexer tokens |
sym run --ast <file> | Show AST |
sym build -t python <file> | Emit .py source |
sym build -t c <file> | Emit .c source |
sym build -t native <file> | Compile to binary (gcc) |
sym build -t hybrid <file> | Build .so + Python wrapper |
sym check <file> | Analyze purity, show C vs Python |
sym repl | Interactive REPL |
sym version | Show version |
import py.requests as req import py.json as json let r = req.get("https://api.github.com/repos/python/cpython") let data = r.json() print "Stars: " + str(data["stargazers_count"])
import py.numpy as np import py.pandas as pd # Pure → compiles to C fn sum_squares(n: int) -> int let total = 0 for i in 0..n total += i * i return total # Python interop → stays Python let df = pd.read_csv("data.csv") print df.describe()
import py.json as json # These 4 → compiled to C fn fibonacci(n: int) -> int if n <= 1 return n return fibonacci(n - 1) + fibonacci(n - 2) fn is_prime(n: int) -> int if n < 2 return 0 let i = 2 while i * i <= n if n % i == 0 return 0 i += 1 return 1 # This → stays Python (uses json) let results = {"fib": fibonacci(35)} print json.dumps(results, indent=2)
#symbol ⊂ py.curses as curses ⊂ py.random as random ƒ game(stdscr) curses.curs_set(0) ∂ snake = [[10, 15], [10, 14], [10, 13]] ∂ dy = 0 ∂ dx = 1 ∂ alive = 1 ⟳ alive == 1 ∂ key = stdscr.getch() ? key == curses.KEY_UP ? dy ≠ 1 dy = -1 dx = 0 # ... movement logic ∂ final = curses.wrapper(game)
if for while fn else elif struct match try catch.fn name(params) -> type. NOT def.let x = value for first assignment. No let for reassignment.import py.package as alias. The py. prefix is REQUIRED."text {expr}" auto-interpolates. No f"..." prefix.print is a keyword: print "hello". No parentheses needed.sort is a keyword: sort data. In-place. Adaptive algorithm.0..100. Two dots. Exclusive end.(x) => x * 2. Fat arrow, not lambda.and or not. Words, not symbols.true false none. Lowercase.try/catch. NOT try/except.match value then pattern => action. _ for default.struct Name with field: type. Methods use fn with self.# comment. Hash style..sym. Always.**. Floor div: //. Modulo: %.|>. Passes left as first arg to right function.#compact or #symbol on first line of file.@=let ?=if !=else ~=for ~~=while >>=print <<=import <-=return f=fn∂=let ƒ=fn ←=return ∀=for ⟳=while ⊂=import ⊕=print ≠=!= ≤=<= ≥=>=ℤ=int ℝ=float 𝔹=bool 𝕊=strSymbolCore v0.2.0 — Complete Language Reference
Hosted on testwallah.in