David Tolnay Profile Banner
David Tolnay Profile
David Tolnay

@davidtolnay

Followers
7,811
Following
148
Media
35
Statuses
368
Explore trending content on Musk Viewer
@davidtolnay
David Tolnay
4 months
If you are running into broken GitHub integrations today, it's because GitHub issuecomment IDs have just passed the maximum value of i32. For example @rustlang 's rfcbot is currently out of commission with an i32 overflow.
Tweet media one
16
271
2K
@davidtolnay
David Tolnay
2 years
The "Industry Coefficient" of some widely used Rust crates. The coefficient is POSITIVE if a crate is disproportionately often downloaded on weekDAYS, and NEGATIVE if disproportionately often downloaded on weekENDS. 0 is the mean across all crates on crates-io.
Tweet media one
25
113
843
@davidtolnay
David Tolnay
2 years
Stack Overflow Developer Survey 2022 - 86.7% of those using Rust want to KEEP USING Rust (significantly higher than any other language) - 17.6% of those NOT using Rust WANT to use it (higher than any other language) - 9.3% of respondents use Rust (up from 7.0% last year)
6
112
734
@davidtolnay
David Tolnay
3 years
Extremely many commas in my crates​.io dashboard this morning
Tweet media one
15
19
632
@davidtolnay
David Tolnay
2 years
All the Rust punctuation, sorted by how often used on crates​.io
Tweet media one
24
64
608
@davidtolnay
David Tolnay
2 years
@rustlang 's crates​.io had more downloads over the past year (13.5 billion) than the previous 7+ years put together (13.2 billion).
4
51
376
@davidtolnay
David Tolnay
2 years
Happy belated 2nd birthday to this guy's reddit comment.
Tweet media one
7
20
330
@davidtolnay
David Tolnay
10 months
This is the impact of Cargo sparse registry protocol (Rust 1.68+) on my CI jobs.
Tweet media one
5
24
321
@davidtolnay
David Tolnay
3 years
New in 1.0.48 of the anyhow crate's `ensure!` macro: we now render a Debug representation of the lhs and rhs of comparison operators into the error message if both sides have a Debug impl.
Tweet media one
5
22
291
@davidtolnay
David Tolnay
3 years
got done my 10000th hour of Rust practice this week, and excited to get to do some real projects now
1
2
257
@davidtolnay
David Tolnay
9 months
Rust's crates-io is now getting as many downloads per week as it got in the years 2015, 2016, 2017, and 2018 put together.
@TobiasBieniek
Tobias Bieniek
9 months
🦀 just passed 50 billion crate downloads 🎉 thank you to everyone who contributed and to all of our sponsors! and thank you also to the Rust Foundation for providing the team with a full-time employee now :) #rustlang #rust
Tweet media one
0
22
104
1
21
244
@davidtolnay
David Tolnay
3 years
New project: a syntax tree pretty-printer that is designed to be usable with generated code.
Tweet media one
2
26
240
@davidtolnay
David Tolnay
3 years
I no longer remember how/why I started learning Rust, but I remember this early impression with crystal clarity: "This language seems neat but it's too bad all the worthwhile libraries are already being built by somebody else" —dtolnay, early 2016, aspiring library designer
4
16
217
@davidtolnay
David Tolnay
3 years
This progression of floating point formatting performance is wild. The Rust libraries here are mine but my only contribution is porting these algorithms to Rust from C. dtoa/Grisu2 (2010) ⟶ Ryū (2018) ⟶ Dragonbox/Schubfach (2020)
Tweet media one
2
10
187
@davidtolnay
David Tolnay
8 months
Tweet media one
4
21
181
@davidtolnay
David Tolnay
3 years
How is it possible that the new `semver` crate makes fewer allocations by a factor of 50× than the previous implementation?
4
20
167
@davidtolnay
David Tolnay
3 years
It's because pointers these days are gigantic, and the vast majority of pre-release strings and build metadata on crates​.io are 8 or fewer ASCII bytes. That amount of text fits *into a pointer* without even any allocation for it to point to.
11
8
165
@davidtolnay
David Tolnay
3 months
As one of the only people who has written a production-quality Rust parser singlehandedly, I used to think: PARSER (code⟶AST): hard PRINTER (AST⟶ugly code): easy FORMATTER (ugly code⟶pretty): hard Came to realize over the past year, for Rust, printer is the hardest of the 3.
1
7
149
@davidtolnay
David Tolnay
2 years
@joshuayn514 @joseph_h_garvin @pcwalton Rust CVEs are filed on unsound library APIs like cpy, even absent any misuse. Whereas all memory-unsafe languages' CVEs are filed only on concrete occurrence of misuse, because literally everything is unsound; those langs do not have such thing as a sound API in the first place.
1
19
136
@davidtolnay
David Tolnay
2 years
@AliceICecile Here is the code if you want to run it on other crates: Bevy is -2.8298 which is way outside the range of the ones in the screenshot.
0
2
137
@davidtolnay
David Tolnay
2 years
@UkonnRa Serde's ratio of weekday downloads to weekend downloads is nearly the same as crates-io's overall ratio. Prost has a bigger proportion of its downloads on weekdays and smaller on weekend, because ain't nobody does protobuf stuff for fun on a weekend.
0
3
127
@davidtolnay
David Tolnay
2 years
Release notes for serde-yaml 0.9: <> Fun fact: this crate was my first ever Rust code. I'm sure someone can dig up a link to the initial commit. The crate has been mostly unchanged and neglected for 6 years but this near-complete rewrite is quite good.
1
10
123
@davidtolnay
David Tolnay
2 years
12% of all crates depend directly on one or both of these libraries and still rapidly climbing.
Tweet media one
3
2
119
@davidtolnay
David Tolnay
2 years
Anyone on here familiar with Wasmtime and would be willing to collaborate on a precompiled proc macros RFC based around `--target=wasm32-macro`?
10
21
114
@davidtolnay
David Tolnay
1 year
My analysis of the 2023 Stack Overflow survey data: If everyone "does what they want" across all languages (all unhappy current users stop using it, all interested non-users adopt it) then Rust usage grows 2.3×, Python shrinks to 0.81×, C++ shrinks to 0.73× of this year's usage.
Tweet media one
1
12
113
@davidtolnay
David Tolnay
2 years
@andresmargalef @mitsuhiko Serde & serde_json & serde_derive all do not use `?` because it is too slow in both runtime and compile time. IIRC the factors are around same as what Armin found, 9–15%.
3
9
103
@davidtolnay
David Tolnay
1 year
Analogy: Buck2 is to Cargo as Rust is to JavaScript
3
16
102
@davidtolnay
David Tolnay
3 years
@m_ou_se Subtle? I can do subtle. Here is one that involves at least 3 rustfmt bugs. For bonus, you can format it A SECOND TIME and the code will change again. https:/play.rust-lang.org/?gist=311cd549627d6826e674cc06165129f0
6
3
98
@davidtolnay
David Tolnay
2 years
Curious why traffic to cxx.​rs is dominated by India, while for serde.​rs India is not even in top 5. Google `cxx india` turns up mostly porn sites—is "cxx" a bastardization of "sex"/"xxx"? And "rupee" being abbreviated "Rs"—have I hijacked a subcontinent's naughty searches?
Tweet media one
Tweet media two
Tweet media three
Tweet media four
8
3
90
@davidtolnay
David Tolnay
1 year
Anyone know what's been happening with package count on npm? They have been averaging steady <1000/day for multiple years. But since last week it's been 80,000/day. Is this the e-book spam I've heard about? Is it GPT-4 taking over the world?
Tweet media one
5
5
84
@davidtolnay
David Tolnay
4 months
My brother is thinking of a career change—If any of you would want to hire the less experienced version of me for cheap, please email him or DM me. Interested in advice or entry level roles in data analysis, insurance, banking, IT/tech support, or anything math/stats/modeling.
Tweet media one
2
9
73
@davidtolnay
David Tolnay
3 years
I got a chance to play with timely and differential-dataflow this week, and I am blown away — it is incredibly good.
2
8
69
@davidtolnay
David Tolnay
3 years
Today I think this is about as wrong today as it was in 2016. We don't have materially fewer blind spots today, due to the scope of what Rust is imminently applicable to being vastly bigger.
1
0
65
@davidtolnay
David Tolnay
2 years
@andresmargalef @mitsuhiko One would hope rustc could just notice the orig and return error type are inferred to the same type, and produce exactly the same LLVM IR as the simpler macro does in that situation, instead of all the internal mechanics of `?`. Every result-heavy rust program gets 9% faster?
3
1
65
@davidtolnay
David Tolnay
2 years
Doing some multiplication: this means 24.0% of ALL the survey takers said they want to use Rust next year. 9.3% use Rust this year. 📈
2
8
64
@davidtolnay
David Tolnay
2 years
That is INSANE as a near-term "total addressable market" approximation. For comparison, not even 24% of survey takers were using C++ this year.
3
7
59
@davidtolnay
David Tolnay
2 years
Serious proposal: if more than 30% of crates·io has a direct dependency on a person's crates, then all of that person's crates should get prioritized in the docs·rs build queue instead of waiting behind the cryptocurrency crates for hours/days.
yes please
444
you inpatient fool
52
🍿
146
16
3
54
@davidtolnay
David Tolnay
2 years
@pcwalton This program would have CVE: fn main() { let x = 9; print!("{}", cpy(&x)); } pub fn cpy(p: *const i32) -> i32 { unsafe { *p } } despite not even UB. It is 100% guaranteed behavior, but "not correct Rust". Examples like this might help folks see the different standard.
2
3
54
@davidtolnay
David Tolnay
2 years
Tweet media one
@davidtolnay
David Tolnay
3 years
Extremely many commas in my crates​.io dashboard this morning
Tweet media one
15
19
632
1
1
50
@davidtolnay
David Tolnay
2 years
Which of the following functions are legal to pass as argument to `dispatch`? (⬇️ 4 questions, there is at least 1 yes and 1 no) fn dispatch<T>(f: impl Fn(&mut View<T>)) {} struct View<'a, T: 'a> { marker: PhantomData<&'a mut T>, }
6
6
50
@davidtolnay
David Tolnay
4 years
@m_ou_se @rustlang @m_ou_se is one of the best things to happen to the Rust standard library in a long time.
@m_ou_se
Mara
4 years
For the past month, I've been a bit more actively contributing to the @rustlang project, and it's been a wonderful experience. The reviewers are all so friendly and helpful. <3 Looking forward to keep doing this more. 😊
Tweet media one
3
14
279
0
6
45
@davidtolnay
David Tolnay
5 years
Tweet media one
1
2
40
@davidtolnay
David Tolnay
3 years
@ekuber @timClicks I opted out of this particular personality cult by putting 'Expert'. There are plenty of people with greater expertise than me in some areas of Rust, and the areas that I am best at are not always the most important.
2
0
39
@davidtolnay
David Tolnay
1 year
0
0
40
@davidtolnay
David Tolnay
3 years
A web framework was already done (iron), a serialization framework was already done (rustc-serialize), and so on.
1
0
39
@davidtolnay
David Tolnay
3 years
@m_ou_se Yes, there is a load-bearing `let ();` in there.
2
0
39
@davidtolnay
David Tolnay
2 years
0
4
38
@davidtolnay
David Tolnay
1 year
@matthiasendler The usage graph shows this even more starkly than stars.
Tweet media one
2
1
36
@davidtolnay
David Tolnay
2 years
I implemented support for compiling and doc-testing #![crate_type = "proc-macro"] in the Rust playground:
0
4
35
@davidtolnay
David Tolnay
4 months
7.6% of rustaceans approve of Rust's grammar for closures and ranges.
@davidtolnay
David Tolnay
5 months
let _ = || a .. b .. c;
3
5
23
1
2
34
@davidtolnay
David Tolnay
1 year
@matthiasendler I found the following aggregation informative. This graph is fraction of crates that used a previous-generation error library over time, vs current-gen library. Prev gen peaked at 9.5% while anyhow/thiserror are at 16% and climbing. So 2× crates benefit from error lib as used to.
Tweet media one
0
3
30
@davidtolnay
David Tolnay
2 years
@ekuber Most crates do not depend on syn. 50.6% of crates on crates⁠.io do not depend on syn, to be exact.
1
0
29
@davidtolnay
David Tolnay
3 years
all_the_right_linebreaks::in_all_the_right_places(f) does not fit in a poll option
2
0
29
@davidtolnay
David Tolnay
3 years
API for a syn AST pretty-printer
prettyplease::unparse(f)
100
f.but_with_linebreaks()
51
quoteln!(#f)
88
5
3
28
@davidtolnay
David Tolnay
1 year
[Cargo, JS]—day-zero new user experience: I typed some things in the console and it did what I meant [Buck2, Rust]—wtf is a prelude? Why is String different from the type of a string literal? Why is that thing a macro?
1
0
24
@davidtolnay
David Tolnay
3 years
Tweet media one
1
0
24
@davidtolnay
David Tolnay
3 months
Printer is in charge of parenthesis insertion so that e.g. `a*B` where B is `c+d` gets printed as `a*(c+d)`, not `a*c+d`. Conventionally this is done using an integer precedence level. Add parens whenever precedence of the subexpression's expr kind is less than outer expression.
2
0
23
@davidtolnay
David Tolnay
5 months
let _ = || a .. b .. c;
parse as (|| (a..b))..c
30
parse as ((|| a)..b)..c
13
parse as (|| ((a..b)..c))
193
should fail to parse
161
3
5
23
@davidtolnay
David Tolnay
1 year
[Cargo, JS]—decent tool for many jobs. In the extreme, with sufficient effort you can build some deranged things that are way outside the scope of what it's appropriate for, and regret it [Buck2, Rust]—scales to make the arbitrarily deranged thing sanely maintainable and fast
1
1
22
@davidtolnay
David Tolnay
1 year
New details emerge on the India mystery. The search query is "सीएक्सएक्स" which Google Translate just translates to "cxx". Is that an accurate translation? What does this term refer to — does it have anything to do with C++?
Tweet media one
@davidtolnay
David Tolnay
2 years
Curious why traffic to cxx.​rs is dominated by India, while for serde.​rs India is not even in top 5. Google `cxx india` turns up mostly porn sites—is "cxx" a bastardization of "sex"/"xxx"? And "rupee" being abbreviated "Rs"—have I hijacked a subcontinent's naughty searches?
Tweet media one
Tweet media two
Tweet media three
Tweet media four
8
3
90
5
1
23
@davidtolnay
David Tolnay
5 years
@sgrif @yoshuawuyts @jntrnr We'd like to have distribute proc macros as precompiled wasm binaries that are executed by a wasm runtime in the compiler. Then adding a dependency on a proc macro no longer adds anything to compile time.
4
5
22
@davidtolnay
David Tolnay
3 months
The parser "just" needs to implement all the special cases and bespoke restrictions, which is straightforward. The AST printer needs to backsolve the transitive consequences of all special cases stacked upon one another.
1
0
22
@davidtolnay
David Tolnay
3 years
@m_ou_se This is absolutely a thing in Outlook.
Tweet media one
2
0
20
@davidtolnay
David Tolnay
3 months
It matters that the printer always produce syntactically valid output code. Otherwise we couldn't pipe the output of `cargo expand` (macro expansion) to format with rustfmt. In the formatter, precedence isn't as complex because the input code is already adequately parenthesized.
1
0
19
@davidtolnay
David Tolnay
3 months
Writing an AST printer for Rust that consistently produces syntactically valid output code is fiendishly complicated. Precedence in Rust is an 8-dimensional vector space as a consequence of all kinds of early bailouts and lookaheads and special cases in the grammar.
1
0
20
@davidtolnay
David Tolnay
3 years
@LeeWHowes @pcwalton Freeing when the reference count reaches N>0 is also garbage collection. OS will collect the garbage during the resulting crash.
0
0
19
@davidtolnay
David Tolnay
2 years
@squirrellang @erin_catto (Serde author here.) "I'm surprised people are excited by Rust" is such a surprising takeaway. I vastly prefer what we have over runtime reflection, for the majority of the same use cases and many more.
1
0
19
@davidtolnay
David Tolnay
3 months
Example: the closures/ranges grammar I tweeted about. There is no integer precedence level that captures the precedence relationships in this code. Or: `break 1 + 'a: loop {}` is valid syntax but `break 'a: loop {} + 1` is not, `break 'b 'a: loop {}` is.
@davidtolnay
David Tolnay
4 months
7.6% of rustaceans approve of Rust's grammar for closures and ranges.
1
2
34
1
1
17
@davidtolnay
David Tolnay
2 years
@sunshowers6 Did not get sick, have not heard of anyone getting sick. But as someone who skipped all 10 talks and spent the day in the hallway track talking, it took a couple days for my voice to recover from speaking loudly enough to be clear through a mask.
0
0
18
@davidtolnay
David Tolnay
3 years
@mappum It's a macro, so:
1
1
17
@davidtolnay
David Tolnay
4 years
@ManishEarth If at any point in the future we add another, I 100% welcome scrutiny over whether it is CORRECT but I reject (and will ban) the inevitable crusaders coming in with "how dare you believe you can write correct unsafe code, only the standard library can write correct unsafe code".
1
3
18
@davidtolnay
David Tolnay
1 year
[Cargo, JS]—who needs to think precisely about types or action inputs if it can just do what you "meant". Build_rs is Turing-complete so go wild [Buck2, Rust]—solid academic foundation, static build graph info unlocks abilities as game-changing as typing does for static analysis
1
1
16
@davidtolnay
David Tolnay
3 years
You can check out the public part of the code here:
Tweet media one
0
0
17
@davidtolnay
David Tolnay
2 years
@ekuber @theprincessxena `<-` is not legal syntax for binop with negative rhs. help: if you meant to write a comparison against a negative value, add a space in between `<` and `-` | 2 | let x = 0< -1; | ~~~
1
0
16
@davidtolnay
David Tolnay
3 years
@ekuber @timClicks Perceiving expert knowledge as the dominant axis in our work does a poor job setting anybody else up for success. I know of plenty of serious Rust experts who have never gotten themselves anywhere.
1
2
15
@davidtolnay
David Tolnay
4 years
@mgattozzi Stay tuned for something cool coming up on Tuesday.
1
0
16
@davidtolnay
David Tolnay
2 years
@payforexposure @pcwalton Patrick's observation holds if you plug in Language X = C++. Language X is not memory safe. As for me, not holding my breath for C++ to figure out how to be a better C++.
1
0
15
@davidtolnay
David Tolnay
4 years
@Sunjay03 If the code and target are truly fixed, the correct way to reflect that is to compile the binary and then delete the source code. That avoids giving the false impression that you can rebuild it later and get the same asm out of the UB code. If you do that, then sgtm.
0
1
12
@davidtolnay
David Tolnay
10 months
"The U.S. Cybersecurity & Infrastructure Security Agency (CISA), National Security Agency (NSA), Federal Bureau of Investigation (FBI), and cybersecurity authorities of Australia, Canada, United Kingdom, and New Zealand jointly developed this guidance"
Tweet media one
0
3
13
@davidtolnay
David Tolnay
3 years
@nick_r_cameron Cargo vendor for talking to crates​.io and resolving a toml manifest. Buck for all builds. Buck invokes rustc. Remote execution, distributed build caches, reproducible hermetic builds, C++/OCaml/Python depending on Rust libs, Rust depend on C++, good tooling to query build graph
1
0
13
@davidtolnay
David Tolnay
5 years
@mgattozzi XML is not a good fit for Serde and I have been rejecting feature requests that XML people want. I propose that you should be looking for an XML library with a good XML-specific derive macro, not hacks on hacks on Serde's derives.
0
0
12
@davidtolnay
David Tolnay
3 years
@ekuber @timClicks I would identify Niko's immense impact more with project management, imagination, negotiation, and trust than all-encompassing expert Rust knowledge. I would identify my impact more with time investment, creativity, chaos tolerance, taste and privilege than expertise.
1
0
11
@davidtolnay
David Tolnay
3 years
@utsl42 @withoutboats @awesomeintheory It's arguably worse. Writing correct unsafe Rust code is famously harder than writing correct C++ or C.
1
1
10
@davidtolnay
David Tolnay
3 years
@thingskatedid @DanielMicay @myrrlyn @code_squirrel @pavlixnet @Esper_Lily @sw17ch You've interviewed me and asked me this question! CV said "Rust, C++, Go, C, Java". Thanks for explaining this one -- I knew a bunch of differences but not this one. Can confirm it was kindly asked.
1
0
11
@davidtolnay
David Tolnay
3 years
@nick_r_cameron Yeah it's breaking in general. For example: trait T1 {} trait T2 {} default impl<T: T1> T2 for T {} fn f1(_x: impl T1) {} fn f2(_x: impl T2) {} fn main() { impl T1 for u8 {} f1(0); impl T2 for i8 {} impl T2 for i16 {} f2(0); //⟵ fail }
1
0
10
@davidtolnay
David Tolnay
5 years
@CuddleViper @oherrala @bascule 325 as of today, or just over 1% of crates.​io — courtesy of cargo-tally.
Tweet media one
Tweet media two
0
0
10
@davidtolnay
David Tolnay
3 years
@josh_triplett - Rustfmt is no good for generated code. I believe that I can do better. - It takes longer than 450ms to compile. - It doesn't build on a stable toolchain because it uses the compilers internal unstable syntax tree. - It is not published to crates.​io.
1
0
10
@davidtolnay
David Tolnay
4 years
@ManishEarth You need to reject the PRs to stop them from behaving this way. I saw you merged one in . I rejected because I agree with you.
2
0
10
@davidtolnay
David Tolnay
3 years
My previous ad hoc implementation could take 45 minutes for complex queries, using an algorithm that is effectively hopeless to parallelize short of reinventing a dataflow framework. New implementation based on differential-dataflow computes the same in 16 seconds on 32 cores.
1
0
10
@davidtolnay
David Tolnay
2 years
@benj_fry @pcwalton mem::forget (the function for leaking a value) used to be unsafe and documented as incorrect to call unless the value was already deallocated by some other mechanism, so using it for a leak would have been UB. It was quietly redefined to be safe later on.
2
0
10
@davidtolnay
David Tolnay
3 years
@algo_luca @a_hoverbear @m_ou_se I got the same email 3 weeks ago and I am glad to see they are still looking. ✊
1
0
9