6 ms·
> Apart from the Rust's usual rule to invent some abbreviations, but only apply them half the time. Do you have an example? > Then "types start with an upper
by pcwalton 12y ago
>
Apart from the Rust's usual rule to invent some abbreviations, but only apply them half the time.
Do you have an example?
> Then "types start with an uppercase letter" except when the language creators break their own rule.
They always start with a capital letter, except for built-in types or FFI bindings to libraries such as libc where the original types used a lowercase letter. This convention is exactly the same as Java.
> Then the fun "sometimes we use () and sometimes we use [] to do practically the same thing".
I've never heard this before. Do you have an example? () is used for function calls, grouping, and tuples, while [] is used for array literals and array indexing.
> Then the various insanities with ::.
The double-colon is very useful so that you can tell the difference between module lookup and field projection/method calling. Early Rust used . for module lookup, and it was confusing to tell at a glance whether a function was being called or a method was being invoked.
> Then Generics. How many examples of languages which tried to use <> for Generics do we actually need before people learn the lesson?
Using square brackets like Scala wouldn't actually help with the ambiguity, because it would be ambiguous with array indexing. The only syntax I've seen that actually solves the ambiguity is D's `!()`, which was deemed too unfamiliar. Angle brackets were chosen because they are familiar and aren't really any worse than the other mainstream options.
> I really wished some people took Rust, and wrote a new frontend to get rid of all the pointless inconsistencies and other "C did, so it has to be good"-isms (like_all_this_underscore_stuff or the ridiculous abbreviations)
The underscore naming convention was actually taken from Python's PEP 8. Rust doesn't really have any more abbreviations than most other languages at this point.
- callahad 12y ago> > Then the fun "sometimes we use () and sometimes we use [] to do practically the same thing". > I've never heard this before. Do you have an example? () is used for function calls, grouping, and tuples, while [] is used for array literals and array indexing. Maybe referring to the ability to use either type of brace with macros?
- pcwalton 12y agoYeah, you can use any type of delimiter with macros, but I think that's an important feature, especially since macros can expand to declarations. Early versions of Rust required parentheses for all macro invocations, and that looked really ugly for anything that looked like a block. Delimiter interchangeability is a feature from Racket that works really well when it comes to macros and I'd hate to give it up.
- blaenk 12y agoAgreed. They allow you to naturally create vectors with the bracket delimiter `vec![1, 2, 3]`, create spawn-like macros with the brace delimiter `spawn { code }`, and in the normal case just use parentheses `println!("testing")`
- frowaway001 12y agoConsidering the glorious downvoting, I won't bother comment any further except saying that these "issues" Rust devs keep pointing out have been addressed. And now, I won't waste any further time with this cult.
- Daishiman 12y agoIt's so sad, because I yet to see a single place where they're addressed.
- frowaway001 12y agoYes, but getting 8 downvotes in two comments ... why should I care?
- Ygg2 12y agoWho cares about downvotes? It's just arbitrary points.
- frowaway001 12y agoIt says a lot about Rust's culture. If they are not only _not_ interested, but actively hostile towards input, why should I bother? Just look at the replies. Sure, it's possible to hand-wave issues away by setting the standards low enough with "Java did that mistake, too", "we just copied that from Python", "this looked more familiar" ... I think no one disagreed with that. It's 2015, and having marketing along the lines of "we only made half of C++' mistakes" just doesn't cut it for me anymore. For other people it might be good enough, but I'm worried that Rust won't get enough traction if the language is not drastically better on average than its incumbents, but just messy in different ways.
- Ygg2 12y agoFirst off, Rust != Hacker News. You might have been downvoted by someone unaffiliated by Rust on HN. For example I'm affiliated with Rust community but didn't down-vote you. Second, let's review your post: You never supplied examples to your comment of using some abbreviation only half of the time. Your point about Rust using [], () and {} for functions is wrong, because it only ever uses () for function calls, others can appear in macro. Your example of using <> vs [] is a subjective choice, that doesn't have any scientific or even majority consensus. To make matters worse, one of Rust's side goal is to somewhat ease migration of C++ programmers to Rust. I actually agree with you on this point, but I realize most people would find this syntax confusing due to habit of writing array literals using brackets. On the other hand underscore python style that is proven by a study[1] to be a better choice for readability you consider the less usable one. [1] http://www.researchgate.net/profile/Bonita_Sharif/publication/224159770_An_Eye_Tracking_Study_on_camelCase_and_under_score_Identifier_Styles/links/00b49534cc03bab22b000000.pdf http://www.researchgate.net/profile/Bonita_Sharif/publicatio... Could you improve your post with examples and scientific studies demonstrating your points and post it to http://internals.rust-lang.org/ http://internals.rust-lang.org/ or http://users.rust-lang.org/ http://users.rust-lang.org/ ?
- alricb 12y agoWhat about '{}'? It's a nice pair of opening/closing characters.
- NotableAlamode 12y ago> () is used for function calls, grouping, and tuples, while [] is used for array literals and array indexing. Array indexing is a function call, because an array is a function from its index set to the set of the values the array stores, or -- equivalent -- a partial function from integers to the value set. Scala gets this right.
- sixbrx 12y ago> Scala gets this right. I don't know, I never liked how all FunctionNs are sort of "unofficial" partial functions (because they may throw), and PartialFunctions are then made a subtype of FunctionN, because they have an extra method where you can ask whether they are defined at given points. Especially since throwing seems to be falling out of favor in Scala, being replaced by Try[] return types.
- NotableAlamode 12y agoThis is an orthogonal issue. Arrays are clearly partial functions. The Try[.]-vs-exceptions issue is to do with the question whether failures should be reflected in types (the Try[.]-option) or not (exceptions). There are good arguments for and against both options, but both options go well with the understanding that arrays are functions and indexing is function application.
- sixbrx 12y agoI don't think anything's much orthogonal to partiality of functions in languages with strong type systems, unfortunately :) You wrote that array indexing is "a partial function from integers to the value set". If we're to take the suggestion seriously, then the practicality of it depends on how partial functions are represented in the language. Which itself is certainly not orthogonal to the Try-vs-exceptions issue.
- NotableAlamode 12y agoI'm not sure I can agree. I didn't say that the type of the array function is independent of the choice of error propagation mechanism. If you think an array is a partial function from integers to some value domain, say A, then in the exceptional POV the array type is int -> A, and in the Try[.] POV the array type is int -> Try [ A ]. I was talking about the mechanism for array indexing. In both cases, indexing is function application. So the choice of error representation is orthogonal. This is even more evidence that we should not use a different operator for array indexing as Rust does alas.