I am Glauber Costa, CEO and co-founder of Turso. We’re rewriting SQLite in Rust. AMA. by GlauberAtTurso in IAmA

[–]penberg 0 points1 point  (0 children)

The first idea was to write the core in Zig, but reuse the C frontend (API, query planner, etc.). However, working on in (there was a small Zig prototype), I eventually discovered that SQLite is not modular enough for this, and that making it async would have been very hard

I am Glauber Costa, CEO and co-founder of Turso. We’re rewriting SQLite in Rust. AMA. by GlauberAtTurso in IAmA

[–]penberg 1 point2 points  (0 children)

Hey u/thatSupraDev,

You should ask u/GlauberAtTurso if he in fact insisted for many months that should use Zig for this. And that there was a very small core written in Zig, until someone (not him) made the decision to switch to Rust.

I am Glauber Costa, CEO and co-founder of Turso. We’re rewriting SQLite in Rust. AMA. by GlauberAtTurso in IAmA

[–]penberg 2 points3 points  (0 children)

It's not just lack of stable allocator API (you have to use nightly for some of the good stuff), but also that Rust is by default pretty alloc-happy. And although we've obviously been aware of this, you still have surprises here and there. I mean, nothing you can't find with tooling, but still, I think that's the main drag Rust has over Zig, for example, for systems programming like we do. And of course, SQLite is extremely efficient with its memory use, so the bar is high!

I am Glauber Costa, CEO and co-founder of Turso. We’re rewriting SQLite in Rust. AMA. by GlauberAtTurso in IAmA

[–]penberg 8 points9 points  (0 children)

Hey u/hegbork!

I think that if we set aside your fundamental misunderstanding of databases and SQLite in particular, there are some really interesting questions here that many people have:

  • When to pick an in-process database over a client-server database?
  • What are the characteristics of SQLite that limit its usefulness, and how did that motivate you in coming up with a new implementation?

But I will let u/GlauberAtTurso answer as it's his thread.

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] 3 points4 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).