Rust and other llvm languages


#1

hello. I am new at rust. I am actually Matlab,Python,julia,nim(rod),c++qt/qml and embedded system programmer. I used llvm so much. I am wondering can we translate julia script to rust or reverse?
Julia is great language while processing data and uses llvm backend. I think we can use julia inside rust programs without dependencies, otherwise Can you add matrix operation sytax like matlab and julia. It will be great for most of us.
If I said something stupid, I am new at rust :slight_smile:


#2

Probably not.

The surface syntax of Rust does not map 1-to-1 to LLVM, and that’s very much on purpose, because many of Rust’s benefits as a language come from restricting what you can do, particularly where it ensures safety. I assume Julia (and, well, every other programming language) also has some restrictions motivated by safety that make it not a 1-to-1 mapping to LLVM.

Without LLVM as an intermediary, you’ve got to look at the surface semantics of both languages. I don’t know very much about Julia, but it’s a dynamically-typed language, it has not only overloading but multiple dispatch, and it doesn’t appear to make distinctions like value vs reference and stack vs heap that are so critical to a systems language like Rust. And then there’s cross-crate restrictions like Rust’s orphan rules which I don’t even know how you’d get to work if one of the “crates” is secretly transpiled Julia. So it seems extremely unlikely there’s any way to translate either language directly into the other, unless we start talking about highly restrictive subsets of each.

It’s definitely possible for Rust and Julia to talk to each other over FFI (that would be the “highly restrictive subsets”). I’m not sure what you mean by “without dependencies” though.

I don’t see Rust ever adding dedicated syntax for this, since Rust is not specifically focused on numeric computation the way Julia and MATLAB are. But, once some subset of const generics stabilizes, the community can start experimenting with linear algebra libraries and I’m very hopeful that Rust’s macros and operator overloading will allow us to achieve something reasonably ergonomic, even if it’s not quite as smooth as those more specialized languages.


#3

Thank you but think about matrix syntax.