1. Long ago, Rust had some interesting built in syntax for different kinds of pointers, and so people checked out Rust then, and didn't realize we got rid of it. This objection has happened less and less since that was ~5 years ago (wow time flies), but sometimes it still comes up.
2. The lifetime syntax uses a single apostrophe, like 'a. We took this syntax from OCaml (though slightly re-purposed), but if you haven't used OCaml, and many have not, it can feel very weird.
3. Not everyone prefers the "curly braces and semicolons" style of systems languages, and so they feel the <>s and ::s and {}s and ;s are noisy. We kept this style to be familiar to systems programmers.
In general, Rust doesn't have a lot of unique syntax, but it does draw from two generally disparate areas: functional languages and systems languages. If you haven't used both before, some of it can feel strange. It happens.
Oh boy do I agree about the noise. I absolutely love Rust, and I definitely don't think it's noisy (in normal examples) but before I first learned Rust generic code feat like syntax soup. It seemed bizarrely messy and convoluted.
Mind you, I love Rust now. This is not a criticism towards Rust. It's simply a reflection on how a non-Rust programmer, largely non-Systems programmer saw Rust's flavor of syntaxes for Generics and Lifetimes.
How time flies. Now I push Rust at work where it makes sense and use it for everything in my personal (code) life.
My favorite part? Likely how it feels imperative while still offering functional features. Iterators, for example, are my favorite thing in the world. This is partially due to system shock I'm sure; the idea of iterators to this old Go programmer feels like magic haha, it was quite the change coming from Go.
What's the alternative? Text-based syntax ala Pascal/Ada is actually noisier than symbol- and short-keyword-based, because you don't ever get to file the "syntax" parts away as you become familiar with them; you have to process them visually every time you read that code. There may be a case for that sort of overly-verbose syntax as a form of literate programming - an introduction meant for users who are as of yet unfamiliar with any given system; but as an everyday practice it's quite painful!
When I first started learning Python I hated the idea of significant whitespace, now I think it is the best thing ever.
I started my journey from QBasic (high-school) to C/C++ (college) to Java to JavaScript and I have to admit that I use Java/JS the most throughout my career so my experience is biased toward my own personal experience.
Had I stuck with C/C++ for 10 years and dabble with Haskell/OCaml at night, I might feel different.
Once I got stuck in Java, I felt very comfortable there.
http://blog.plover.com/prog/Java.html
Money quote: "I enjoyed programming in Java, and being relieved of the responsibility for producing a quality product."
I never believe in connecting programming language with quality product because I see no evidence.
People gravitate to work using languages with characteristics that suit them. Most people coding Java would be less happy with something else, and most people using something else would be less happy obliged to use Java.
Though, I can accept JS and Go (the last one takes a while).
pub fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> {
vec![]
}<> for generics. Point 3.
'a for a lifetime. Point 2.
() , and {} for function syntax. Point 3.
pattern: type for arguments. This is in a few different languages, and doesn't fit into my below points, but the paragraph I made after the point.
& for references, point 3.
-> for the return type of functions. In the paragraph after.
! to indicate that vec! is a macro. This is pretty unique, actually. Ruby does let you use ! in function names, but that's not really the same thing.
[] is used to invoke vec! similarly to how you index anything else, that is, this creates an empty vec, like [] would create an empty array. This is sorta point 3 and the final paragraph.
None of this is to say that you're wrong about this; I think it just really demonstrates how hard it is to please people with syntax. None of this is unique to Rust, but the combination of influences is.
There's no silver bullet just like anything else. It's a matter of preference.
Generics is fine (exist in C++ and Java). Although I dislike crazy generics <T<S>> but that could be design problem.
<'a> (yeah technically it's just the 'a.
"->" non-alphabet, I came from C family (C/C++/Java) so return type stated earlier as part as the whole long-train of ceremonial stuff alongside the modifier (public static int myMethod)
Pointers and Reference: not my cup of tea but I understand it's important for system language. Others can argue its importance for "business apps" (or web-apps) but I never need pointers and references so _shrug_.
semi colon after input parameter:
query: &str
vs
string query
contents: &'a str Vec<&'searching str>
<--- the fact that now you can combine these non-alphabet stuff together => "&'a".
vec![] => exclamation mark squeezed between what appears to be a keyword "vec" and an array syntax
Again, don't get to riled up. I just personally don't enjoy reading syntax like this.
The syntax choices Rust made don't seem any stranger than e.g. Go. Rust just has more concepts because of what it's trying to accomplish.
I'm more in app-development.
Over the years I have just grown repeatedly to love static and typed. The larger my code bases the more it (dynamic features) always seemed to be something that caused me trouble. Typed languages felt bad for prototyping, but as time went on that argument of mine just didn't seem to hold water. I definitely don't feel that way now.
And, while I do like Rust's syntax, and have grown strangely fond to the syntax coined "The Turbofish" ::<>, I just haven't seen a typed language that can do what Rust can with a vastly more simplified syntax (ie, Python). I imagine it's not possible, but I'm not making claims here - just thinking out loud. Of course, Haskell and friends might be near that camp, but arguably even if the language is as powerful I'd they're too different to qualify for my statement.
Anyway, not trying to convince you of anything. Just thinking out loud. Carry on friend :)
This is how I feel when I saw any languages that utilize special characters. It is shorter, I give you that, but that shortness is taxing my brain.
No, I'm not asking for convincing as I mentioned I'm not the target audience of Rust (system programming, OS, etc).
Ironically at college my specialization was System Programming, OS, and Database. Pretty much infra stuff that Rust serves well :). Not sure what happened along the way that changed my mind.
vec![1,2,3] declares a vector of [1,2,3]. But it isn't `keyword` ! `array`, it's more like vec(1,2,3) where vec is a variadic function. But instead of being a function, its a macro so its done at compile time using AST transformations.
Basically, `vec` isn't special, `!` is. `anything!()` or `anything![]` are ways to call macros.
I don't recall the exact transformation, but vec![1,2,3] is basically equal to
let v = Vec::new();
v.push(1);
v.push(2);
v.push(3);
It's not quite equal because it might initialize with Vec::with_capacity(N) where N is the number of args, but you get the point.auto multiply (int x, int y) -> int;
One of the many reasons why I stick with Java.
Those who build data-pipeline, ML, processing big-data, they love constructs that can help them achieve their goal faster.
Those constructs are essentially processing collection type of constructs: predicates(), forEach(), map(), reduce(), transform(), filter(), etc.
Those who writes business-apps tend to favor OOP because they need to map business domains.
PUBLIC FUNCTION Search \
GIVEN REGION Searching \
TAKING Query: SHARED Str, \
Contents: SHARED Str REGION Searching \
GIVING Vector OF SHARED Str REGION Searching IS
TAKE Vector!Empty
END FUNCTION.
It might look like an improvement if you're seeing Rust-like code for the first time ever, but it very much isn't one in the longer run! Even the final version of that function might be somewhat tedious to write and review, to say nothing of something even slightly longer than that! pub fn search<'searching>(query: &str, contents: &'searching str) -> Vec<&'searching str> {
vec![]
}
Give your lifetimes meaningful names.