Skip to content

3.0.0

Latest

Choose a tag to compare

@Sreyas-Sreelal Sreyas-Sreelal released this 06 Apr 07:21
69e7725

Malluscript v3.0.0 - The Native Extension Update

This major release completely breaks down the barrier between esoteric scripts and mainstream performance by introducing Native C-ABI Plugins.

What's Changed

  • Native Plugin Support: You can now import high-performance dynamic libraries (.dll, .so, .dylib) seamlessly as modules using the ulppeduthuka keyword, exactly like regular .ms scripts.
  • Bidirectional FFI: Native C/Rust plugins can interact directly with Malluscript's execution state, allowing them to share data and even invoke Malluscript functions via callbacks.
  • The mallubind Rust Crate: We have officially launched the mallubind crate, which provides a safe, idiomatic Rust wrapper over the raw Malluscript C-ABI. Building complex native extensions for Malluscript is now incredibly easy and type-safe.
  • Isolated Module Contexts: Every plugin is loaded into its own isolated memory space to avoid polluting the global variable namespace, ensuring scalable architecture.

Native Plugin System Details

Malluscript now acts as a full-fledged engine. Instead of being limited to just Malayalam script processing, you can offload heavy operations (like File I/O, networking, and graphics rendering) to Rust or C.

Example: Building a Native Web Server
By compiling a Rust plugin (e.g. http_plugin.dll) that exposes TCP sockets and HTTP responses via mallubind, you can import it into Malluscript and host web pages!

http_plugin http ennu ulppeduthuka;

"Starting web server on port 3000...\n" ezhuthuka;
server_id = http.http_listen<3000>;

1 um 1 um thullyamanengil avarthikuga {
    client_id = http.http_accept<server_id>;
    0 ne_kal client_id veluthan enkil {
        request = http.http_read<client_id>;
        response = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\n\r\n<h1>Malluscript Server!</h1>";
        http.http_write<client_id, response>;
        http.http_close<client_id>;
    }
}

The mallubind Abstraction

Developers looking to extend Malluscript no longer need to write dangerous unsafe C code. Using the mallubind crate and the malluscript_native! macro, creating bindings takes seconds:

use mallubind::{InterpreterState, Value, malluscript_native};

malluscript_native!(add_numbers, reg, |args: &[Value]| {
    let a = args.get(0).and_then(|v| v.as_integer()).unwrap_or(0);
    let b = args.get(1).and_then(|v| v.as_integer()).unwrap_or(0);
    Ok(Value::Integer(a + b))
});

#[no_mangle]
pub extern "C" fn register_mallubind(registry: *const mallubind::ffi::MsInterpreterState) {
    let reg = InterpreterState::new(registry);
    reg.register("add_numbers", add_numbers);
}

C/C++ Support via C-ABI

For developers who prefer writing plugins in C or C++, the underlying architecture is fully exposed through a standard C-ABI. You can build plugins natively in C by exporting the same register_mallubind interface and manipulating raw MsValue primitives—meaning Malluscript plugins can be built in virtually any compiled language that supports C headers!


Support the Project

If you find Malluscript useful, please consider supporting the development through any of the following platforms:

For more details and examples, visit the Malluscript Repository.

Full Changelog: 2.0.0...3.0.0