11 opcodes.
Native binaries.

also known as BodyGuard — H4928 — the language that guards the body of the program

mishmaath is a numbered-instruction language — every line is a number and an operand.
numbered instructions eliminate syntax noise. what you write maps directly to what happens.
it transpiles to C, then gcc compiles it to a native binary. no runtime. no VM. no interpreter.

view on github language reference python3 + gcc required
$ git clone https://github.com/ajax80/mishmaath && cd mishmaath && chmod +x mishmaath

how to read a mishmaath program

every line starts with a number — the opcode. everything after it is the operand. indentation is optional and ignored.

3 x 7          →  let x = 7
5 x > 5       →  if (x > 5) {
  2 "big"       →    print "big"
5             →  }   bare 5 closes the block
9 i 0 10      →  for (i = 0; i < 10; i++) {
  2 "%d" i    →    printf("%d\n", i)
9             →  }   bare 9 closes the loop
7             →  return 0

opcodes 0–6 are language mechanics. 7 is return. 8 is mutation. 9 is loops. 10 is all I/O — terminal, network, file, database.

the opcode table

eleven instructions. one per line. first token is the opcode.

opnamewhat it does
0moduletop-level setup, raw C passthrough via 0 c ...
1functiondeclare a function — 1 main, 1 add #a #b
2printoutput — literal, variable, or printf-style format string
3letdeclare or assign — int, float, string, array, 2D array
4channelopen I/O channel or call a function
5ifconditional — if / else if / else / end, compound and/or/not
6computetransform — strlen, strip, split, replace, upper, lower, join, exists, read, json, atoi, fmt, sqrt, regex...
7returnend function, optionally return a value
8mutatein-place arithmetic or string append — += -= *= ++ strcat
9loopfor / while / decrement / step / stdin / file / sqlite query / websocket recv — bare 9 closes
10ionetwork, terminal, file, database, threads, processes — HTTP, TCP, WebSocket, SQLite, shell_all, pipe, spawn...

quick examples

hello world
#!/usr/bin/env mishmaath
0
1 main
4 stdout
2 "Hello, World"
7
variables + loop
#!/usr/bin/env mishmaath
0
1 main
4 stdout
3 i 0
9 i 0 10
  2 "%d" i
9
7
HTTP GET + JSON
#!/usr/bin/env mishmaath
0
1 main
4 stdout
10 body get "https://httpbin.org/get"
6  ip json "origin" body
2  "your ip: %s" ip
7
TCP HTTP server
#!/usr/bin/env mishmaath
0
1 main
4 stdout
10 srv listen 8080
9  client accept srv
  10 req recv client
  6  path http_path req
  3  r "OK: "
  8  r +path
  10 client http_ok r
  10 client close
9
7
2D array
#!/usr/bin/env mishmaath
0
1 main
4 stdout
3 grid 10 20   # cols x rows
3 grid 3 4 99 # grid[3][4] = 99
6 v grid 3 4  # v = grid[3][4]
2 "%d" v
7
sqlite3 database
#!/usr/bin/env mishmaath
#link sqlite3
0
1 main
4 stdout
10 db open "log.db"
10 db exec "CREATE TABLE IF NOT EXISTS log (id INTEGER PRIMARY KEY, msg TEXT)"
10 db exec "INSERT INTO log (msg) VALUES ('hello')"
9  row db query "SELECT id, msg FROM log"
  6 id  db col 0
  6 msg db col 1
  2 "[%s] %s" id msg
9
10 db close
7
float math
#!/usr/bin/env mishmaath
#link m
0
1 main
4 stdout
3 pi 3.14159
6 r sqrt pi
2 "sqrt(pi) = %g" r
6 n ftoi r
2 "as int: %d" n
7
token stream processor
#!/usr/bin/env mishmaath
0
1 main
4 stdout
3 line
9 line stdin
  6 line strip line
  5 line contains "let" or line contains "assign"
    2 "[3·declare]  %s" line
  5 else line contains "compute" or line contains "derive"
    2 "[6·compute]  %s" line
  5 else line contains "if " or line contains "when "
    2 "[5·branch]   %s" line
  5 else
    2 "[?·unmapped] %s" line
  5
9
7
concurrent threads
#!/usr/bin/env mishmaath
0
3 running 1

1 worker
9 running != 0
  2 "tick"
  10 sleep 100
9
7

1 main
4 stdout
10 spawn worker
10 sleep 500
3 running 0
10 join worker
7
WebSocket client
#!/usr/bin/env mishmaath
0
1 main
4 stdout
10 ws open "ws://echo.websocket.org/"
10 ws send "hello"
9  msg ws recv
  2 msg
9
10 ws close
7
string ops
#!/usr/bin/env mishmaath
0
1 main
4 stdout
3 s "Hello, World"
3 found 0
6 found contains s "World"
3 out
6 out replace s "World" "mishmaath"
3 word
6 word split s ","
3 u
6 u upper s
2 "found=%d replace=%s split=%s upper=%s" found out word u
7
regex
#!/usr/bin/env mishmaath
0
1 main
4 stdout
3 s "order #4821 placed"
6 m match "[0-9]+" s
5 m == 1
  6 id match_get "[0-9]+" s 0
  2 "order: %s" id
5
7
functions
#!/usr/bin/env mishmaath
0
1 double #n
3 r n
8 r *2
7 r

1 main
4 stdout
3 x double 21
2 "%d" x
7
float arrays
#!/usr/bin/env mishmaath
#link m
0
1 main
4 stdout
3 arr[] 5.0    # double arr[5]
3 arr.0 1.1
3 arr.1 2.2
3 arr.2 3.3
3 v 0.0
6 v arr 0     # v = arr[0]
2 "arr[0] = %g" v
9 i 0 3
  6 v arr i
  2 "arr[%d] = %g" i v
9
7
file ops
#!/usr/bin/env mishmaath
0
1 main
4 stdout
3 s "mishmaath writes"
10 write s "out.txt"
3 n 0
6 n exists "out.txt"
2 "exists: %d" n
3 data
6 data read "out.txt"
2 "read: %s" data
5 _err != 0
  2 "read failed"
5
10 delete "out.txt"
7
shell + pipe
#!/usr/bin/env mishmaath
0
1 main
4 stdout
3 out
10 out shell_all "ls *.mish"
2 "mish files:\n%s" out
3 result
3 input "hello bodyguard"
10 result pipe "tr a-z A-Z" input
2 "piped: %s" result
7

error state

_err is a global int, always available. every fallible op sets it — 0 = ok, non-zero = failed.

10 body get "https://api.example.com/data"
5 _err != 0
  2 "request failed: %d" _err
5 else
  2 "got: %s" body
5

sets _err: 10 get · 10 post · 10 db open · 10 db exec · 10 ws open · 10 srv listen · 10 shell · 10 write · 6 read

run a program

# run directly (add #!/usr/bin/env mishmaath and chmod +x)
./hello.mish

# compile to named binary
./mishmaath hello.mish -c -o hello

# inspect generated C
./mishmaath hello.mish -o hello.c

# link external libraries
#link m                     # adds -lm to gcc
0 c double r = sqrt(2.0);  # raw C passthrough

what it compiles to

mishmaath is a transpiler. Your program becomes C, then gcc turns it into a native binary. The transpiler is ~1000 lines of Python. No external libraries.

# this mishmaath program:
3 x 7
5 x > 5
  2 "big"
5 else
  2 "small"
5

# becomes this C:
int x = 7;
if (x > 5) {
    printf("big\n");
} else {
    printf("small\n");
}