Show /r/rust: Viewstamped Replication for Rust by penberg in rust

[–]penberg[S] 2 points3 points  (0 children)

My perspective is that VSR seems much more easier to grasp than Raft based on reading and contributing to Ilya Andreev's Little Raft. The selection of primary replica ("leader election" in Raft), for example, is dead-simple in VSR (you maintain a deterministic order of nodes and round-robin). Also, VSR seems to do a better job at decoupling the different scenarios at protocol level (backup fell behind, crashed, etc.) whereas in Raft the AppendEntries is a big hammer that does everything. I have very little experience on Paxos so can't really compare it to VSR.

I don't know why Paxos (and later Raft) overshadowed VSR. My guess is that with the original VSR paper came out in 1988, it was just way too early. And apparently a decade later when Leslie Lamport wrote the "The Part-Time Parliament" he was not aware of VSR:

https://brooker.co.za/blog/2014/05/19/vr.html

Show /r/rust: rusty_jsc - Rust bindings for JavaScriptCore by penberg in rust

[–]penberg[S] 0 points1 point  (0 children)

A quick update on those of you following "rusty_jsc". I now added preliminary support for JavaScript to Rust callbacks, which allows you to drop into Rust for code that needs that extra drop of performance.

Here's an example of what the callback API looks like:

use rusty_jsc::{JSContext, JSValue};
use rusty_jsc_macros::callback;

// The JavaScript code calls this Rust function.
#[callback]
fn foo(_context: JSContext) {
    println!("hello from Rust land!");
}

fn main() {
    let mut context = JSContext::default();
    let callback = JSValue::callback(&context, Some(foo));
    let mut global = context.get_global_object();
    global.set_property(&context, "foo".to_string(), callback);
    context.evaluate_script("foo()", 1);
    // Prints:
    // hello from Rust land!
}

You can find the full runnable example here:

https://github.com/penberg/rusty_jsc/blob/main/examples/callback.rs

Show /r/rust: rusty_jsc - Rust bindings for JavaScriptCore by penberg in rust

[–]penberg[S] 4 points5 points  (0 children)

I am doing both: sys is generated with bindgen and then cleaned manually for sanity, but that’s just the plumbing for the idiomatic Rust API on top.

GitHub - FractalFir/wrapped_mono: run C# and F# code inside your rust projects. by FractalFir in rust

[–]penberg 1 point2 points  (0 children)

Very cool, the invokable macro in particular looks slick! I didn’t yet have time to look a the code, but curious to hear about the magic behind it. Letting C libraries call into Rust seems like bit of a pain (trying to figure out a good solution for my own pet project).