5 ms·
> Most of them involved abusing the "∗" and "&" symbols, which put you in a territory in which you seem to be dealing with pointer arithmetic again like in low-
by pcwalton 12y ago
> Most of them involved abusing the "∗" and "&" symbols, which put you in a territory in which you seem to be dealing with pointer arithmetic again like in low-level C, something which I thought Rust was trying to escape from.
First off, Rust doesn't have pointer arithmetic.
Moreover, though, Rust is not trying to "escape from" pointers in C and C++; it's a manually memory-managed language, not a garbage-collected one. For Rust's domain (systems programming without automated memory management), learning about pointers is a necessity. What Rust saves you from is making dangerous mistakes with memory management.
> One thing I really liked about D is the string mixins, which could allow for what has become common these days in F#: type generation at compile time (which at the end of the day allow you to, for example, parse XML or JSON with static APIs, hence allowing intellisense/codeCompletion/youNameIt).
Rust has macros and compiler plugins, which allow you to do the same thing.
- knocte 12y ago>First off, Rust doesn't have pointer arithmetic. It should have avoided the "*" and "&" symbols then, IMNSHO. C# does this partially by using the "ref" keyword.
- pcwalton 12y ago> It should have avoided the "∗" and "&" symbols then, IMNSHO. Those operators aren't for pointer arithmetic… > C# does this partially by using the "ref" keyword. But C#'s reference parameters have no corresponding dereference operator, because they aren't first class and are limited to function parameters. As a result, most programs cannot be written without using the garbage collector in C#. In Rust, however, references can appear as first-class values, which makes them much more flexible—enough to supplant a garbage collector when combined with smart pointers—but requires that you annotate where they are created. `&` and `*` are well-known operators for this.
- knocte 12y ago> Those operators aren't for pointer arithmetic… That's the point of my suggestion! One looking at them will think they are pointer arithmetic, which is not pretty for newcomers.
- pcwalton 12y agoThose operators aren't for pointer arithmetic in any language I know of, including Rust, C, C++, or Go. The operators for pointer arithmetic are plus and minus (technically square brackets too in C)--that's why it's called pointer arithmetic.
- sanderjd 12y agoI think you are confusing pointers with pointer arithmetic. There is no reason you must have one to have the other.
- deleted 12y ago[deleted]