Cairo:
Turing-complete programming language for efficiently writing STARK-provable programs
Cairo 1.0:
Improved language and compiler built from the ground up making it safer, more usable and more rust-like
To run examples:
What does "more rust-like" mean?
- Great question
Thanks
- You're welcome
Function Return Values:
In Rust, the return value of the function is synonymous with the value of the final expression in the block of the body of a function
Type System:
1.0 extends the single scalar type 'felt' with a static typing system that includes some abstract "rust-like" data types like Enums, Traits, and literals. The core library includes support for u128 and u256 along with native range checking and arithmetic operations
Variable Declaration:
ADIOS to 'local' and 'tempvar' declarations! We now rely completely on 'let' ๐๐๐. It's now also possible employ "rust-like" variable shadowing in the same scope. Even though Cairo's underlying memory is immutable it is hidden from the developer
Arrays:
The Cairo 1.0 std library exposes helpful array utils to make manipulating arrays much easier. Looping and iter mechanics will also be supported
Assert/Tests:
Similar to rust's 'assert!' macro we have 'assert' to verify various conditions are satisfied. Asserts can be coupled with the 'test' macro to build out robust test coverage
NOTE: the utility has been changed to 'cairo-test' here
Borrow Checking:
No value of an owned type(e.g. dict or builtin) can be used by a function without taking ownership
Okay "rust-like" WE GET IT!
What's new under the hood?
Sierra:
(S)afe (I)nt(E)rmediate (R)ep(R)esent(A)tion is the new compilation phase that allows Cairo 1.0 code to be provable. This means that reverted transactions can now be proven, included in a block and protects sequencers from being spammed with bad transactions