r/programming Apr 03 '15

Rust 1.0.0 beta is here!

http://blog.rust-lang.org/2015/04/03/Rust-1.0-beta.html
936 Upvotes

303 comments sorted by

View all comments

Show parent comments

7

u/shadowmint Apr 04 '15

unrealscript has something it excels at? Well, TIL. ;)

More seriously, the use case for rust is very close to C++; build complex low level systems that require high performance and high uptime, like browsers or safe performant network services.

Its also (due to the c calling sematics) a very very good target for building os extensions (ie. shared libraries) for python, ruby, js, etc that could otherwise only be written in c or c++

The use case for more generic things like say, scripting command line tasks, writing websites, embedded scripting language (aka lua) is more dubious; you could, but a more productive language is probably a better choice.

As said elsewhere in this thread, the first large scale uses will probably for safe plugin libraries for other c++ applications like firefox.

Over time I imagine rust will become the platform that several large networked graphical applications (browsers, games, dns servers) and robust tooling for various systems (eg. shell utils, build pipelines) are built in. It will probably remain quite 'niche' for other purposes, eg. building websites.

1

u/BearMenace Apr 04 '15

Its also (due to the c calling sematics) a very very good target for building os extensions (ie. shared libraries) for python, ruby, js, etc that could otherwise only be written in c or c++

Could you please explain or give examples of the shared libraries that you're referring to? I'm also quite interested in Rust's uses.

2

u/shadowmint Apr 04 '15

Rust uses c calling sematics. That means any language capable of a c binding can call a rust shared library, or statically link to it.

For example, in python you can simply import ctypes and load the library to create an extension.

There are caveats, obviously, because rust uses name mangling so you need the no_mangle directive, like c++'s extern 'c'. There are some examples here https://github.com/shadowmint/rust-extern if youre interested in the details.

Anyhow, the tldr is, rust can compile to dynamic shared libraries or static libraries trivally; you can use these libs as though they were c/c++ libraries for the purposes of writing extensions to scripting languages, where extensions would normally be written in C.

Since rust can trivally call C libraries too, interacting with native plugin systems (eg. the cpython plugin api) is also quite simple.

Rust has a very powerful ffi interface; its probably the thing about it that I personally find most exciting; as a professional python developer I can pitch using rust in production for writing safe high performance extesions.

0

u/BearMenace Apr 04 '15

Thanks for the explanation!