1. 38

  2. 7

    There seems to be more “intermediate” level Rust posts recently. OP is a good example.

    1. 8

      It’s true, and great to see! It might be in response to the Rust 2018 roadmap, which specifically highlights:

      One of the strongest messages we’ve heard from production users, and the 2017 survey, is that people need more resources to take them from understanding Rust’s concepts to knowing how to use them effectively. The roadmap does not stipulate exactly what these resources should look like — probably there should be several kinds — but commits us as a community to putting significant work into this space, and ending the year with some solid new material.

      <plug shameless=true> For example, I’ve been doing Rust live-coding sessions where we build non-trivial (and useful) Rust crates (e.g., I recently did one on writing an asynchronous SSH client), and those have been pretty well received. It seems like we’re getting more and more Rustaceans who want to try Rust for “real things”, and that’s pretty exciting! It’s good to see the supply meeting that demand.

      1. 6

        (OP) I think it’s a virtuous cycle. I got into Rust because I read some good entry level posts that talked about how it was ready for prime time.

      2. 7

        Another language that’s worth taking a look at for CLI apps is OCaml,this blog series has a good rundown of of porting a Python app.

        1. 11

          I really want to agree, because I love MLs and love how simple OCaml’s runtime is, but I find OCaml so frustrating in practice. There are, what, three standard libraries, which are incompatible with one another, and then also several incompatible build systems. I’m sure it’s possible to work around this and make them interpolate, but it drove me completely nuts last time I tried that route.

          1. 1

            Is the Reason flavour any better in those areas?

            1. 1

              I haven’t tried it for the dual reason that I don’t trust Facebook and it’s more a language that can target OCaml than genuinely OCaml. That may be unfair, and some old co-workers of mine love it, but I just haven’t tried it enough to form an opinion.

          2. 2

            I really never felt at home in MLs. I like haskell (although I am wary of its laziness, I usually prefer strictness as a default), I like Rust (although I would be happy to just have a GC instead of borrow-checking, but I can see what rust is aiming at, its just not my use case).

            OCaml in my experience (1-2 years ago) lacked good tooling and the ecosystem I find in Rust or Haskell. Also I miss typeclasses or traits.

            1. 2

              The situation is still not perfect in OCaml world, but the new dune (former jbuilder) build system is becoming the de-facto standard and tooling in the last couple of years has been improving a lot. The example of cargo, among other things, has been driving a lot of changes

          3. 5

            I thought the float sorting was interesting. Here’s how Go handles NaN and Inf:



            1. 3

              I did a facepalm at the “It turns shadowing from a frequent cause of bugs into something that prevents bugs!”

              1. 5

                I think it’s really not quite as bad because you have the semantic information through the variable name and a strong type system backing you. There are definitely times where I’m taking the same piece of data but transmuting it over a sequence of types for different reasons like encodings and such and it’s a pain to perform that ceremony of Hungarian notation. If the semantics remain the same and the type encoding is the only difference, maybe shadowing is the right thing, especially with lifetimes.

                1. 1

                  I think the mentality is, that a variable isnt anIdentifier, but kind of apair (anIdentifier, aType), so repeating the information contained in the type in the identifier is redundant and sometimes even bad, because after a refactoring the type might have changed (from a vector to an iterator for example, etc).

                  Of course this shouldn’t be the opportunity to name all local variables x, but it can make sense for a chain of transformations, filtering down a result list for example.