Like Tree31Likes

Let's talk about Rust!

This is a discussion on Let's talk about Rust! within the General Discussions forums, part of the Community Boards category; What you are saying makes no sense. Either you have fewer, but more complex instructions or you have more, but ...

  1. #151
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,606
    What you are saying makes no sense. Either you have fewer, but more complex instructions or you have more, but simpler instructions. You can't have both.
    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.

  2. #152
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,703
    Quote Originally Posted by Elysia View Post
    What you are saying makes no sense. Either you have fewer, but more complex instructions or you have more, but simpler instructions. You can't have both.
    They aren't instructions, he is specifically talking about assembly macros.

    Many assemblers support predefined macros, and others support programmer-defined (and repeatedly re-definable) macros involving sequences of text lines in which variables and constants are embedded. This sequence of text lines may include opcodes or directives. Once a macro has been defined its name may be used in place of a mnemonic. When the assembler processes such a statement, it replaces the statement with the text lines associated with that macro, then processes them as if they existed in the source code file (including, in some assemblers, expansion of any macros existing in the replacement text).

    Note that this definition of "macro" is slightly different from the use of the term in other contexts, like the C programming language. C macros created through the #define directive typically are just one line, or a few lines at most. Assembler macro instructions can be lengthy "programs" by themselves, executed by interpretation by the assembler during assembly.

    Since macros can have 'short' names but expand to several or indeed many lines of code, they can be used to make assembly language programs appear to be far shorter, requiring fewer lines of source code, as with higher level languages. They can also be used to add higher levels of structure to assembly programs, optionally introduce embedded debugging code via parameters and other similar features.
    If you don't know what something is, don't pretend to follow along.

  3. #153
    Registered User
    Join Date
    May 2009
    Posts
    2,577
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  4. #154
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    1,074
    So, I'm currently looking through the Rust wiki and I have some comments/thoughts :

    1. No null pointers is interesting to me though I'm sure other languages already have this

    2. It's performance is expected to be similar to C++ with proper checking which means native versions of C++ are faster and a performant build of Rust would have to be "unsafe"

    3. I like the functional style in the factorial examples and that if-else is an 'expression'

    4. Things are automatically immutable so I don't see how time is saved or this is preferred over using 'const' in C/C++ because I have to declare 'mut' for everything I want changed

    5. println() is no better than printf() and both are less useful in my mind than std::cout which just prints anything without me specifying

    6. Spawning multiple threads is very similar to std::thread + lambdas

    And I have to read more about the pattern matching and recursive data structure examples to understand them.

  5. #155
    Registered User
    Join Date
    Jun 2014
    Posts
    13
    Yeah, once I discovered languages that don't have null I pretty much stopped being impressed by languages that didn't solve this problem. That's why I didn't like Dart: it's not doing enough to really replace JavaScript. It has all the null pointers, all the callback hell, it's just a small improvement that's not worth the investment to learn it.

    Unlike D, Rust doesn't have "unsafe" builds that perform better. But you can write code that is marked trusted and the compiler assumes you know what you're doing. In other words, you either leave safety to yourself or the compiler. You'll have to use the more low level APIs explicitly.

    In regards to const, 80% of all variables are used once and only once. What's the point of marking 80% of your variables const when you can just mark 15% of your variables mut? (The other 5% are never used)

    println! macro is better than printf because it won't compile when you have the wrong amount of arguments, while printf will barf at runtime

  6. #156
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,703
    Not to make a mountain out of a molehill, but:

    I think rust is just different in terms of const. I have heard that every variable is constant until proven otherwise, but in C/C++, most variables are not const because they must have a useful, immutable value when they are defined. Most programs transform input in some way. Why would I want to declare all of my variables with human input or otherwise mut when they most likely always need to be modified at least once? Most of the examples do not show why this design choice is helping anybody.

    if you are compiling such that printf() is not being checked, then you are doing it wrong. You aren't supposed to compile with warnings turned off. That is basic stuff.
    Last edited by whiteflags; 06-23-2014 at 03:18 AM.

  7. #157
    Registered User
    Join Date
    Jun 2014
    Posts
    13
    to the contrary, most variables are something like

    Code:
    ui_inputSpinBox1 = findChild<QSpinBox*>("inputSpinBox1");
    and then later

    Code:
    ui_outputWidget->setText(QString::number(value + ui_inputSpinBox2->value()));
    so you assign something, use it once and you're done
    this is 80% of all variables according to research

  8. #158
    Registered User
    Join Date
    Jun 2005
    Posts
    6,299
    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?
    stahta01 likes this.
    Right 98% of the time, and don't care about the other 3%.

  9. #159
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    1,074
    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.

  10. #160
    Registered User
    Join Date
    May 2009
    Posts
    2,577
    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.
    whiteflags and Mario F. like this.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  11. #161
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,627
    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.
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  12. #162
    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.

  13. #163
    Registered User
    Join Date
    May 2009
    Posts
    2,577
    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.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  14. #164
    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

  15. #165
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    1,074
    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.
    stahta01 likes this.

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21