Skip to content

Reducing boilerplate code #670

@mmagician

Description

@mmagician

To compile even a simple program, a lot of boilerplate is needed, e.g. for the counter contract:

#![no_std]

#[global_allocator]
static ALLOC: miden::BumpAlloc = miden::BumpAlloc::new();

#[cfg(not(test))]
#[panic_handler]
fn my_panic(_info: &core::panic::PanicInfo) -> ! {
    loop {}
}

bindings::export!(IncrementCounterNote with_types_in bindings);

mod bindings;

use bindings::{exports::miden::base::note_script::Guest, miden::counter_contract::counter};
use miden::*;
<only now starts the actual logic>

Looking through some other projects in the space and how they handle compilation from high-level languages, I came across the Leo tutorials: https://www.youtube.com/watch?v=PM_NBNti9H0
where writing Rust-like language requires almost no boilerplate (I assume they need to do similar things as here but that are handled under the hood). It would be amazing to provide a similar experience for Miden.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions