The syntax of every modern programming language keeps getting more complex with each new release (standard). This is an unavoidable price for language evolution and a constantly growing "entry tax" for newcomers.
TrustLang — is a language-«layer» on top of
Safe memory without a garbage collector
Stack overflow — as an exception
Program stack overflow is handled as an ordinary program exception, instead of abnormal termination with segfault. Stack protection →
Automatic protection from dangling references
Static analysis of dangling references (analogous to ownership and borrowing in Rust),
but for
Type system
Static and dynamic typing.
The type can be specified explicitly or inferred automatically from the context.
Ability to use
Integration with C/C++
Embedding of
Formal verification
Contract programming (pre/postconditions, assertions). Export of code and contracts to an SMT solver (Z3). Verification* →
How it looks
An example of a simple TrustLang program with unlimited-precision numbers and automatic type inference.
Running the program as a bash script with automatic compilation of the C++ code on the first run and subsequent execution of the binary file. Automatic recompilation when the source changes.
#!../_build/trust --run -Wsigil=ignore -Wembed=ignore
$fact := 1\1; # Autotyping
$mult:Int32 := 1; # Fixed type
while( mult <= 40 ) {
fact *= mult; # factorial 40, no precision loss
{% $mult++ %}; # Increment as a C++ code fragment
};
@print('{}', fact);
Output:
815915283247897734345611269596115894272000000000
More examples and the resulting generated