Stdlibs at: https://github.com/stefand-0/solstd
Sol — Embrace modularity, ease of use, and speed.
Sol is a lightweight scripting language that compiles to C. It gives you the raw performance of C with a cleaner, more modern syntax — and a module system that actually makes sense.
C is fast. C is everywhere. But C is also verbose, error-prone, and lacks a sane way to organize code across files.
Sol fixes that.
- Modular by design —
get("path/to/module.sol")imports just work, including nested subdirectories - Familiar syntax — C-style types and control flow, minus the footguns
- Zero-cost abstraction — transpiles to clean C, then compiles with clang or gcc
- No build system headaches — one command compiles and runs
pip install tsolcRequires Python 3.10+ and a C compiler (clang, gcc, or cc).
showcase/showcase.sol
hello.sol
main() out int
out("Hello, World!\n")
return 0tsolc hello.sol --run| Sol | C |
|---|---|
int, float, double, char, |
Same |
string |
char* |
int8–int64, uint8–uint64 |
int8_t–int64_t, uint8_t–uint64_t |
int[], float[], ... |
Pointer + compound literal |
int count -> 42
float pi -> 3.14
string name -> "Sol"
int[] nums -> [1, 2, 3, 4, 5]Assignment uses -> to avoid confusion with ==:
count -> count + 1pub square(int n) out int
return n * npubmarks the function as public (importable from other files)out typespecifies the return type; omit forvoid
get("std/math.sol")
get("utils/helpers.sol")Paths are relative to the importing file. Subdirectories work naturally:
get("std/io/file.sol")
get("../shared/types.sol")Imports are deduplicated automatically — no header guards needed.
Indentation-based blocks — no braces, no end keyword:
if (x > 0)
out("positive\n")
elseif (x < 0)
out("negative\n")
else
out("zero\n")
int i
for i -> 0; i < 10; i++
out("%d\n", i)
while (running)
running -> falsestring sign -> x > 0 ? "positive" : "negative"
int abs -> x < 0 ? -x : x// Output
out("Hello, %s!\n", name)
// Input can be done with inline CDrop straight into C when you need it:
C -> "double result = 2.0;"struct Point
float x
float ymyproject/
├── main.sol
├── std/
│ └── math.sol
└── utils/
└── string.sol
main.sol
get("std/math.sol")
main() out int
int result -> pow(2, 10)
out("2^10 = %d\n", result)
return 0tsolc file.sol # Compile only
tsolc file.sol --run # Compile and run
tsolc file.sol --keep-c # Keep the generated .c file- Parse — Sol source is tokenized and parsed into an AST (indentation-aware)
- Resolve —
get()imports are recursively resolved and merged - Generate — Clean C11 code is emitted (structs first, then forward declarations, then definitions)
- Compile — clang/gcc compiles the C to a native executable
- Run — The binary is executed (with
./prefix and proper permissions on Unix)
MIT — see LICENSE for details.