Thread: Let's talk about Rust!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Yarin View Post
    When a language aspect is standardized by the platform rather than the language specification itself, that makes it an implementation detail, just as I said.
    No, it doesn't.
    A standard may still mandate what a platform ABI may and may not do.
    Besides, many things such as name mangling can be part of the standard ABI, while lower level things such as calling convention may be part of the platform ABI.
    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. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    C does not have a standard ABI AFAIK. It only happens that due to its simplicity, it often just works.
    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.

  3. #3
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    C supports a standard ABI that is used by multiple Compiler Vendors.
    O_o

    Elysia is correct.

    There is no C standard ABI. Sometimes things will work out because the language is simpler. (You don't, for example, need mangling to account for overloading.) The ABI you are probably familiar with is one of a few common ABI mostly designed by hardware engineers. (A variation of the "Itanium" ABI is very common these days even in x8664 land.) Even then, the ABI you are familiar with only has so much conformance. (On x86, for example, different compilers use different "internal padding" for variables depending on the options. You might, same example, compile with some variation of "use double precision for all mathematics" changing the size of all structures with a `float' member. Depending on other compilers, you'll never be able to directly interface the compiled code because some compilers do not have options for aligning `double' to 96 bits while that is the standard for other compilers.) One you reach beyond default everything, the ABI gets less and less "standard".

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  4. #4
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Besides, many things such as name mangling can be part of the standard ABI, while lower level things such as calling convention may be part of the platform ABI.
    O_o

    If the standard mandated a particular mangling scheme, most vendors would not follow that part of the standard.

    *shrug*

    Face it, you aren't going to see a standard ABI which will be widely adopted for years and years if ever.

    For a vendor, "backwards compatibility" would be more important than rigid adherence to the standard because clients expect a level of compatibility.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by phantomotap View Post
    Face it, you aren't going to see a standard ABI which will be widely adopted for years and years if ever.

    For a vendor, "backwards compatibility" would be more important than rigid adherence to the standard because clients expect a level of compatibility.
    That's why it's important to have in place from day #1 so no legacy code will be able to "get in the way." That gives the highest probability of there ever existing a common ABI.
    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.

  6. #6
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by Elysia View Post
    That's why it's important to have in place from day #1 so no legacy code will be able to "get in the way." That gives the highest probability of there ever existing a common ABI.
    You just don't get it, do you? The 'B' in ABI means 'binary', as in, machine code. It cannot be fully standardized by the language specification without making it unportable (to anything not covered by the spec, obviously).

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I do get it, and I never said it had to be fully specified by the standard.
    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.

  8. #8
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    So... Are we gonna all just ignore the fact that MILL architecture CPUs sounds absolutely astonishingly amazing? It's free performance boosts without code rewrites. I started watching the presentation on branching and I'm really starting to get into this. I mean, forget writing in assembly. Learning assembly in this day and age just seems silly unless you're either getting paid for it or you're getting paid a lot for it.

    The speaker is also a perfect caricature of a computer scientist, imo. And I absolutely loved his joke, "Now, some of you younger folks may not recognize it but this is 'assembly language'."

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    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.

  10. #10
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    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.

  11. #11
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    "...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

  12. #12
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    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.

  13. #13
    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

  14. #14
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    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.

  15. #15
    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

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