P
Patrick Walton
pcwalton.github.io · Personal blog · on HN since 2013
Patrick Walton, a Mozilla engineer on Servo and Rust, writes about Rust language design, parallel layout, and GPU font rendering.
What HN saysHN links it for early Rust history such as typestate and garbage collection removal, and for his Pathfinder GPU rasterizer work.
53HN people shared it
43linked it in comments
16stories submitted
741story points
11 months agolast shared
2013people per year2026
Most-shared posts
- 1Revamped Parallel Layout in Servo7 people · 8 points · first shared 2014 · discussion on HN
- 2Removing Garbage Collection from the Rust Language (2013)7 people · 1 points · first shared 2022 · discussion on HN
- 3Pathfinder, a fast GPU-based font rasterizer in Rust6 people · 384 points · first shared 2017 · 101 comments on HN
- 4Removing garbage collection from the Rust language5 people · 242 points · first shared 2013 · 130 comments on HN
- 5Performance of sequential Rust programs4 people · 66 points · first shared 2013 · 26 comments on HN
- 6Typestate Is Dead, Long Live Typestate (2012)4 people · 16 points · first shared 2015 · 1 comments on HN
- 7Webrender talk 0220164 people · first shared 2016
- 8Pcwalton’s Plans for 20193 people · 2 points · first shared 2018 · discussion on HN
- 9Removing Garbage Collection from the Rust Language (2013)3 people · 2 points · first shared 2020 · discussion on HN
- 10Typestate is dead3 people · first shared 2018
- 11`Cxx-Async`2 people · 4 points · first shared 2022 · discussion on HN
- 12An Overview of Memory Management in Rust - pcwalton2 people · 1 points · first shared 2013 · discussion on HN
- 13The new borrow check in a nutshell2 people · first shared 2013
- 14Safe Manual Memory Management1 people · 8 points · first shared 2013 · discussion on HN
- 15A hard case for memory safety1 people · 4 points · first shared 2013 · discussion on HN
What HN people wrote when they linked it
steveklabnik · 2022-03-31
Amazingly, typestates used to be a headline feature of Rust, in the very, very, very old days. Like, "Wow, Rust is the language that's going to make typestates mainstream!" was a thing people thought when seeing it.
Eventually it was removed. https://pcwalton.github.io/2012/12/26/typestate-is-dead.html
sercand · 2019-03-19
https://bugzilla.mozilla.org/show_bug.cgi?id=909760 and https://bugzilla.mozilla.org/show_bug.cgi?id=1104146 are the issues for downloading which are 4 and 6 years old.
Chrome and Safari support keyboard multimedia keys to play/pause video and audio which firefox does not. Picture in Picture is not available on Firefox.
Pinch and double tap gestures to zoom are not available. Scrolling does not follow system conventions like overflow kinetic scrolling.
https://pcwalton.github.io/2018/12/07/plans-for-2019.html mentions about excessive power consumption on webrender.
metajack · 2018-08-13
If you're interested in this, I recommended reading about Patrick Walton's work on Pathfinder: https://pcwalton.github.io/2017/02/14/pathfinder.html
aturon · 2015-01-09
This is a very old post, but you can encode many uses of typestate pretty easily: http://pcwalton.github.io/blog/2012/12/26/typestate-is-dead/
It'd be great for someone to write a more up-to-date version of this post!
shiomiru · 2025-12-11
The greatest mistake IMO is the way float state leaks out of blocks, as this is both extremely unintuitive and undesirable for performance reasons.[1] Floats should've been restricted to inline formatting contexts, with all in-flow blocks behaving as if they had `clear: both' set.
I also don't understand why they never specced the (much simpler) `text-align: -moz-left/-moz-right/-moz-center' which already had precedent in HTML with `<div align=left/right/center>'. It's the saddest part of the "center a div" saga, all the W3C had to do to fix it is to assign a standard keyword to a feature that everybody already implemented, but to this day it still hasn't happened.[2]
[1]: https://pcwalton.github.io/_posts/2014-02-25-revamped-parallel-layout-…
[2]: After many long decades, they did finally specify block-level `justify-items'. Two problems: a) it's backwards-incompatible with text-align, b) it still doesn't work in Gecko.
NobodyNada · 2025-02-28
> Rust has data race prevention not because it’s a good idea but because the whole language falls apart without it.
In terms of the design goals and evolution of the Rust language, this is exactly backwards. Rust was originally conceived as a garbage-collected, green-threaded language designed for concurrent programming -- think something similar to Go but with a stronger type system and no data races. The ownership model was created, first as foremost, not for memory safety but to prevent data races; and, more broadly, to help programmers reason about the correctness of their code.
Midway through development, as people started using the language & getting a feel for it, the language designers realized that the ownership model was powerful enough to express not just data race freedom but full memory safety without needing a GC (some writing from this stage in Rust's development: https://smallcultfollowing.com/babysteps/blog/2013/06/11/on-the-connec… https://pcwalton.github.io/_posts/2013-06-02-removing-garbage-collecti… So they removed the GC, and that decision positioned Rust where it is today: a nicer, memory-safe "C/C++ competitor", popular for systems code where the performance overhead or runtime complexity of a garbage collector is considered unacceptable.
kibwen · 2024-09-03
The Rust compiler doesn't produce warnings out of zealotry, but rather as a consequence of pre-1.0 historical decisions. Note that Rust doesn't use any syntax in pattern matching contexts to distinguish between bindings and enum variants. In pre-1.0 versions of Rust, this created footguns where an author might think they were matching on an enum, but the compiler was actually parsing it as a catch-all binding that would cause any following match arms to never be executed. This was exacerbated by the prevailing naming conventions of the time (which you can see in this 2012 blog post: https://pcwalton.github.io/_posts/2012-06-03-maximally-minimal-classes… (note the lower-cased enum variants)). So at some point the naming conventions were changed in an attempt to prevent this footgun, and the lint was implemented to nudge people over to the new conventions. However, as time went on the footgun was otherwise fixed by instead causing the compiler to prioritize parsing enum variants rather than bindings, in conjunction with other errors and warnings about non-exhaustive patterns and dead code (which are all desirable in their own right). At this point it's mostly just vestigial, and I highly doubt that anybody really cares about it beyond "our users are accustomed to this warning-by-default, so they might be surprised if we stopped doing this".
snovv_crash · 2022-09-21
https://pcwalton.github.io/_posts/2013-06-02-removing-garbage-collecti…
This came 2 years after C++11 was finalized, which introduced RAII memory management, threads, range loops and much more, and is the basis for modern C++.
Of course, there are pros and cons to keeping backwards compatibility with old code. Personally I think it's an amazing technical achievement that the same code written in 1987 still works. Particularly for numerical work there are a lot of libraries that would be a massive pain to rewrite correctly, just getting them off of Fortran was an achievement.
In terms of new and old standards coexisting in the same code, of course it isn't preferable, but it is possible which can enable many use cases, eg. in place upgrades. Forcing rewite-the-world is what caused the Python 2 --> 3 migration to be such a mess.
And if you really don't want old features, there are linter rules and compiler warnings which do a great job for this.
Const-me · 2021-02-04
> which I believe WebRender targets
OpenGL 3.0 and OpenGL ES 3.0: https://pcwalton.github.io/slides/201808-webrender/
They both support texture arrays.
> texture layer dimensions have to be specified up-front
Indeed, but it's possible to create another larger one, and copy layers between arrays within GPU.
It's the same idea as std::vector on CPUs, most heaps can't resize memory either, they instead allocate new blocks and copy.
There're two wins with texture arrays.
1. Removes area limitation. 2D textures are often limited to rather small size, like 2k^2 pixels. Same limitation applies to arrays, but with multiple layers their total area is only limited by VRAM size. That 2D library I've linked above renders arbitrarily complex 2D graphics with only 2 draw calls, regardless on how many sprites or font glyphs are used in the scene. Two because front-to-back opaque followed by back-to-front translucent.
2. These packing algorithms often scale worse than linearly with available area or count of sprites on the atlas. Using multiple layers of the array takes care of that, new sprites are only packed into the last layer, and layer size is never too large.
Chris_Newton · 2015-08-06
Pretending that modern type systems provide anything near an adequate control of effects is misleading at best. Controlled side effects are an excellent goal
I completely agree. But, as I suspect you’d agree, it’s not an easy problem even to specify the behaviour we would ideally like to see here.
For example, one of the important things about side effects is not only their existence or lack thereof, but their ordering (e.g. you must write to a socket only after you open it and only before you close it).
When I’m designing software, I tend to think of effects at three distinct levels: can effects happen at all, what relative timing (i.e., ordering) do they need to have, and what absolute timing do they need to have?
The most basic question is whether certain effects or effects related to a certain resource happen at all. This includes distinguishing pure functions from code with side-effects, but it could also be about, say, having a function that appears pure from the outside but is implemented using mutable state internally. If that state is stored in internal memory that is only acquired and released within that function and no reference to it is accessible outside the function, then the scope of the effects is limited and the usual advantages of pure functions still apply viewed from outside. If the state is stored externally, say in a file or database, then potentially it could interact with other parts of the system because they could also acquire a reference to it…
keeperofdakeys · 2024-03-06
The funny thing is that rust used to have things like garbage collection. For the kind of language Rust wanted to be, removing them was a good change. But there could always be a world where it kept them.
https://pcwalton.github.io/_posts/2013-06-02-removing-garbage-collecti…
mikepurvis · 2023-11-01
Interesting that GC was originally part of rust and got un-bolted:
http://pcwalton.github.io/_posts/2013-06-02-removing-garbage-collectio…
throwup · 2022-10-12
Rust was still changing quite a lot in 2013. It sounds like you used it back when it had a garbage collector, baked-in green threads, and "~" and "@" sigils everywhere. Rust 1.0 may as well be a completely different language.
Here's a blog post from the same year that proposed removing the garbage collector.
https://pcwalton.github.io/_posts/2013-06-02-removing-garbage-collecti…
ssokolow · 2022-06-03
Here are a couple of examples of the changes that were made in the two or three years before Rust 1.0 if anyone wants to read more:
https://github.com/rust-lang/rfcs/blob/master/text/0230-remove-runtime…
https://pcwalton.github.io/2013/06/02/removing-garbage-collection-from…
chrismorgan · 2021-09-23
I don’t know the current situation especially as regards WebRender in Firefox, but WebRender did box-shadow in a shader back in 2015: https://pcwalton.github.io/2015/12/21/drawing-css-box-shadows-in-webre…
I don’t really know what I’m talking about with all this stuff in much depth; I’m mostly reporting what I’ve heard and learned over the years of watching from the outside and keeping half an eye on things, but never quite learning about them in detail.
Since we’re talking box shadows and performance, https://raphlinus.github.io/graphics/2020/04/21/blurred-rounded-rects.… is also some fun work in the space.
creata · 2020-12-23
Rust used to have a lot of stuff built into the language, including garbage collection![0] I think that a long time ago they chose to move stuff out into libraries so that Rust could be a serious competitor to C++.
https://pcwalton.github.io/2013/06/02/removing-garbage-collection-from…
mrec · 2019-07-19
BTW, were you aware that links to your older blog posts (e.g. [1]) were broken? Looks like you just removed "/blog" from the path, but you don't seem to be doing anything else with it.
[1] http://pcwalton.github.io/blog/2017/02/14/pathfinder/
twic · 2019-07-10
Or maybe a heavyweight one. I note that the clang annotations refer to "typestate", which was a mechanism that existed in primordial Rust, but which was dropped because it was unnecessarily complicated:
http://pcwalton.github.io/2012/12/26/typestate-is-dead.html
Although to be fair, clang's version is a highly limited particular case of typestate, with one axis of state with three values, rather than a general heavyweight typestate mechanism.
epage · 2019-01-29
I wonder if this is due to not using the native compositor which they are looking at fixing this year.
See "Adding support for native OS compositors to WebRender" at https://pcwalton.github.io/2018/12/07/plans-for-2019.html
sriram_malhar · 2018-12-24
This is precisely the problem addressed by typestates and session types. Each state has a unique type, and in that state, one can only call the appropriate functions.
Interestingly, Rust used to have typestates in its very early incarnation.
See: https://pcwalton.github.io/2012/12/26/typestate-is-dead.html
wycats · 2018-02-09
For slightly more context, I wrote the first lines of Rust code for Skylight as a spike at the end of 2013, and joined the Rust core team more than a year later. :)
I was largely inspired by a blog post in June 2013 by Patrick Walton: Removing Garbage Collection From the Rust Language[1]
[1]: http://pcwalton.github.io/blog/2013/06/02/removing-garbage-collection-…
ohazi · 2018-01-22
"Crappy pessimistic heuristics"
Are you talking about the borrow checker from half a decade ago? [0] Have you used the language since then? This is FUD -- it's really not hard to get code past the borrow checker anymore. Maybe every thousand lines or so you'll need to add a block or pull a temporary variable out of a one-liner, but the compiler basically tells you exactly what to do when something like that is relevant.
[0] https://pcwalton.github.io/blog/2013/01/21/the-new-borrow-check-in-a-n…
raphlinus · 2017-12-22
I don't want to overstate it; I've written a lot of SIMD in my life too. If you've got audio processing that needs to run in a realtime thread, I can see how SIMD is appealing, because we don't really have mechanisms to achieve realtime on GPU (yet). However, for a lot of seriously heavy computation, it seems like doing it on the GPU is a win. For the cases where memory transfer back and forth to the GPU is expensive, even integrated GPU should offer significantly more computational resources than even AVX-512.
One of the use cases I'm thinking of is font rendering, where I published a SIMD-heavy prototype a couple years ago, and it's blown out of the water by a newer GPU-based approach: http://pcwalton.github.io/blog/2017/02/14/pathfinder/
robin_reala · 2017-09-22
You’re in luck: https://pcwalton.github.io/blog/2017/02/14/pathfinder/
As HN resident pcwalton says: “The immediate next step for Pathfinder is to integrate into WebRender as an optional accelerated path for applicable fonts on supported GPUs.”
Scaevolus · 2017-06-22
Did you see this? http://pcwalton.github.io/blog/2017/02/14/pathfinder/
dochtman · 2017-06-08
This reminds me of Pathfinder:
http://pcwalton.github.io/blog/2017/02/14/pathfinder/
How is it different/similar?
niftich · 2016-08-03
A slide deck from February which explains how Webrender works is available from the developers [1].
[1] http://pcwalton.github.io/slides/webrender-talk-022016/
panic · 2016-05-30
the_why_of_y · 2016-04-23
Assuming you're talking about WebRender?
http://pcwalton.github.io/slides/webrender-talk-022016/
... which is notable because it is not immediate mode but the first retained mode renderer in a browser. Also, they used Rust to cut down on the time spent debugging threading issues.
pritambaral · 2016-02-25
"Glyphs—rasterized on CPU with Quartz or FreeType (for now)"[0]
0: http://pcwalton.github.io/slides/webrender-talk-022016/