14,081 karma · joined Mar 7, 2014 (12y ago) · 1,887 submissions
comment 3y ago · link · parent
392.
Raph’s Reflections and Wishes for 2023(raphlinus.github.io ↗)
4 points · by raphlinus · 3y ago · 1 comment
comment 3y ago · link · parent
comment 3y ago · link · parent
This is not conceptually a difficult problem, you can just shape all possible substrings between candidate line breaks to get their widths, at which point Knuth-Plass will give the optimal line breaks (relative to your objective function). But given that shaping is expensive, you really want to avoid that in the 99.99% or so cases where the width of the word isn't altered by other words beyond space boundaries. That's what the "safe to break" logic is about - letting you know when you can make that assumption, as opposed to needing to reshape to get the precise metrics.
[1]: https://en.wikipedia.org/wiki/Nastaliq#/media/File:Khatt-e_N...
comment 3y ago · link · parent
The first system I know of that does solve this very well is DirectWrite. Sergey Malkin describes the solution here: https://github.com/harfbuzz/harfbuzz/issues/1463#issuecommen...
It sounds like Chromium has since also adapted the "safe to break" API. Great to see people engaging these hard problems!
comment 3y ago · link · parent
It does look like a very good year coming up! I'm writing a reflection/wishes post as we speak.
comment 3y ago · link · parent
Btw, this is one of the reasons I feel a bit burned by MoltenVK, as it happily and silently translates correct SPIR-V into MSL that's lacking the correct barriers. In my experience, GPU translation layers are some of the leakiest abstractions around.
[1]: https://raphlinus.github.io/gpu/2021/11/17/prefix-sum-portab...
comment 3y ago · link · parent
Programming GPU compute outside CUDA is still quite painful; the developer experience of tools is terrible and the ecosystem has a lot of catching up to do. I'm most bullish on WebGPU going forward, but there are definite growing pains.
comment 3y ago · link · parent
There's tons of juice left on the CPU side. Again I recommend Metamath Zero (which is somewhat of an opposite direction as HoTT), as it's able to check the entire Metamath proof database in a few hundred milliseconds. This is orders of magnitude faster than most other proof systems.
If you did want to manipulate trees on the GPU, then my stack monoid work[1] might be a good basis for it.
Of course, a whole nother direction is to use AI to develop proofs, which is a fascinating and growing area (see Holophrasm[2] and DeepMind work[3]). That of course runs on the GPU.
[1]: https://arxiv.org/abs/2205.11659
[2]: https://arxiv.org/abs/1608.02644
[3]: https://www.deepmind.com/publications/proving-theorems-using...
comment 3y ago · link · parent
* WebGPU will ship but early adoption will be slow.
* Stable Diffusion will run on WebGPU.
* Rust adoption will accelerate rapidly; C++ increasingly for legacy code only.
* Rust will also become an official side in the Stupid Culture Wars.
* Twitter.com will become a pale shadow of its former self (also having become a side in the SCW).
* Mastodon will be big. It will have growing pains but deal with them reasonably well.
comment 3y ago · link · parent
Of course I admit that Lean is pretty much cleaning everybody else's clock, but it's not clear to me that's because of the inherent superiority of type theory over set theory. It's equally plausible that it's just well engineered, and there's been a lot more attention on automating type theory by computer scientists.
comment 3y ago · link · parent
comment 3y ago · link · parent
comment 3y ago · link · parent
[0]: https://www.cs.utexas.edu/users/EWD/transcriptions/EWD03xx/E...
comment 3y ago · link · parent
Actually I have an even more amazing artifact. He wrote out the entire book "Predicate Calculus and Program Semantics" as a manuscript, beautifully formatted two pages to a letter-sized sheet, page numbers and all. It is nearly perfect but does have a few crossed out bits. I can't find that anywhere online, and just sent an email to the EWD archive. I'd be very surprised if I have the only extant copy, but if so I will certainly get it properly preserved.
comment 3y ago · link · parent
comment 3y ago · link · parent
comment 3y ago · link · parent
413.
An extensive letter from Edsger Dijkstra to my 19 year old self (1989)(mastodon.online ↗)
310 points · by raphlinus · 3y ago · 71 comments
comment 3y ago · link · parent
bool add_will_overflow(int32_t a, int32_t b) {
uint32_t c = (uint32_t)a + (uint32_t)b;
return (((uint32_t)a ^ c) & ((uint32_t)b ^ c)) >> 31;
}
That produces the following assembly (see Godbolt[2]): lea edx, [rdi+rsi]
mov eax, edi
xor eax, edx
xor esi, edx
and eax, esi
shr eax, 31
ret
In Rust, you can write a.checked_add(b).is_none() which produces the following assembly[3]: add edi, esi
seto al
ret
A fun fact about this code: the overflow flag which is set by the add instruction and then harvested dates back at least to the 8080 (almost 50 years ago) and is not present in vanilla ARM. However, Apple Silicon has it as an extension, to make life easier for Rosetta 2 binary translation[4]. So when you do get to use this shorter code sequence, be thankful of the effort that chip designers put in to make it execute efficiently.I expect the C23 built-in functions will perform as well as Rust here, which is a win both for ergonomics (you can't really consider the current state of "will a+b overflow" to be discoverable) and performance.
[1]: https://mastodon.online/@raph/109535617953722719
[2]: https://godbolt.org/z/17zMsWjYv
comment 3y ago · link · parent
comment 3y ago · link · parent
comment 3y ago · link · parent
I've lately become slightly addicted. The production style is appealing, and the stories compelling. The fact that people like Logan Paul are able to pull off these scams with little accountability says a lot about our modern times. I definitely recommend Coffeezilla.
comment 3y ago · link · parent
Regarding collaboration with Freya, if she is open to it, please get in touch. I do have some ideas.
[1]: A New Shape Control and Classification for Cubic Bézier Curves, Yang and Huang, 1993, PDF cache: https://github.com/paperjs/paper.js/files/752955/A.New.Shape...