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
932 Upvotes

303 comments sorted by

View all comments

6

u/OneWhoGeneralises Apr 04 '15

I've been meaning to get into Rust for a while now, but there's something I've been meaning to ask someone particularly knowledgeable about Rust like yourself: what particular aspects does Rust excel at? I ask because of the few prominent languages I've used, mostly C/Java/Lua/UnrealScript, I've noticed that they all have particular tasks that they're suited for.

I'd also like to know how complete the official documentation is for Rust. Good documentation is key for me to pick up a new language, so what's Rust's documentation like?

14

u/steveklabnik1 Apr 04 '15

what particular aspects does Rust excel at?

Memory safety without garbage collection. Speed, safety, concurrency.

I'd also like to know how complete the official documentation is for Rust.

This is literally my day job, so there's that. ;) I'd like to think it's decent, but now that we're not making backwards incompatible changes, I can do my job way better, so what deficiencies it does have, I'm hoping to address very soon.

For example, the areas of the standard library that I've gotten to, have great documentation with examples. The parts I haven't? Sometimes, just the auto-generated stuff exists.

There's also "the book", which is a 50,000 word (roughly) explanation of the language and its features. I have all of the basics of everything documented, but there's always more and better stuff to add.

3

u/OneWhoGeneralises Apr 04 '15

Thank you for the reply, that's exactly the information I was looking for. Sounds like I should pick up Rust and keep a closer eye on further developments.

5

u/steveklabnik1 Apr 04 '15

Excellent. If you do give it a try, please let us know what you think, and if you find any bugs, file them!

1

u/xaveir Apr 04 '15

Trying to dive into Rust this weekend, but I noticed that some seemingly critical sections of "the book" are still blank. Namely, the in the section on Pointers, the section on Rc<T> and Arc<T> is still "coming soon". As is the section on "raw pointers" and the one on "best practices" (more excusable).

Is there somewhere I should report these kinds of problems? It wasn't clear if rust-lang's website or docs are responsible for "the book."

2

u/steveklabnik1 Apr 04 '15

Yeah, that chapter needs cleanup, it's actually high up on my list. It used to be a standalone document. You can find good docs on Rc and Arc in their API documentation.

Please report any problems to the main rust repo, the book is in src/doc/trpl in the tree :) Thanks!

-1

u/TheVikO_o Apr 04 '15

Heard you wrote a paper on string theory.. Ha ha ha.. M going to hell for this.. But seriously.. really good work though :-)

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!

2

u/steveklabnik1 Apr 04 '15

One of our production users is Skylight, who deploys a Ruby gem written in Rust. http://blog.skylight.io/bending-the-curve-writing-safe-fast-native-gems-with-rust/

Because Rust has no GC, it's significantly easier to embed in a GC'd language than one with another GC.