Skip to content

Commit

Permalink
πŸ“ add why zig section
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelStark committed Oct 24, 2023
1 parent 6e5a3ee commit 0e29f7d
Showing 1 changed file with 48 additions and 26 deletions.
74 changes: 48 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,46 @@

- [Zig](https://ziglang.org/)

## ⚑ Why Zig?

Choosing Zig for a third implementation of the Cairo VM brings several advantages, offering a unique blend of features not entirely covered by the existing Rust and Go implementations.

### 1. Simplicity and Readability

Zig aims for simplicity and clarity, enabling developers to read and understand the code quickly. It omits certain features like classes and exceptions to keep the language simple, which can be particularly useful for a VM where performance and maintainability are key.

### 2. Performance

Zig compiles to highly efficient native code, similar to Rust, making it an excellent choice for computationally-intensive tasks. The language's design gives the programmer direct control over memory and CPU, without unnecessary abstractions.

### 3. Explicit Control with Safety Features

Zig provides an environment where you have explicit control over memory allocation, similar to C and C++. While this does mean you're responsible for managing memory yourself, Zig offers certain safety features to catch common errors, like undefined behavior, during compile time or by providing runtime checks. This approach allows for a blend of performance and safety, making it a suitable choice for a VM where you often need fine-grained control.

### 4. C Interoperability

Zig offers first-class C interoperability without requiring any bindings or wrappers. This feature can be a game-changer for integrating with existing technologies.

### 5. Flexibility

Zig's comptime (compile-time) features offer powerful metaprogramming capabilities. This allows for expressive yet efficient code, as you can generate specialized routines at compile-time, reducing the need for runtime polymorphism.

### 6. Minimal Dependencies

Zig aims to reduce dependencies to a minimum, which could simplify the deployment and distribution of Cairo VM. This is particularly advantageous for systems that require high-reliability or have limited resources.

### 7. Community and Ecosystem

Although younger than Rust and Go, Zig's community is enthusiastic and rapidly growing. Adopting Zig at this stage means you can be a significant contributor to its ecosystem.

By choosing Zig for the third implementation of Cairo VM, we aim to leverage these features to build a high-performance, reliable, and maintainable virtual machine.

## ⚑ Wanna learn Zig fast?

- [Zig language reference](https://ziglang.org/documentation/master/)
- [Zig Learn](https://ziglearn.org/)
- [Ziglings](https://ziglings.org/)

## πŸ”§ Build

```bash
Expand All @@ -34,24 +74,6 @@ You can display the help message by running:
./zig-out/bin/cairo-zig --help
```

```text
cairo-zig
Version: 0.0.1
Author: StarkWare & Contributors
USAGE:
cairo-zig [OPTIONS]
Cairo Virtual Machine written in Zig.
Highly experimental, use at your own risk.
COMMANDS:
execute Execute a cairo program.
OPTIONS:
-h, --help Prints help information
```

### Run a cairo program

```
Expand All @@ -75,14 +97,6 @@ zig build test --summary all
- [ ] Check [Zig style guide](https://ziglang.org/documentation/master/#Style-Guide) and apply it.
- [ ] Create documentation.

## πŸ“„ License

This project is licensed under the MIT license.

See [LICENSE](LICENSE) for more information.

Happy coding! πŸŽ‰

## πŸ“š Resources

Here are some resources to help you get started:
Expand All @@ -98,3 +112,11 @@ Here are some resources to help you get started:
- Some cryptographic primitive code generation has been done using the amazing [fiat-crypto](https://github.com/mit-plv/fiat-crypto) by [mit-plv](https://github.com/mit-plv).
- [sig](https://github.com/Syndica/sig) has been a great source of inspiration for the project structure and the way to use Zig.
- [nektro](https://github.com/nektro/) for the [zig-time](https://github.com/nektro/zig-time) library.

## πŸ“„ License

This project is licensed under the MIT license.

See [LICENSE](LICENSE) for more information.

Happy coding! πŸŽ‰

0 comments on commit 0e29f7d

Please sign in to comment.