Better HN
topnewbestaskshowjobs
Log inSign up

raphlinus

14,081 karma · joined Mar 7, 2014 (12y ago) · 1,887 submissions

I do research on fundamental UI technology and 2D graphics, with a focus on Rust and fonts. @raph@mastodon.online
Submissions

comment 3y ago · link · parent

One of my main resolutions is not to write a programming language for GPU compute shaders. I've written a bit more about my 2023 wishes here: https://raphlinus.github.io/personal/2022/12/31/raph-2023.ht...

392.

Raph’s Reflections and Wishes for 2023(raphlinus.github.io ↗)

4 points · by raphlinus · 3y ago · 1 comment

comment 3y ago · link · parent

Aw thanks. It remains a life goal to write a book on 2D graphics, including text layout and rendering, but I don't see any way to find time for it in the next year at least. Meanwhile I do have some pretty exciting stuff lined up, including some writing (just not a book) and will publish a blog post on my 2023 plans tomorrow.

comment 3y ago · link · parent

By "shaping across space" I mean that the shapes of the words might be very different depending on whether there's a space or whether they're on second lines. That basically doesn't happen in Latin script (though one could possibly imagine a very fancy cursive or a stunt). So I'll give an example in Nastaliq. One of the example images[1] on Wikipedia is "خط نستعلیق" (meaning "Nastaliq script") where the "خط" is tucked under the other word when they're on the same line. There's a space between them, so it's a valid line break. If they were on two separate lines, the total width would be a lot wider because of that shaping behavior.

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

No. Most line breaks in English are at spaces, and the Computer Modern fonts don't have any complex shaping behavior across spaces (it's mostly complex scripts such as Nastaliq that have this behavior). I haven't checked to see whether it takes into account the kerning value with the hyphen added.

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

A clarification: Druid proper uses the text layout capabilities of the platform (DirectWrite on Windows, Core Text on macOS, and Pango on Linux), while Xilem does indeed use Parley. Lapce uses a fork of Druid that, as parent states, uses Parley for text layout.

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

Sure! I have blogged about this[1], but I'll summarize here. Basically a barrier helps you do a "message passing" pattern, where one workgroup prepares some data then sets a flag, and another workgroup can read the flag and then read the data from the first workgroup. However, in Metal (and hence WebGPU) the barriers aren't powerful enough to guarantee you won't see stale data. Thus, to do prefix sum on Metal, you need to at least two dispatches, one to aggregate reductions over partitions, then another to do the sum within a partition. That's less efficient, both because of the dispatch overhead, and also because you need to read the data at least twice. You also need a bunch of different versions of your shaders to handle different problem sizes, which is really annoying (in fact, Vello can't handle more than 64k path segments until I write the larger version). Vulkan, CUDA, and DirectX12 (even DirectX11) can all do this; it's one of the ways in which Metal is an inferior basis for doing GPU compute.

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

DirectX12 has ok compute capabilities, but is increasingly being left in the dust by Vulkan. It doesn't have pointers or a memory model, but it does have device scoped barriers (which Metal lacks), so you can do things like single-pass prefix sum (monoid scan) operations, which Metal and WebGPU can't. Also, the Nvidia "cooperative matrix" operations (which access the "tensor cores") exist in CUDA and Vulkan but not DirectX12.

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

Do not nerd snipe me!

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

Nice work finding this indeed! This sounds like it could become a nice story for Coffeezilla. It's increasingly looking to me like it's an outright scam. Strange that it's for such low stakes as academic prestige, usually they go straight for the money.

comment 3y ago · link · parent

From my world:

* 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

I think you're overstating the case against ZFC as a practical basis for proof formalization. The Metamath project has got pretty far even without powerful tactics and so on, and has an appealingly simple kernel. That work continues in Mario Carneiro's Metamath Zero, which does add some pretty basic automation, and is able to prove a simple C-like compiler among other things.

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

As a followup, this proof has now been declared as fatally flawed by John Carlos Baez, with some additional analysis by Noam Zeilberger. The argument is beyond my personal mathematical knowledge, but I would consider this a pretty definitive verdict.

[1]: https://mathstodon.xyz/@noamzoam/109567981846531700

comment 3y ago · link · parent

I love how "ski" is such an outlier for highly upvoted TLDs. Either the Hacker News crowd really loves skiing, or ciechanow.ski is responsible. I bet there is a similar story for most of the other TLDs on the list, but don't recognize any of the others (except for home.cern which is pretty obvious).

comment 3y ago · link · parent

Here's a fairly recent paper on techniques to reduce the aliasing: https://www.dafx.de/paper-archive/2016/dafxpapers/20-DAFx-16...

comment 3y ago · link · parent

How dare you say that!. Humility was an integral part of his brand. So much so that he titled his Turing Award lecture "The Humble Programmer"[0].

[0]: https://www.cs.utexas.edu/users/EWD/transcriptions/EWD03xx/E...

comment 3y ago · link · parent

That certainly sounds like him!

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

Yes, we were corresponding for a while, this wasn't just a response to a cold contact. My dad, who was quite a promoter and very invested in the idea of me being a gifted kid, reached out to a bunch of computer scientists, and several responded. I have some of those letters but haven't done any careful organizing of them. As I mentioned in the memorial note, Dijkstra would go on to invite me to the Marktoberdorf summer school the following summer, where I got to spend time with him, Tony Hoare, Greg Nelson, Robert Constable (of Nuprl fame), and others.

comment 3y ago · link · parent

This seemed strangely familiar.

Nice writeup though! I like the way it derived the logic rather than just presenting the solution.

comment 3y ago · link · parent

Indeed. I think we've lost a little something from that era, though, where it took some effort to reach out, sending a letter on paper. These days, it's super easy to contact someone on social media or whatever, which is very convenient and efficient. Dijkstra to me really personified a slower, deeper way of interacting.

comment 3y ago · link · parent

And to add more continuity to the circle, here is a short memorial I posted to Advogato on Dijkstra's death, just over 20 years ago: https://web.archive.org/web/20170629060656/http://www.advoga...

comment 3y ago · link · parent

I don't know for sure, but I suspect so. He was meticulous in so many ways, including his thought, his language, and of course his handwriting, so it seems entirely in character that he would redo a draft to make it look flawless.

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

The addition operator just landed in Rust 1.66 (checked_add_signed[1]), but the subtraction one it looks like you'd need to roll your own.

[1]: https://github.com/rust-lang/rust/issues/87840

comment 3y ago · link · parent

Oops, you're right. Too late to edit, sorry about the confusion.

comment 3y ago · link · parent

I posted overflow checking of signed integer arithmetic as a puzzle yesterday[1]. I got some good responses but none quite as minimal wrt number of instructions as my own solution:

    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

[3]: https://rust.godbolt.org/z/36Ta9oP1P

[4]: https://news.ycombinator.com/item?id=33635720

comment 3y ago · link · parent

Oh, I wouldn't worry. What would make a collab video cool is not dazzling people with mathematical BS, but rather visually showing the geometric and physical principles behind the splines, especially their relationship with bending elastic strips. If you want to have a chat to brainstorm (even if nothing comes of it), my contact info should be pretty easy to find.

comment 3y ago · link · parent

You're remembering right, and the accusation is in this video 3 weeks ago where he has Marc Cohodes accusing Bloomberg of spiking the story because it would be bad for (crypto) advertisers. A good news organization doing actual investigative journalism would have been able to get this story, if nothing else by following up tips such as these. A question which remains unanswered is: why didn't they?

[1]: https://youtu.be/FDqhM7vHR2o?t=885

comment 3y ago · link · parent

Coffee's recent interview on the Lex Fridman podcast gives more background to these investigations, and specifically why you're not seeing them in mainstream media. Basically, Coffee is taking a lot of risk, as the scammers apply a lot of pressure, including legal threats and not so legal threats, to suppress knowledge of their wrongdoing. Mainstream media tends to give in to these threats, but Coffee is in a somewhat unique position of being able to take them on.

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

Ooh, the Chebyshev basis is neat. I hadn't seen exactly that before. It reminds me a lot of the "shape control" technique[1] which is also similar to a basis function approach but has a bit of linear solving. Essentially, you get one point (usually at t = 0.5), and also the direction but not magnitudes of the tangents at the endpoints (G1, not C1). This is one of the better-performing existing techniques for offset curve, though does have stability problems (in particular, nasty behavior for a symmetric "S" curve).

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...

1
131415
63