DevotionGeo

DevotionGeo

What do you dislike about Rust?

For me it’s the semicolon, because I stopped using a semicolon in JavaScript, two other of my favorite languages, Elixir and Go don’t have a delimiter already. Before that I used Ruby (Rails) and that too didn’t have a delimiter.
So having a compulsory delimiter, semicolon in Rust bugs me a lot.

Most Liked

hauleth

hauleth

The difference is that semicolons have meaning in Rust, in contrast to other languages you have mentioned:

fn foo() -> usize { 0 }
fn bar() -> usize { 0; }

Will have behave differently (in fact, one will not compile at all).

My issue with Rust is ? operator which changes flow of the application. TBH I would prefer it to be “coalesce operator”, so instead of:

let foo: Foo = a()?.b()?.c()?;

It would work like:

let foo: Option<Foo> = a()?.b()?.c();
AstonJ

AstonJ

In the interest of balance, I’ve posted:

:nerd_face:

OvermindDL1

OvermindDL1

Remember this, the ‘semicolon’ is the sequence binary operator. Just like + is. See a + b will run a, then run b, then add them together and return the result, and a ; b will run a, then run b, then it returns b’s result (throwing away a’s). This is common in most languages that use semicolons as you need some way to ‘sequence’ operations. Elixir also has ; but it makes newlines pretend to be a ; when you aren’t in an expression body, which does introduce some syntax ambiguities in elixir (and javascript) that you end up hitting when you do enough coding in them.

So in Rust the ; is not a delimiter, its the sequence operator, and you absolutely do not need it when you don’t have a need for sequenced operations, and without it you couldn’t know how to sequence operations otherwise (remember, in Rust any whitespace, whether a space, tab, or newline are all the same thing).

? started out as the macro-by-example try!, and just like the macro it still expands to the code inline. A ‘coalesce’ operator is just map, as is the proper name of such a monad style container. (? is most similar to ‘unwrap’ of a comand but instead of throwing it returns on failure).

The thing is that doing such a coalescing wouldn’t be a replacement for ? at all as ? actually removes the monad (Option/Result for example) and allows you to change the type trivially as the chain progresses. Of course you don’t need to use ? either, it just expands to normal inline code and you can write that code (or even your own macro’s) as you wish.

Also, something like let foo: Option<Foo> = a()?.b()?.c(); is painful as you’d still have to unwrap the option/result and handle the failure case anyway, which is what ? does, hence the above ?. is not only not a replacement for ? but it doesn’t even handle the same case, it’s something entirely different and would still leave the original issue of having to deal with the failing return manually.


For me though, what I’m disliking most about rust currently is the lack of GAT’s. Some other things I’d like but are currently ‘meh’ about in comparison to how overwhelmingly important GAT’s are to me are things like GADT’s or postfix macro’s or such things.

Where Next?

Popular Backend topics Top

New
New
First poster: bot
C++: The Good Parts . Jordan DeLong overviews the past, current and near future “good parts” of C++'s functional side through the colore...
New
AstonJ
Consider this Erlang code: Rectangle = {rectangle, 20, 10}. {rectangle, Width, Height} = Rectangle. &gt; Width. 20 &gt; Height. 10 When...
New
Jsdr3398
I’ve recently become interested in Elixir and all it’s neat perks. And since I’m currently working on a messaging platform; elixir seems ...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
Jsdr3398
I just thought of this. Are there any disadvantages when making your server in Assembly (other than having to learn a bunch of stuff :ro...
New
Exadra37
Finishing my app to take notes on Videos: I am aiming to put it online on my playground by this weekend. Edit: It’s up https://video...
New
mafinar
I’ll be participating. This would be very interesting because I have been having coders block + a lot of distraction this weekend. But l...
New
KnowledgeIsPower
Do you just use plain Terraform alone? Do you use CDK for Terraform or other supporting tools (e.g. Terraform Cloud ) for Terraform?
New

Other popular topics Top

Exadra37
I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
New
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File &gt; New Rule: And select Deny, O...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
sir.laksmana_wenk
I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc. However, I don’t...
New