
Rust 2019: Tame Complexity through Community Involvement Tools - lwhsiao
https://internals.rust-lang.org/t/rust-2019-address-the-big-problem/9109
======
scaleout1
Recently started introducing Rust in my team and here are my notes on some of
the issues we have run into so far. We are primarily a Scala/JVM shop with a
little bit of Python.

\- `Error Handling` is a bit of a dumpster fire right now. Rust has something
called a `Result` enum which is similar to `Either[Error,T]` monad in Scala
however every single Rust crate I have used so far its creating its own
`Error` enum which makes it really hard to compose `Result`. Ideally I would
like to chain `Results` as `e1.and_then(e2).and_then(e3)` but its not possible
due to incompatible error enums. Ended up using
`[https://docs.rs/crate/custom_error/1.3.0`](https://docs.rs/crate/custom_error/1.3.0`)
to align the types.

\- A lot of basic things are still influx and community wide standards have
not been established. For example: I needed to externalize some environment
specific settings in a Config but couldnt figure out where to put non-code
assets in a cargo project and then how to reliable read them. In JVM world
`src/main/resources` acts like a standard place for stuff like this but that
patterns has not been established yet.

\- Distributing code inside the company is hard because there is no
integration with Artifactory or similar tools. We are directly referring git
sha in Cargo right now and waiting for better solutions.

\- Rust comes with a default unit test framework but it pretty bare bones. I
havent seen examples of test fixture, setup/teardown support and loading test
configs etc.

\- I really like Rust compiler because of really good error messages it
produces but its really slow and you start to notice it as you add more
code/external crates

-IDE support is good but not great. I am using IntelliJ with Rust plugin as we use IntelliJ for Scala/JVM and it is nowhere as good as even Scala plugin which is pretty mediocre in itself.

Overall I am pretty happy with the language (except for Error issue) and most
of my gripes are around the ecosystem and tooling around the language.
Hopefully these will be resolved as language gains more momentum

~~~
smaddox
You should try using `map_err` and the `?` operator, with your own error enum
defined using the `failure_derive` crate, for example:

    
    
        foo().map_err(|e| MyError::FooError(e))?
          .bar().map_err(|e| MyError::BarError(e))?;

~~~
kouteiheika
A tip - you usually don't need lambdas in such cases; this should work:

    
    
        foo().map_err(MyError::FooError)?
          .bar().map_err(MyError::BarError)?;

~~~
smaddox
Oh, nice! I did not realize tuple constructors implemented `FnOnce`! Thanks
for the tip!

------
Lerc
What I would like to see is something where people could submit a small
working program in one language and a Rust expert would make a program that
does the same thing in idiomatic Rust. This doesn't need to be anything too
complex. A wiki would be fine, the work would be in having volunteers to make
the demos.

If you don't know the idioms you end up doing a sort of transliteration of the
source language where the concepts may work against the nature of Rust. A
developer can spend a long time barking up the wrong tree with few indicators
as to which is the right tree.

As an example of what I mean. Here is a program that I wrote in JavaScript
specifically because I could not find a way to write it in Rust that felt like
I was doing it the right way.

[https://codepen.io/Lerc/pen/yQxmob?editors=0010](https://codepen.io/Lerc/pen/yQxmob?editors=0010)

I could come up with Rust versions that were basically emulating pointers with
array indexes(and a mess when something is deleted), or map versions that
incurred lots of run-time lookup. The crux of the problem, I think is either
how to do a mutable graph of mutable nodes, or how to do map on a immutable
graph of immutable nodes to a new immutable graph of immutable nodes in the
next state along.

I'm sure others have this issue of "I know how to do it in X, doing it that
way in Rust is a mess, what's the right way?"

~~~
em-bee
take a look at
[http://rosettacode.org/wiki/Category:Rust](http://rosettacode.org/wiki/Category:Rust)
more than 400 code examples have a solution in Rust.

~~~
steveklabnik
There’s no real guarantee of quality or idiom there, though.

~~~
em-bee
but that's something the rust community could take care of.

should be much less work than creating yet another repository.

i think there was at least one language that made rosettacode their official
repository for code examples. so all their solutions were vetted by
experienced developers.

i believe the rosettacode maintainers would allow adding a note to each
example that has been checked. (simply add it to the description of the
solution, so that people know which examples are recommended)

~~~
em-bee
you could also create a list of links to approved rosettacode examples

------
wwright
I truly love the Rust project.

There is so much genuine compassion, diligence, and attention in the
community, and it shows everywhere.

~~~
cjohansson
That has been my experience as well

------
qznc
I continue to admire the Rust PR. This "everybody blog what Rust should do in
2019" generates a lot of publicity from my point of view.

Other language communities, take note.

------
swsieber
Well, I didn't expect to see this pop up here. (I'm the author)

~~~
coldtea
Almost everything major (and lots of non-major stuff, like minor release
announcements) regarding Rust ends up on HN, so it only made sense that this
would too...

~~~
swsieber
I'd love to see click through vs up vote rates. I.e. do people up vote without
clicking through? I'd love to see how it varies by topic...

------
nixpulvis
One of my 2019 goals is to try and be more involved with Rust in some way or
shape. Hoping to go to meetups or the like. Rust as a language is really
special to me, and I'd love to be able to give more back.

------
jhack
Thought it'd be the syntax. Maybe next year.

~~~
steveklabnik
There are no plans to significantly change the syntax.

~~~
zozbot123
Not as part of the official Rust project, of course. But it would be nice to
see some exploration of what a "reskin" of Rust-like semantics with a
different syntax could look like. Kind of like some languages, e.g. VB.NET or
Nim are little more than "reskins" of others, in ways that arguably make them
more intuitive than the original.

~~~
swsieber
[https://internals.rust-lang.org/t/pre-rfc-first-class-
suppor...](https://internals.rust-lang.org/t/pre-rfc-first-class-support-for-
compile-to-rust-languages/7610/14)

^^ This link is a pre rfc for adding good support for those types of things.

------
SlowRobotAhead
>The embededded working group could probably use a page listing all the
platforms

I haven’t looked into which micros are supported by Rust in actuality because
I checked their main site and saw an old Nordic, a few old STMs, an old NXP,
and some old MSPs, then left the page.

If I was a hobbiest this might be ok and I might research it more. As a
professional, I pretty much noped out of there assuming that it’s just nowhere
near ready for me.

I’d like to see it work! But until there is an IDE with debugging using code
overlay and breakpoints... Rust is just not for me. I wonder what year they
get there?

Edit: apparently there is a gap between what hobbiests consider acceptable and
what my company would need that the Rust fans can’t imagine - this somehow
means my opinion isn’t valid. Let me know when Keil or IAR or anyone sells a
supported and professional IDE with a Rust compiler.

~~~
th0br0
You do get all that today already. The various Cortex'es are supported rather
well + gdb in combination with a JLink gives you the debugging interfaces you
need.

~~~
SlowRobotAhead
You’re talking about command-line GDB?

~~~
XMPPwocky
Or anything that can talk to a gdbserver (most IDEs).

