Re:SwiftWasm: Run Swift in Browsers
by mlevental on Friday May 10, 2019 @04:39PM
(#19882006)
i use rust too and some of the quality of life features from swift would make rust as good as swift, if not better. ?? rather than unwrap_or, as? and try?, if let, guard let. maybe there are reasons rust didn't incorporate this sugar having to do with the borrow checker i don't know but jeez i feel so burdened with boiler plate when i deal with optionals in rust.
[ Parent
| on HN ]
Rust has if let. It can't chain them yet, but the proposal to fix it (RFC 2497) was accepted and implementation is in progress.
But Rust lacks `guard let x = a else { return }` which is one of the nicest additions of Swift. I know there were attempts to add it to Rust, but somehow the community really doesn't like it because a `let x = match a { Some(a) => a, None => return; }` is too similar. However I feel that guard also expresses the intent.
Re:SwiftWasm: Run Swift in Browsers
by gamegoblin on Friday May 10, 2019 @06:13PM
(#19882758)
I frequently define a `guard!` macro in Rust that does exactly that. Seems clean enough to solve at the macro level -- doesn't necessarily need to be built into the language itself.
Re:SwiftWasm: Run Swift in Browsers
by newacctjhro on Friday May 10, 2019 @07:35PM
(#19883272)
This kind of stuff should be on the stdlib if it's meant to be idiomatic.
Re:SwiftWasm: Run Swift in Browsers
by gamegoblin on Friday May 10, 2019 @07:58PM
(#19883417)
Rust errs on the side of not putting things in the stdlib. Even things like random number generation or regexes are not in stdlib.
The excellent package manager (Cargo) makes this a non-issue.
As a contrary view, I find the boilerplate helps when I revisit a Rust project months later.
Re:SwiftWasm: Run Swift in Browsers
by totalperspectiv on Friday May 10, 2019 @06:13PM
(#19882757)
If you'd like a lower friction yet similar speed / systems language. I'd highly recommend playing around with Nim. It is exceedingly pleasant and easy to use.
sure but honestly how much traction does it have?
Certainly not as much as Swift, but enough to make joining our community[1] fun :)