Thread: Let's talk about Rust!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by iopq View Post
    so you assign something, use it once and you're done
    this is 80% of all variables according to research
    I've certainly seen that "according to research" figure quoted in various presentations, but I've never seen a source cited. I also have not found a report or article (refereed or not) which documents the research which produced that conclusion. Do you have a reference?
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  2. #2
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Well, I'm not 80% of all researchers.

    In my coding, there isn't a variable that I don't mutate at one point in time. Or at least, the ratio is severely different. I do have consts but very few of them.

    Okay, I'm not saying Rust is bad. The threading model in Rust is absolutely sublime but that's only because I already think C++11's threading model is sublime and Rust's is incredibly similar.

    But I'm a scientific programmer. How can Rust help me? Is Rust the language I should use? These aren't meant to be hostile questions. I am literally asking, is Rust good for scientific applications? This thread has shown me that it seems best for security-intensive applications but everything I write, I want people to see everything. I also need performance above all else.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by MutantJohn View Post
    Well, I'm not 80% of all researchers.

    In my coding, there isn't a variable that I don't mutate at one point in time. Or at least, the ratio is severely different. I do have consts but very few of them.

    Okay, I'm not saying Rust is bad. The threading model in Rust is absolutely sublime but that's only because I already think C++11's threading model is sublime and Rust's is incredibly similar.

    But I'm a scientific programmer. How can Rust help me? Is Rust the language I should use? These aren't meant to be hostile questions. I am literally asking, is Rust good for scientific applications? This thread has shown me that it seems best for security-intensive applications but everything I write, I want people to see everything. I also need performance above all else.
    This is what I read on the wiki page and it makes more sense than most of the Rust supporters in this thread.
    The goal of Rust is to be a good language for the creation of large client and server programs that run over the Internet.
    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  4. #4
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by stahta01 View Post
    The goal of Rust is to be a good language for the creation of large client and server programs that run over the Internet.
    So is the goal of Google Go and Facebook Hack. It says nothing useful about the language.

  5. #5
    Registered User
    Join Date
    Jun 2014
    Posts
    13
    It's also not the goal according to the developers of the language. The goal is to have a language with the same performance of C++ and better safety than Java while still not having GC. For example, it statically guarantees you have no data races, while Go only detects them heuristically. If anything, web stuff is still half-baked in Rust.

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by iopq View Post
    It's also not the goal according to the developers of the language. The goal is to have a language with the same performance of C++ and better safety than Java while still not having GC. For example, it statically guarantees you have no data races, while Go only detects them heuristically. If anything, web stuff is still half-baked in Rust.
    You do realize web pages are NOT the only thing that uses the internet!

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  7. #7
    Registered User
    Join Date
    Jun 2014
    Posts
    13
    Quote Originally Posted by stahta01 View Post
    You do realize web pages are NOT the only thing that uses the internet!

    Tim S.
    Of course not, but it doesn't have a standard HTTP library yet, just some attempts by community members.

    On another note, Rust compiler is pretty smart:

    Code:
    fn main() {                                                                                                                           
        let compiler_knows_this_is_initialized;                                                                                           
        let mut x = 1u8;                                                                                     
        loop {                                                                                                                            
            if x > std::rand::random() {                                                                                              
                compiler_knows_this_is_initialized = x;                                                     
                break;                                                                                                                    
            }                                                                                                                             
            x += 1;                                                                                         
        }                                                                                                                                 
        println!("{:u}", compiler_knows_this_is_initialized);                                                                             
    }
    it actually realizes that this is a valid program

  8. #8
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Whoa, I'm tripping out. Either I don't know enough about const-ness or you're mutating an immutable variable...

    Or can read-only variables be initialized with a value once and only once? Or does the initialization have to happen at declaration? I always thought it was at declaration.

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by MutantJohn View Post
    Whoa, I'm tripping out. Either I don't know enough about const-ness or you're mutating an immutable variable...

    Or can read-only variables be initialized with a value once and only once? Or does the initialization have to happen at declaration? I always thought it was at declaration.
    Apparently the compiler is smart enough to realize that the variable is going to get initialized once and only once and hence does not barn.
    The same thing can be done using constexpr in C++14 I believe (I didn't try).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Registered User
    Join Date
    Jun 2014
    Posts
    13
    Apparently not. You can write:

    Code:
    let x;
    x = 1;
    print!("{}", x);
    the compiler knows that it wasn't used before it was initialized and it will compile and print 1
    if you write

    Code:
    let x;
    print!("{}", x);
    x = 1;
    the compiler will barf at you

    Code:
    const.rs:3:18: 3:19 error: use of possibly uninitialized variable: `x`
    const.rs:3     print!("{}", x);
                                ^
    note: in expansion of format_args!
    <std macros>:2:23: 2:75 note: expansion site
    <std macros>:1:1: 3:2 note: in expansion of print!
    const.rs:3:5: 3:21 note: expansion site
    error: aborting due to previous error

  11. #11
    Registered User
    Join Date
    Jun 2014
    Posts
    13
    this can be done because Rust has a loop() so it knows you can only escape via break

    Java does the same thing in case of for(;;) and while(true) but not in other cases like while(1 == 1) so it's a little bit embarassing that while(true) and while(1 == 1) don't work the same way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Do I talk too much?
    By GoodStuff in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 05-20-2003, 10:45 PM
  2. Who wants to talk on AIM?
    By Death Wish in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 07-05-2002, 06:29 AM