Live data from Hacker News

Rust Guide

doc.rust-lang.org

111–120 of 147 posts

Re: Rust Guide

#111
post #33
post #4

Earlier quoted context omitted.

If you want more details, less cruft, you probably like to read the Manual: http://doc.rust-lang.org/rust.html The Guide is fine as a tutorial and where does it not teach the basics? So your impression is definitely not mine. "Stop talkting to me informally" is also very subjective. I very much prefer the informal way.

Looking forward to reading "Rationales and design tradeoffs" section. But it's still not written: http://doc.rust-lang.org/rust.html#appendix:-rationales-and-... Is there any place to read about the Rust design?

http://doc.rust-lang.org/master/complement-design-faq.html

Re: Rust Guide

#112
post #7

Please Rust-lang, why, oh why, do you choose to name function 'fn' and module 'mod', dont you expect to read any of the programs you write!? How is anyone supposed to read fn main(). Fun main? Fen main? F of N? Is it related to ln in println? Ive tried rust, but it just doesnt parse well in my mind. More time is spent for me parseing out the bullshit terse keywords than the meaning of the program. Ada gets this right…

Maybe you shouldn't spell out every abbreviation (and acronym) when you read? Otherwise it can be "fun" when you read HN comments about the HTML5 WebGL API and the low FPS CSS animations that eats too much CPU power.

Re: Rust Guide

#113
post #81

Earlier quoted context omitted.

On the other hand, not many languages use lowercase 'i' for complex number literals, in fact I can't think of any right now.

I can't even think of a language that has first class complex numbers, let alone complex number literals.

C?

     #include 
     complex f(complex a, complex b) {
         return a*b + 5*I;
     }

Re: Rust Guide

#114

Earlier quoted context omitted.

fn & mod are fine. no worse than cdr & car. Variable declaration and type annotations in rust are the thing you should be confused/angry/sad about.

Yes! This is what drives me the most crazy about rust: fn foo W>G GGW>>>F F>>A>(bar: AJK S>>>){ ... } Okay, I'm probably being a jackass, but I find Scala's use of [] for nested type annotations to be much easier to parse.

I'm biased, but I'm partial to Myrddin's syntax:

    const foo = {bar: @a, baz : asd(@a,foo(@b, bar(@c,@d),int))
        ...
    }

Re: Rust Guide

#115
post #81

Earlier quoted context omitted.

On the other hand, not many languages use lowercase 'i' for complex number literals, in fact I can't think of any right now.

I can't even think of a language that has first class complex numbers, let alone complex number literals.

Python does.

    >>> 5 + 2j
    (5+2j)
    >>> 2j * 2j
    (-4+0j)

Re: Rust Guide

#118
post #81

Earlier quoted context omitted.

On the other hand, not many languages use lowercase 'i' for complex number literals, in fact I can't think of any right now.

I can't even think of a language that has first class complex numbers, let alone complex number literals.

Go does too. http://play.golang.org/p/ficmYvVehL

Re: Rust Guide

#119
post #31
post #13

Earlier quoted context omitted.

I understood that, but it's an unfortunate suffix.

I agree. Isn't it the default though? Could be implied when you choose to leave it out.

Yes it could be implied if left out. Due to type inference.

`5` would be signed or unsigned if left off. Depends on how you use it.

So you could try.

    use std::num::abs;

    let v = vec!['a', 'b', 'c', 'd'];
    let x = 3;
    let c = v[x];    // v.index (operator overload) constrains x to type uint.

    let y = abs(x);  // error: failed to find an implementation of trait core::num::Signed for uint.
                     // abs can't constain the type to an int because abs can take anything that          
                     // implements  `Signed` (eg BigInt)
                    
If you wanted to make sure that x was signed.

    let v = vec!['a', 'b', 'c', 'd'];
    let x = 3i;
    let y = abs(x);  // Ok as x is signed.
    let c = v[x];    // error: mismatched types: expected `uint` but found `int`
If you really wanted to index to try an index with an int you can use a checked cast.

    let casted = x.to_uint(); // Returns None if x is negative or Some(x) if it's postive.

Also a generic int doesn't have to be int or uint, it can be any integer value: signed: i8, i16, i32, i64 or int. Unsigned: u8, u16, u32, u64 or uint.

Re: Rust Guide

#120
post #89

This language really interests me, but I would like to know some real world applications that are being used for it. While I may enjoy writing it as a hobby, could this be something that I utilized in production as well?

Probably the largest application written in Rust is the Rust compiler itself.
Post reply on HN