REPL, RAII, Static Types

Is there any language that supports:

REPL, RAII, and Static Types ?

If we drop RAII, we get: OCaml, ... ?
If we drop REPL, we get: C++, Rust, ...

I'm in this situation where I want RAII for nice object cleanup / destructors, but am also really missing the interactivity of a REPL instead of waiting for cargo to finish compiling.

Is there any language that has all 3 of the above?

Just out of curiosity, do you know about / did you try evcxr? It claims to provide a REPL-ish experience for Rust in the form of Jupyter notebooks.

EDIT: Another project in this space which I just found out about in a quick web search is papyrus.

EDIT: Yet another from a "repl" search in crates.io is irust.

3 Likes

I have heard about evcxr and saw papyrus on news.yc. irust is news to me.

I have not tried them. From a superficial look, they seem more in-progress than "production ready" (but I may be wrong about this.)

There's this additional constraint (not mentioned in original question) that I need this to work in wasm32 -- so solutions involving calling cargo/rustc per line and loading a *.so dynamically are unlikely to work.

I'm really surprised I can't find a language with REPL + RAII + Static Types. Having such a language, even if it lacked traits / borrow checker, as a scripting language for Rust would be really useful for wasm32 applications. (Part of it being that the RAII in the "scripting language" can in turn trigger the RAII in Rust -- something that's not obvious how to do with rust-wasm32/JS bindings.)

I’ve never used it, nor do I know if it’s any good, but Swift appears to have a REPL. (Also I have no idea what the wasm story is for swift.)

I’m personally not that surprised you’re having trouble finding such things. With dynamic/interpreted languages involving heavy (or any at all) runtime/gc you almost get a REPL for free. It seems like one would have to go quite far out of your way to build a REPL for a compiled “systems” programming language.

I wonder if something like Miri would be a good base for a rust REPL that didn’t make use of dynamically loaded shared lib hacks?

2 Likes

@murarth : I like how https://github.com/murarth/ketos is already a Lisp on Rust and already has Ketos/Rust interop setup.

I'm thinking about ripping out the GC, replacing it with RefCount, and pushing Ketos towards something like https://github.com/carp-lang/Carp

Any advice? :slight_smile:

1 Like

@uberjay : Thanks! Swift is a really interesting choice.

No advice, but that sounds like it would be pretty nifty to have. :wink:

Actually, it might be easier to just rewrite Carp in Rust. IT's only ~10k lines of Haskell. If only someone has a Haskell2Rust :slight_smile:

1 Like

You could try this:

2 Likes

This is insane. I meant it as a joke given the Laziness / WHNF / GC aspects of Haskell. I don't see how this can possibly work -- is there also a "mini haskell runtime" written in Rust?

1 Like

I have no idea. I just have a habit of searching for things I need on GitHub. :slight_smile:

2 Likes

I'm apologizing for the necro-post, but since I haven't seen it mentioned yet: the people at CERN have developed a REPL for C++ based on LLVM.

2 Likes