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.

Popular Backend topics Top

PragmaticBookshelf
Real-time applications come with real challenges—persistent connections, multi-server deployment, and strict performance requirements are...
New
PragmaticBookshelf
TDD is a modern programming practice that all C developers need to know. It’s a different way to program—unit tests are written in a tigh...
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
PragmaticBookshelf
It's easier to learn how to program a computer than it has ever been before. Now everyone can learn to write programs for themselves—no p...
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
GermaVinsmoke
Reading Programming Elixir 1.6 book, I’ve completed part 1 of the book. Now I’m thinking of reading Elixir in Action. What do you all sug...
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
New
PragmaticBookshelf
Build fast, scalable PostgreSQL and Rails apps. Solve data growth, quality, and reliability challenges, for workloads from consumer Inter...
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New

Other popular topics Top

malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
PragmaticBookshelf
A PragProg Hero’s Journey with Brian P. Hogan @bphogan Have you ever worried that your only legacy will be in the form of legacy...
New
siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
New
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
AstonJ
Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face: https://on...
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
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
DevotionGeo
I have always used antique keyboards like Cherry MX 1800 or Cherry MX 8100 and almost always have modified the switches in some way, like...
New