by antocv · 12y ago · 0 comments
How is anyone supposed to read fn main(). Fun main? Fen main? F of N? Is it related to ln in println?
Ive tried rust, but it just doesnt parse well in my mind. More time is spent for me parseing out the bullshit terse keywords than the meaning of the program.
Ada gets this right, there you have to write exactly what you mean, end begin, if then. Simple clear.
Terseness, shorts and abbrevations, thts now hw you wrt anyng.
I know it's trendy to remove all non alnum characters and make everything super verbose but there's a compromise to make here. Because some languages went overboard with symbol soup doesn't mean all symbols/abbreviations are bad.
This is the kind of reacting any newcomer to a language makes. You start with lisp? "omg all those parens!" You start with python? "omg significant whitespace!" You start with C? "OMG all those semicolon at the end of lines!" You start with perl? "OMG!" You start with APL? "O|▼".
Also I think making basic language constructs overly verbose doesn't help legibility because it drowns the actually interesting bits in a lot of boilerplate. VHDL comes to mind, but it's probably not what you were talking about...
as box break continue crate else enum extern false fn for if impl in let loop match mod mut priv proc pub ref return self static struct super true trait type unsafe use whilefwiw, continue and return used to be cont and ret, match used to be alt, crate used to be not a keyword iirc.
It's historical. Rust's keywords used to be far more short on average - I think the rule was no more than 5 characters.
fun would have been better: - ML heritage for named functions (fn was anon) - muscle memory with the leading part of javascript function - the other abbreviations take the leading part of the word
fn calculate() does not lead my brain/mind to discover everything there is it already knows that is function and what it means in this specific context, but instead if I read it as fun it takes me to fun times calculating tip at college with friends.
mod means modification. Modulus. Or module. Why oh why, cant they just write freaking word module?!
Thats what programming is about - kill assumptions, define stuff, and Rust is flowing with assumptions and tersness.
Ada is what I am talking about - a very fine verbose language. Even Java is better than rust.
I think if Mozilla designed Java, it would look like this
pub cls Dfne {
priv stat fin Str hey;
}
In Rust, the function keyword is written 'fn', there're no assumptions or ambiguity there. You just have to learn "in Rust fn means function". It's as capricious as any other keyword, including function.
As a non-native English speaker I find this amusing because for me it's very clear that keywords are magic incantations for the compiler or interpreter, they aren't meant to explain anything. You just learn how to use those keywords and deal with it. For me, it's not clearer to write function instead of fn because in my native language you write it 'función'.
In my experience, it's not rare for Spanish-speaking programmers to ommit the t in function as it is the clearest and most natural way for them to write it. Then, when the program doesn't work, they have to add the missing ts. I feel fn is an improvement with regards to this, as it's not so English-centered. Let's stop pretending that programming a computer is a mixture of Logic, Math and English.
The most powerful metaphor I use when I explain to newer developers how to write clear code is simply "tell a story." Of course you're telling a very constrained story, and some parts need a little comment to explain them, but I strongly believe that even if you're using english keywords, you should be telling a story in the development team's native language if possible. Not everything is a binary choice, even in computing. ;)
I humorously read it in my head as "fuckin' main".
Instead of, what, cryptic symbols to decipher?
You dont read symbols?
Also, what's the problem with pronouncing 'fn' as 'ef-en'?
Thank you.
Somewhere, a transliteration vim plugin is struggling to escape. Based on user preferences it will display:
def Σ():
print("LOL WUT?")
Σ()
-or- define sum():
print("LOL WUT?")
sum()
-or- Ξ Σ
⍋("LOL WUT?")
Σ
-or even- IDENTIFICATION DIVISION.
PROGRAM-ID. Abomination.
PROCEDURE DIVISION.
DisplaySummary.
DISPLAY "LOL WUT".
STOP RUN.But python at least doesnt have the goal it seems to make abbrevations and allow misconceptions about what the language is saying.
Why not use brk, cont as well? Somethings are abbreviated, some things are not.
Variable declaration and type annotations in rust are the thing you should be confused/angry/sad about.
cdr and car requires me to know 60-year-old implementation details of Lisp.
Also i'd much rather live without type inference, so I guess rust gives me that option. I'm just too neurotic (low level networking code/parsers/etc) to not specify types.
let mut monster_size: int = 50;
I'd really really just like the type to be first. let mut int monster_size = 50;
But wait, there are yet more options: let monster_size = 50i32;
Boxes are just plain confusing on first sight. They make pointers look like a lucid breath of fresh air. let owned = box 10i;
let borrowed = &20i;
let sum = *owned + *borrowed;
I find options in a language quite distressing (see also perl). I'm also not sold on the mut keyword and i'm likely to become confused when one gets to complex types.Don't get me started on the automatic dereferencing. That's seriously confusing.
Is there a rule of thumb for when I am meant to use which of these? can i use the type annotation anywhere i use a number as a literal?
Raw string literals:
> They are written as r##"blah"##, with a matching number of zero or more # before the opening and after the closing quote
Why? Why the optional number of #'s?Syntax extensions? !
Why is print a syntax extension? why isn't it in the library? if it is a macro why are we running around putting ! at the end of them... why does it matter? Why do that?
I prob don't know what I'm talking about but that's my initial impression from last week
Why? Why the optional number of #'s?
Code generation. You can nest raw literals within raw literals. Boxes are just plain confusing on first sight.
They are special way to allocate values. They are verbose so that programmers won't use them as often. Think of them as a speed bump.Boxes and lifetimes get a bit used to, but comparing Perl and Rust is, I feel, quite unfair. Rust's syntax is much smaller than Perl's, and from what I've seen the team has taken pains to make it smaller and more regular.
As for println!, it's a macro which gives you compile-time checks on your format string (same as OCaml), which is very nice.
print is a macro so it can be strongly typed and checked by the compiler. As far as I know, "!" is just a convention to make macros obvious -- it seems unnecessary to me, too.
Putting the type of a variable at the end is common in new C-likes. Go does it too. In the case of Rust, I'm pretty sure it's inherited from ML. It avoids a lot of the problems and complexities caused by C's type keywords (see: typedefs of pointers to functions; const pointers to values and pointers to const values; etc.).
fn foo<<W<>W>G<>GGW>>>F<<D>F>>A>(bar: AJK<<<DUoSJK><<>S>>>){
...
}
Okay, I'm probably being a jackass, but I find Scala's use of [] for nested type annotations to be much easier to parse. from_str::<Option<uint>>
vs from_str::‹Opton‹uint››
Hmm. Those are a little lightweight, are actually angle quotes, not angle brackets. Actual angle brackets aren't available on my keyboard, but would look like: from_str::⟨Option⟨uint⟩⟩
Jeez, why does Unicode have so many different variations on angle brackets? The above are "mathematical left/right angle bracket", but there's also: from_str::〈Option〈uint〉〉
Which uses "left/right-pointing angle bracket" and: from_str::〈Option〈uint〉〉
Which uses "left/right angle bracket"At least in the font I'm typing this in, the "left/right-pointing angle brackets" look the best to me. It would be really nice if now that Unicode is ubiquitous, we could standardize on keyboard layouts that get you access to more punctuation like this, so that people didn't have to keep fighting over a fairly limited amount of punctuation to use as technical notation in programming languages.
const foo = {bar: @a, baz : asd(@a,foo(@b, bar(@c,@d),int))
...
}