Live data from Hacker News

A taste of Rust

lwn.net

11–20 of 93 posts

Re: A taste of Rust

#12
post #8
post #2

I'm a big fan of rust (hence my username), and would like to know if there have been any non-trivial benchmarks of Rust's compilation time, and the performance of compiled executable. Last I checked Rust took about 40 minutes to compile itself on my laptop. Is it still the case? (I haven't touched Rust for a month or so.) Also, is anyone using Rust in non-toy projects? (Except Mozilla's own servo.)

> Also, is anyone using Rust in non-toy projects? Since it's not production ready yet: no

You should double-check what kind of projects are being worked on before saying that it isn't being used for non-toy projects :) I can list at least two off the top of my head:

Q^3, which can render Quake 3 maps and will eventually be its own game: https://github.com/Jeaye/q3

Servo, an experimental web browser being written by Mozilla: https://github.com/mozilla/servo

Re: A taste of Rust

#13
post #8

Earlier quoted context omitted.

> Also, is anyone using Rust in non-toy projects? Since it's not production ready yet: no

You should double-check what kind of projects are being worked on before saying that it isn't being used for non-toy projects :) I can list at least two off the top of my head: Q^3, which can render Quake 3 maps and will eventually be its own game: https://github.com/Jeaye/q3 Servo, an experimental web browser being written by Mozilla: https://github.com/mozilla/servo

For me, a non-toy project is a project that runs in production, where I can build my business on.

Re: A taste of Rust

#14
post #11

I know there are various pointer type prefixes in Rust (@foo, ~foo, &foo, *foo), 'foo for lifetimes and $foo for macro arguments, but WTH is +foo? https://github.com/mozilla/rust/blob/master/src/librustc/mid... I haven't seen this in the documentation.

+foo is an old deprecated feature called a mode that is finally just about to be removed. Because the compiler is written in rust, it can take some time for deprecated things to be fully removed from the language.

Modes were supposed to give hints to the compiler whether or not to implicitly copy or move a value into a function, but it was buggy and confusing. So we replaced it with always moving for unique types, and always copying for reference counted types.

Re: A taste of Rust

#15
post #11

I know there are various pointer type prefixes in Rust (@foo, ~foo, &foo, *foo), 'foo for lifetimes and $foo for macro arguments, but WTH is +foo? https://github.com/mozilla/rust/blob/master/src/librustc/mid... I haven't seen this in the documentation.

A very old, very very deprecated feature. I believe pcwalton's working on removing the last vestiges of it from the compiler as we speak. The feature was called "argument modes", but it's been deprecated for so long that almost nobody remembers precisely how they were used (very few understood it in the first place). They were quite pervasive in the early 0.0 days, and it's taken this long to remove them completely.

In addition to the +foo forms, there were also others: -foo, &&foo, ++foo, perhaps more. Be glad that they're gone. :)

Re: A taste of Rust

#16
post #11

I know there are various pointer type prefixes in Rust (@foo, ~foo, &foo, *foo), 'foo for lifetimes and $foo for macro arguments, but WTH is +foo? https://github.com/mozilla/rust/blob/master/src/librustc/mid... I haven't seen this in the documentation.

They're called "modes" and were a way of controlling whether parameters were copied or passed by reference etc (I think). It's been deprecated for a while and there's an (ongoing) effort to remove them from the code base, e.g. the example you give has been removed already: https://github.com/mozilla/rust/blob/incoming/src/librustc/m... (along with most of the modes from the whole source tree, a big patch landed just a few days ago).

(Also, the master branch is not the one to be looking at for the latest changes at the moment: patches are merged into 'incoming', and master hasn't been updated for more than a month.)

Re: A taste of Rust

#17

The article doesn't specify what exactly, is permitted by an unsafe vs. safe function. The Rust reference indicates the additional operations permitted by unsafe functions are: 1. Dereferencing a raw pointer. 2. Casting a raw pointer to a safe pointer type. 3. Calling an unsafe function. I was expecting something more along the lines of Safe Haskell ( http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/safe-... )…

Indeed, there's been some discussion regarding forcing users to specify what sort of unsafety they desire when using unsafe blocks. There's no syntax whatsoever yet, but consider something like the following:

  unsafe(no-bounds-checks) {
      ...
  }
or:

  unsafe(raw-pointers) {
      ...
  }
Right now the problem is that once you drop into an unsafe block, everything that is unsafe becomes allowed. Obviously this is bad for correctness and bad for readability.

Re: A taste of Rust

#18
post #10

It might be childish but I just can't force myself to swallow the ugly curly braces and semicolons. Some compromises had to be made, e.g. the lack of tailcalls is a regrettable but nonetheless well justified decision. But why didn't they include a standard indentation style in the language specification itself and get rid of the cruft? They have one for Servo anyway, which is the raison d'etre of the whole language,…

Python indentantion-as-block definition has many drawbacks, not to mention the lack of semicolons that forces \

you \

to \

write \

so \

many \

backslashes.

They are not the ultimate solution for block definition and line breaking. You must be very used to them, and that's why you find the lack of it irritating, but that's another story.

Disclaimer: I code python every day of my life nowadays, I'm not a python hater.

Re: A taste of Rust

#19
post #10

It might be childish but I just can't force myself to swallow the ugly curly braces and semicolons. Some compromises had to be made, e.g. the lack of tailcalls is a regrettable but nonetheless well justified decision. But why didn't they include a standard indentation style in the language specification itself and get rid of the cruft? They have one for Servo anyway, which is the raison d'etre of the whole language,…

The standard indentation style is four spaces. Rust does have a pretty-printer (think gofmt), but it's not very good right now so it never actually gets used. It's very old and basically needs to be entirely rewritten.

Re: A taste of Rust

#20
post #13

Earlier quoted context omitted.

You should double-check what kind of projects are being worked on before saying that it isn't being used for non-toy projects :) I can list at least two off the top of my head: Q^3, which can render Quake 3 maps and will eventually be its own game: https://github.com/Jeaye/q3 Servo, an experimental web browser being written by Mozilla: https://github.com/mozilla/servo

For me, a non-toy project is a project that runs in production, where I can build my business on.

I love rust, but we have not yet finalized the syntax and the semantics yet, so it'd be risky to write mission critical things in it. Our plan is to hit 1.0 by the end of the year.

That said, rust has been written in rust, and every commit is tested against our test suite on Linux, OS X, BSD, and Windows. So while the language itself may be changing, any code you write in it at a given point in time should work. It'll just take some (small) effort to keep that code in sync with the compiler.

So if you are able to handle that risk, we'd love to have you try it out. It'd really help us find the warts in the language/stdlib before we lock in 1.0.

Post reply on HN