News for hackers. Stuff that matters.
Re:Announcing Rust 1.7 by steveklabnik on Thursday March 03, 2016 @03:22PM (#11219730)
Someone asked a similar question on /r/rust the other day, here's what I had to say:

Rust is a programming language. It's a general programming language, so it's good for a large variety of things. Different people have different reasons for using Rust. There are three large constituencies, as I see them: systems programmers, functional programmers, and scripting language programmers.

Before I get into details: all generalizations are false ;)

Systems programmers come to Rust because it's able to do the lowest levels of software: operating systems, device drivers, stuff like that. Where it improves on existing systems languages is "safety." The Rust compiler does a lot of compile-time checking to make sure you don't do things wrong. Existing languages force you, as the programmer, to double check your work. We have the compiler double-check your work, and force you to get it right.

Functional programmers see all that static checking, and it feels like home. But a home where they have significant speed gained. Functional languages can be fast, but not always C level fast. Rust is. It's easier to get that level of performance out of Rust.

Scripting language programmers come to Rust for two reasons: the first of which is to write extensions to their language for speed. You can write a Ruby gem in Rust, rather than in C. This is useful because this low-level stuff is not their expertise, and so the extra checks are really nice. Related: we have a lot of the nice tooling that scripting language folks have come to expect from their language. No need to write makefiles, we have Cargo. The second is sort of related, but these checks also mean it's easier to learn low-level stuff, so if they want to expand their universe, Rust is a nice way to do so. We're seeing a lot of people for whom Rust is their first systems language.

I didn't know where to put this one, but Rust focuses on a concept called "zero-cost abstractions." This means that a lot of our features that feel very high level are extremely efficient. You don't write manual for loops, you se iterators. You don't deal with pointers directly, but with references. Structures like Box and Vec do memory management, but you don't need a garbage collector, and you don't need to manually manage it, but you also don't need to explicitly call free().

These are very broad strokes. Lots of other people have other reasons too. But that's some of them.

Re:Announcing Rust 1.7 by merlincorey on Thursday March 03, 2016 @03:30PM (#11219782)
Thank you for your insight. I have but one question.

What does Cargo the rust package management tool have to do with make, the declarative build system? It would seem they are unrelated to an outsider such as myself.

Re:Announcing Rust 1.7 by steveklabnik on Thursday March 03, 2016 @03:34PM (#11219823)
Part of managing packages is how those packages are actually built. For example, let's say that I'm starting a project in C. I'd write some code, and write a makefile to make it easier to build, so that just a 'make' suffices. In Rust, you use Cargo instead of make: "cargo new foo" will give you a Cargo.toml pre-filled, and a src directory to put your code in. "cargo build" will then build your project.

Work goes on, and how I want to use, say, a library for a hashmap of some kind. In my C project, I would probably be adding a git submoule, and then modifying my make files to build the dependency, and configure how to link it in with my code. With Cargo, I add a line to my Cargo.toml, and "extern crate bar" to my source file, and upon the next "cargo build", Cargo will handle the downloading, compiling, and linking of that library, as well as any sub-dependencies it has.

Now, it's also true that make is broadly more general than Cargo, and so in some circumstances, you'll use them together. I have a hobby OS project, for example, and so I have a Makefile which calls nasm to compile the assembly, cargo to compile the Rust, and ld to link the two together. Eventually, I would hope that Cargo can do it all, and I could probably make it work, but it's not inherently bad to use make either. Stuff like operating systems are the only case where I've felt that need; Rust itself is currently built with Make, because it pre-dates Cargo, but we're in the process of cargo-ifying our build as well.

Does that make sense?

Re:Announcing Rust 1.7 by merlincorey on Thursday March 03, 2016 @03:58PM (#11219990)
Yes thank you for the clarification. I have been mostly pleased with the things I've seen and heard from the rust community and I really should dive in.

I am pleased to hear that Cargo, rather than attempting to be a rust-specific make replacement, is a tool that obviates the need for using make or make-like tools by automating the things you would have used it for, only.

Make and Cargo together sounds like just what I wanted to hear, and your hobby OS project sounds like fun.

Finally, I think it's great that Rust will be using Cargo itself soon, but I am curious if the reverse is possible -- if I want to put in the extra effort, can I build my own rust software in make alone WITHOUT Cargo?

Re:Announcing Rust 1.7 by steveklabnik on Thursday March 03, 2016 @04:05PM (#11220029)
You can absolutely use Rust without Cargo, you'd just call `rustc` yourself directly.
Re:Announcing Rust 1.7 by merlincorey on Thursday March 03, 2016 @04:21PM (#11220136)
That's just what I wanted to hear!

Thanks again.

Re:Announcing Rust 1.7 by kibwen on Thursday March 03, 2016 @04:55PM (#11220359)
To elaborate on Steve's comment, Cargo fundamentally operates by calling rustc itself. You can pass the `--verbose` flag to Cargo to see the commands that it generates.
Re:Announcing Rust 1.7 by Manishearth on Thursday March 03, 2016 @09:38PM (#11221699)
A lot of scripting language folks I've talked to like Rust not because it lets them write extensions or whatever, but because static typing is awesome (and their use case works perfectly well with Rust as much as it does Python). In the static typing world, C++ has its own set of problems (namely, having to worry about pointers), and there's not much love for Java amongst some communities. Both Rust and Go provide an interesting new alternative here. Some extra static typing and free speed; sign me up!
Re:Announcing Rust 1.7 by lmm on Friday March 04, 2016 @07:50AM (#11223397)
I feel like for many of those people something like OCaml/Haskell/F#/Scala (which have been around for many years) would be better options. It's very rare to actually need the very last ounce of performance you get by moving to a non-GC language compared to a fast typed GCed language, whereas there is a real cost to having to manage object lifetimes in Rust.
Re:Announcing Rust 1.7 by Manishearth on Friday March 04, 2016 @12:02PM (#11225066)
> there is a real cost to having to manage object lifetimes in Rust.

I disagree. For the most part, you don't have to worry much about lifetimes in Rust once you have programmed in the language for a bit. It's a learning curve, like any other (functional languages have their own learning curve). There are cases now and then when you do have to think about it, but mostly it's either quickly fixing mistakes caught by the compiler (like any other type error, and this reduces as time goes by), or writing the correct code from the get-go.

That doesn't make Rust a better choice than the functional languages, but it certainly doesn't make it worse.

(of course, there are other reasons as to why Haskell/etc might be a better option for these people)

Re:Announcing Rust 1.7 by unfamiliar on Thursday March 03, 2016 @04:09PM (#11220053)
This is a really excellent summary, I think it really says a lot more than the previous summaries I've heard which put a lot of emphasis on the safety bit. That is of course a very important aspect, but I feel like over emphasising it sells Rust short. I'm most excited about it for parts 2 and 3, part 1 is just a bonus.
Re:Announcing Rust 1.7 by steveklabnik on Thursday March 03, 2016 @04:15PM (#11220088)
Thanks. It's easy to get lost in the safety bit, because from a PLT perspective, it's the most interesting. But there's a lot more going on.

Sean Griffin, the current maintainer of ActiveRecord, has been writing an ORM in Rust. He specifically has been saying quite a bit that the safety aspect is almost irrelevant to him, he sees Rust as a "practical Haskell".

It's also true that there's a lot of stuff we have that's _because_ of safety but isn't interesting because of safety. For example, memory safety is at the core of our concurrency story, but the end result is "compile-time errors for concurrency bugs", which is much more interesting than "safety".

TL;DR: marketing is difficult. Messaging is tough.

Re:Announcing Rust 1.7 by BuckRogers on Friday March 04, 2016 @02:50AM (#11222542)
Where do Java, Go and C# programmers fall? Perhaps just more on the order of more complexly implemented and designed scripting languages? Those three make up a good swath but systems, functional and scripting don't so map well to those.
Re:Announcing Rust 1.7 by GolDDranks on Friday March 04, 2016 @03:21AM (#11222636)
Rust excels in writing fast and efficient libraries that are portable and caller-agnostic. Java, C# and Go all have GC-endowed runtimes, so they might fare not as well on that field.

On the other hand, GC allows for faster and easier programming without the need to reason about lifetimes, like you would have to do in non-GC-languages like C and Rust. Java, Go and C# are fast enough to do a lot better than scripting languages, plus they are statically typed and safe.

I think that what Rust provides for user of those languages, has more limited scope: mainly squeezing the last drops of perf, and especially doing some realtime programming.

Edit: One additional pro of Rust is that it managed resources like files and sockets very robustly with its type system, which may help prevent bugs. That's a thing CG won't do for you.

Re:Announcing Rust 1.7 by steveklabnik on Friday March 04, 2016 @10:30AM (#11224344)
Re:Announcing Rust 1.7 by llogiq on Saturday March 05, 2016 @03:33AM (#11228888)
TL;DR: Java is awesome, Rust is awesome, let's code even more awesome stuff!
Re:Announcing Rust 1.7 by Kratisto on Thursday March 03, 2016 @03:50PM (#11219938)
Thank you for the summary!
Re:Announcing Rust 1.7 by steveklabnik on Thursday March 03, 2016 @04:17PM (#11220103)
You're very welcome.