641 points · by signa11 · 5y ago · 170 comments
[1]: http://lambda-the-ultimate.org/user/825/track?sort=desc&orde...
This post is an example of the incredible impact an engineering manager can have without writing a line of code.
The article doesn't mention it but this is of course a very good long term strategy. Things students learn during their formative years at university will bear fruit once they enter the work force.
How many of those students are now at or about to enter important positions in the industry?
Do you think Java could have become this big if it wasn't teached at so many universities at the entry level?
I am still sad that some of the things I've seen or have taken part in didn't materialize and haven't taken a hold in the present.
The students you had were certainly as happy as being with you as you were having them. :-)
It sounds like the leadership of Dave was key to getting the team to focus and to delivery high quality results.
But I derive a great deal of my current livelihood from Rust and helping firms use it well, so thank you, Dave.
If nothing else, maybe I'll be looking more closely at my next tools, and hoping they have their own Daves quietly advocating for their success.
I did not realize this; that explains why cargo is so similar to ruby bundler (which Katz also wrote).
I'd love to see an interview with him on his experiences with dependency management. What did he learn? What things in earlier attempts did he change in later attempts (from bundler to cargo to yarn)? What does he think he got rightest? What mistakes does he think he made? What mistakes does he think other people are still making? What features of a language or platform faciliate or challenge good dependency management? etc etc etc.
In general, I think there isn't much "learning from prior art" in our field that crosses language/platform boundaries. Katz being personally driving the implementing popular dependency management solutions on three different langauges/platforms was one way to actually learn from cross-language experience! I think in dependency management in particular, there are still a lot of lessons people are learning on their own not realizing another language/platform already learned some painful lessons on it... or maybe differences in langauges/platform mean some things aren't transferable...
https://github.com/graydon/rust-prehistory/commit/8952f420ae...
Not only his name is on the Rust commit repo, he's also in the list of top 10 commiters the article features as an early Rust development example (although for just 6 commits or so).
It has a payback a long way down the road but my gut knows it is worth it.
I've never learned how to use macros effectively, but once I've gotten more comfortable in Rust I'd like to give it a good shot. Given Dave's background with Racket and Macros, this feels like a worthwhile endeavor.
On a side note there are a lot of cool language oriented programming stuff that Racket does through it's macro system, and I wonder if it is at all possible to do something like that in Rust
There was an aha-moment when I realised that it was token based and not AST based like some other macro systems I've worked with in some other languages.
Case in point is how to express varargs in macro rules which is expressed roughly like a comma followed by an expression repeated n times. Super nice.
I love the designed by committee aspect of Rust. I have great respect for good committees. I have served on a few (and some bad ones, shiver). One of the things that makes a committee work is a good facilitator
As the saying goes: A camel is a horse designed by a committee: Goes twice as far on half as much carrying twice the load....
Quite a few times I was surprised that Rust breaks with some old patterns that were copied over and over in the last 50 years or so. For example: "match" instead of "switch", or the same if/else regardless if it is a statement or a value. These are small touches, but they show attention to detail.
These are good ideas for sure, but they are bread and butter to anyone who is familiar with functional programming. The Lisp and ML families of languages have had them for many decades.
The fact that more languages _aren't_ like this is what's surprising to me, given how effective they are. I love that Rust is bringing them to the masses, but what on earth took the industry so long to accept them?
I guess the answer is that algebraic data types (inductively defined data) tend to be pitted against object-oriented programming (coinductively defined data), and object-oriented programming has dominated the industry for the past 3 decades. Some languages like Kotlin have tried to combine them, but personally I'd rather just embrace the former and relegate the latter to a seldomly-used design pattern, not a programming paradigm hardcoded into the language.
I'm currently designing my own toy language and writing the compiler (to LLVM IR) in Rust.
Representing the AST with Rust's sum types is so simple. Visiting that AST through pattern matching is great. But the "enum" keyword still bugs me.
The way you define product types (tuples, records, empty types) and then their implementation, just awesome. But the "struct" keyword still bugs me too.
It feels "high level" with some quirks.
Then you have references, Box, Rc, Arc, Cell, lifetimes etc... It feels (rightfully) "low level".
Then you have traits, the relative difficulty (mostly for Rust newbies like me) of composing Result types with distinct error types, etc...
It feels "somewhat high level but still low level".
Sometimes you can think only about your algorithm, some other times you have to know how the compiler works. It seems logical for such a language, but still bugs me.
The one thing I hate though, is the defensive programming pattern. I just validated that JSON structure with a JSON schema, so I KNOW that the data is valid. Why do I need to `.unwrap().as_string().unwrap()` everywhere I use this immutable data?
[0]: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-va...
Everything else is named so well and designed so well that this really sticks out.
foo.expect("already validated")[1]: https://pingcap.com/blog/rust-compilation-model-calamity
They are awesome but they make compile-time arbitrarily bad. The D compiler is roughly as fast as the Go one. However, D has macros though and that makes it very slow to compile sometimes.
The alternative to macros are code generators. Works fine for bigger stuff like a parser generator but not for smaller stuff like a regex.
Not according to this benchmark:
https://github.com/nordlow/compiler-benchmark
dmd performed around 1.5x to 4x faster than go.
My only experience with Rust so far has been trying to learn it by writing applications in it and also use 3rd party CLIs, but quickly loosing interest because the "change <> try out change" cycle has been too slow and cumbersome, and installing/compiling dependencies take fucking forever, even on a i9-9900K.
An important thing though, if you aren't doing this already, is to not wait for a full build to know if your types check out. You can use cargo-check if you prefer (https://doc.rust-lang.org/cargo/commands/cargo-check.html), but really I recommend using an editor with immediate feedback if at all possible. rust-analyzer (an LSP) is one of the best, and should be available even if you're on Vim or something.
Using Rust without snappy editor hints is fairly miserable because of how interactive the error feedback loop tends to be. If you don't rely on a full build for errors - just for actual testing - I find the build times to be perfectly livable (at least in the smallish projects I've done).
[1] https://bevyengine.org/learn/book/getting-started/setup/#ena...
About on par with C/C++ and Go. In that you don't have one and don't want for one. REPL driven development is difficult with languages like Rust, both to implement and use.
I think there are some projects floating around out there, but I personally don't see a purpose for one. It's not python or matlab.
On the other hand iterative development with rust analyzer going and all the dependencies already built is pretty painless. By the time you run your tests or program, it's likely to take only a few seconds to build.
That said you can write terribly long to compile rust. Usually there's some trades you can make to weigh compile time as more important than flexibility or static code paths.
I've written a sizeable ad server in rust with maybe 25kloc. Where I was the sole developer and sys ops person, it cost me a little upfront time but saved me many more hours in operations work.
In my experience, you write some code, the rust analyzer (which is easily embedded in an IDE like VSCode or IntelliJ - which has its own "analyzer" I think) gives you immediate feedback, so you know immediately if things compile or not (there are a few edge cases the analyzer might miss, so when you actually run "rustc" something doesn't compile, but it's pretty rare)... you then write a little test , and Rust has many ways of letting you do that (unit tests right into the same file as the code being tested, integration tests which let you use the code as if from another crate, and even doctests, which are like unit tests but embedded in the documentation of your code)... running the tests is a matter of pressing a button and waiting a few seconds (compilation + test runtime) normally, unless you change dependencies between runs as that requires downloading/compiling your code AND the dependencies, which can be very slow (dozens of seconds)... which is the same problem as with a fresh build, which will almost certainly run in the minutes because of the necessary local compilation of all dependencies... but the experience is not very different from something like Java or Kotlin IMO (but definitely a slower cycle than Go, for example).
But once they're there, the result is extremely advanced tooling that other language ecosystems have taken years to develop. Things like IDEs, debuggers, static analyzers, superoptimizers, fuzzers, verification tools, build systems, language interop adapters, and code generators, are all examples of things that can take advantage of advanced type systems to develop strong capabilities extremely easily.
I think Rust is starting to show signs of such benefits, and I think in 10 years we'll all be looking back at it with surprise that anyone ever doubted it.
I'm curious, could you elaborate?
foo(x : int)
Therefore, one would expect to annotate the return type as,
foo(x : int) : string
Since the pattern is showing foo applied to x. The Rust syntax is actually confusing for both Haskell/ML programmers (where the arrow comes from) and mainstream programmers. It's too small an issue to change now though.
Rust's support for proper "algebraic data types" is very good and gives it an advantage over languages like C++. However there are some small surprises, such as forcing all enum constructors/fields to be public (one must therefore wrap it to make an abstract data type).
Every language has its warts and these are particularly minor ones.
Haskell doesn't use that notation either, it uses -> both for the parameter list and for the return type, and separates argument names (arguably, these are poor choices, since currying is not an efficient CPU-native operation and not intuitive so distinguishing between multiple arguments and returning closures is useful, and argument names are useful for documentation).
On the other hand the enum thing is certainly surprising.
> foo(x : int) : string
> since the pattern is showing foo applied to x.
kind of like the C/C++ "declaration mirrors use" thing, i.e.
int *foo;
which means"the result of dereferencing `foo` is of type `int`"
which is not the same as saying
foo : Ptr<int>;
because in the former, you're kind of describing what `foo` is a without actually saying it, if that makes sense.i find that way of specifying types counterintuitive in both C/C++ and MLs.
So now companies make billions off of the software written in Rust and has even one student become a millionaire? Companies that appropriate such projects should start paying their fair share to people who made it possible for them to make such profits.
This is arguable a big idea of free software: trying to jealously hoard the value for ideas that are naturally freely copied and shared is just plain inefficient.
So yes, in this case it would be nice if these interns got a big pay out, but if they did, then the megacorps wouldn't bother using Rust because they plan is already to just outbid all the non-monopolists for workers rather than actually be productive with their workforce. And C++ and whatever else are already free, so Rust has to complete with those.
The only way to make things more fair is just give up on meritocratic value capture, and just do a big tax and big UBI, so just as free software is free to use by all, some of the value created in the use of free software is also freely shared by all.
Just limiting to software engineering (there's other lucrative fields out there) you can easily make a six-figure income remotely. This gives you the freedom to live somewhere with very low cost of living. It's not hard to build wealth this way.
You could debate that getting the necessary skills to get a job like this is harder than it should be.. that corporations themselves are broken.. whatever your worldview is that's fine but "cannot get wealthy off salary" is just plain false.
You can make hundreds of thousands of dollars a year as an engineer, without even talking about stock. I'd call that wealthy. If you're an engineer of some stature, 7 figures TC yearly is not out of reach.
let and let mut
let and var
And went with the verbose option.Swift went with the succinct option, which I love about the language. In practice I suppose I do mostly type “let” in Swift so it doesn’t matter much
Swift, however, chose ‘func’ instead of ‘fn’, after much debate.
Those little things that are debated initially, then forever
let (x, mut y) = (5, 10);
After this statement `x` will not be mutable, but `y` will be. You cannot do let mut (x, y) = (5, 10);
So the way Rust currently works just doesn't map clearly on `let` and `var`.This is in the era of a new version having patch notes like (paraphrased) "Of the four pointer types with special syntax, we've converted two of them to regular types with names and deleted the fourth" - it predated that much concern with backwards compatibility.
In the end, social factors and inertia trumped technical precision and consistency. I am strongly inclined to think this was a mistake. Mutability is easier to explain initially, but teaches an incorrect mental model that hinders a correct understanding of Rust’s approach to memory safety, falling apart as soon as you touch things like atomics, RefCell or Mutex, which mutate self despite taking it as &self, a supposedly immutable reference.
Could you elaborate or link to some material / discussion regarding that? I'd be very interested in how the alternative approach you're describing would change (or make unnecessary) constructs like RefCell.
The thing I’m noting about atomics, RefCell and Mutex is how they have methods that (safely) mutate themselves, despite taking &self, a supposedly immutable reference.
(I’ve modified the final sentence in my original comment to clarify this.)
Does it really fall apart? None of these constructs change the fact that if a &mut T is available, you can call functions on that type that take &mut self. The only thing that breaks is the assumption that non-presence of mut implies that there is no way to call those &mut self functions. If you change it to "non-prsence of mut implies that you need extra constructs like atomics, RefCell or Mutexes in order to get mutable access" it works out again.
This becomes a huge deal when people think that they have an immutable data structure just because they have an & reference to it. Someone will inevitably stash a mutex or similar in there because they just need to be able to mutate it this once… I mean these three times… I mean all the time. Oh, you wanted this immutable data structure so you could diff it for your VDOM or incremental calculations or whatever? Heh, guess you’ll have to find some other way or structure things so that mutations can be propagated through the object tree or something. And you’ll keep on having cache issues from time to time when people forget to jump through the right hoops. Sorry about that.
So yeah, the mental model of &/&mut references being about mutability is just completely and harmfully wrong. Rust does not have a way of guaranteeing immutability.
fn (&mut T) proc (x: var T)Super clear. The "let" version smells a lot of "I have a CompSci PhD".
let vs let mut is /clear/ - you can simply not mix them up.
I think of it as being more math like rather than PhD.
Nothing wrong with borrowing from math.
30 years ago I think it would have reminded people more of BASIC or Fortran than (say) Scheme.
Now? It's in Javascript in its ES6 evolution and related languages, Swift, Rust, and probably other "newer" languages I'm not aware of. Scala had it ten years ago also, but is more mainstream than it was then.
Using 'var' instead of 'val' where possible: the compiler/linter will tell you this.
Or do you mean something else?
But everyone is cheering them on.
Investing your time in improving C++ is a safe bet for a long-lasting meaningful impact on software [development]. C++ will outlive Bjarne.