On 11/19/2013 05:17 AM, Patrick Walton wrote:
On 11/18/13 7:41 PM, Kevin Ballard wrote:
Is that really why, or are you just guessing? I'm assuming the real
reason is that people are used to languages where heap allocation is
common and stack allocation rare or nonexistant, and don't understand
why boxing everything is a bad idea. In other words, it's a problem that
a proper tutorial should be able to help with. I don't think changing
syntax is going to make much of a difference.
I've observed a lot of beginning Rust programmers treat the language as "add
sigils until it works". (I have specific examples but don't want to name people
here; however, feel free to contact me privately if you're curious.) They end up
with slow programs and frustrated with Rust, wondering why they had to fight the
compiler if they seemingly didn't gain any performance from it.
I think a fair amount of it is that the sigils don't visually convey enough
information to the programmer; they feel like something that you just have to
add to make the compiler happy. A sigil in Rust's expression grammar as it
stands represents an *action*, not a *qualifier* as it does in most other
languages (e.g. `$foo` in PHP). Moreover, the `~` expression maps to one of the
most expensive machine operations in the entire language semantics! It's thus
important in my view to emphasize to newcomers that `~` *means* something; it is
not just a qualifier you have to add to make the compiler happy. Indeed, if you
are adding it just to make the compiler accept your code, there's something
wrong--either the API you're using is inefficient or you're confused about the
semantics!
I share this line of reasoning. However, why not take the opporunity to find a
proper term (or abbreviation)? "New" says nothing about the "action" or its
cost. Semantically, every expression yields a "new" value, doesn't it?
(My take as of now would be "mem", as a shortcut for "reserve some memory on the
heap, where the following piece of data is to be stored; but I don't find it
great myself. "Alloc" or "store" would be pretty good, but maybe too long.)
Some may think this is just bikeshed; I don't share this view: instead,
terminology is extremely important, it is what conveys semantics, or should;
ditto for "key signs". And key terms & signs remain until the end of eternity ;-).
Denis
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev