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 7y ago · link · parent

I found this really worth watching, as much for the sociological commentary about the way modern mathematics is done as for the presentation of the program (and the latter resonates strongly for me).

One of the more interesting bits for me was in the Q&A, where Prof Buzzard was asked about alternatives to Lean. Lean is the most evolved of the dependent-typed calculus of constructions provers, but two other approaches might work. One is univalence, which is sexy, but Prof Buzzard observed that they haven't actually got much done in their system.

The other is set theory, which is more familiar and approachable to working mathematicians, but the systems out there lack automation. He didn't mention Metamath by name, but that's currently the most developed such system, and they have managed to get a lot done, either in spite of or because of the lack of type theory sexiness of the foundations.

So the question I'd love to see answered is whether automation is inherently easier in type theory, or whether it might be possible to build automation for a set theoretical approach. John Harrison gave a talk last year at AITP on the topic, but I haven't heard much more of this.

comment 7y ago · link · parent

I'm not fluent in any language (except maybe English), but this was my job on Android for about five years, and I still have my hand in. I got very good at being able to spot various forms of incorrect rendering, and of course called in the experts when needed.

One of my favorite examples was Devanagari shaping. In the word ट्विटर (tvitar = Twitter), does the "i" matra shape before the "tv" it in the middle of it? In my sample, people accepted it either way (and you'll see both depending on font), but there are lots of examples where one is just wrong.

comment 7y ago · link · parent

I don't get to the south bay often, but sounds like it might be good to have a little compositor meetup. I can certainly vouch for pcwalton's interest and knowledge in the topic :) Follow up by email?

comment 7y ago · link · parent

Looking over this stuff, I get an uneasy feeling. X was a brilliant solution to problems 35 years ago, where you barely had enough memory for a full frame buffer and the graphics model was primitive (no antialiasing or transparency). From what I've seen, Wayland is a good solution for the model maybe 15 years ago, where you're willing to accept the frame-and-a-half latency hit from having a compositor in the path.

Basically, my question is whether anybody is working on a solution for the hardware we have today, where there are hardware overlays, the GPU throughput is orders of magnitude higher than what's needed to composite a desktop, but we still care about memory bandwidth, largely because all of resolution, bit depth, and frame rate is still going up. And you really want to be able to schedule every pixel that gets presented with a high degree of timing accuracy.

I've become familiar with Windows, but feel like it's a bunch of hacks. They will promote a window to an overlay, but it's all a heuristic, and I'm pretty sure latency will stutter while it does the transition in and out. And the new flip-model stuff actually regresses the ability to do smooth window resizing.

I'm not even sure macOS is working on lowering latency. I haven't seen any mention from them of hardware overlays.

Most of the attention these days seems to be in the VR/AR space, where latency is obviously important, and there's more of a green field with respect to legacy compatibility, but I'd love to see this problem space actually solved on the desktop. Doing this right is not easy - it probably requires some form of soft real time discipline across the graphics stack (including GPU scheduling) so you can race the beam.

comment 7y ago · link · parent

I just watched the YouTube link, and it's amazing! I've been toying with making some of my own video content, and this is inspiring. There's only so many hours in the day though.

comment 7y ago · link · parent

David Murray (aka the 8-bit guy) has a plan to build the "Commander X16", a new 6502 based computer that is philosophically similar to a VIC-20 but has more RAM (2MB), a higher clock (probably 8 MHz) and an FPGA to do VGA video. It might not be on the radar of people here because of some odd choices, like using a Facebook group as the primary discussion forum.

comment 7y ago · link · parent

You could argue that much open source work is like volunteering to serve food at the local country club. Sure, you're feeding hungry people, but there is something just a little bit wrong about that.

Personally, I'm getting more paid open source work than I have time for, all based on permissive licensing, but I might be something of an outlier.

comment 7y ago · link · parent

Fun fact: floor(x + 0.5) rounds 0.49999997 to 1.0 (this is 32 bit floats, the same principle applies to 64). Most libraries have slower than ideal round conversion because of historical dross; modern chips have a very fast SIMD round instruction but its behavior doesn't exactly match libc round. See https://github.com/rust-lang/rust/issues/55107 for a deeper discussion.

comment 7y ago · link · parent

It's completely fair though, and I wouldn't want people trying to use druid while really basic functionality like menus is still being worked on. The only way I would recommend druid is if people want to roll up their sleeves and help build the toolkit.

If it's still dismissed in six months to a year, that would be sad.

comment 7y ago · link · parent

I can think of a bunch of stuff that has moved or is moving from third party crates into the standard library: parking_lot, hashbrown, (minimal) Future trait. But I agree that no crate has moved wholesale into the standard lib.

comment 7y ago · link · parent

No worries, it was read with offense I didn't take. I agree, designing a good random number API is in fact hard. I just think we can give developers a better out-of-the-box experience.

comment 7y ago · link · parent

Probably could have worded it better. I didn't mean, "only use a little bit of async," I agree that doesn't make sense. I meant, "use async if your problem really needs it, otherwise avoid it."

comment 7y ago · link · parent

Depends on the use case. I'm thinking about GUI, where on Linux you can write code that links against (say) Gtk, and thus can pull in lots of libraries while the executable itself is tiny. With the current state of the Rust ecosystem, you basically have to build the GUI toolkit and bundle it with your app.

comment 7y ago · link · parent

Right, I see your point here. There are non-trivial issues that need to be worked out, which I'm sure is one reason it's not in the library yet. Another (mentioned elsewhere) is that it takes time to converge on what a good API might look like.

comment 7y ago · link · parent

I admit, design of a proper random number library API is tricky, and experience from deploying rand will no doubt be invaluable. The point I was trying to make is that some use cases require sophistication such as being able to choose different algorithms, but a lot of the times rand shows up in a build time histogram, it's just because the user wanted some pretty good random numbers; a much simpler API would suffice.

comment 7y ago · link · parent

Since stdlib and compiler releases are tightly coordinated, that shouldn't be a problem, no?

comment 7y ago · link · parent

To a very large extent, we already have this with `fn foo(foo: &dyn T)` (or `foo: Box<dyn T>` for the owned version). What I would find even more interesting is the compiler much more aggressively factoring out the common code from the multiple instances, ideally compiling it only once and putting only that one version in the binary.

comment 7y ago · link · parent

In my post, I specifically call on proc-macro support (syn and quote) plus rand (not all of rand though, just the "give me a random number" functionality that comprises 99% of the use cases but 10% of the implementation complexity) to be added to the Rust standard library. But I feel these are particularly justified because they're already present, just not accessible. Overall, I think Rust's "batteries not included" approach is a good tradeoff.

comment 7y ago · link · parent

I talk about this a bit, I'm in favor of at least medium granularity crates, but if they break down into smaller features, where different use cases will meaningfully choose different sets of features, use feature gates. So, for example, you might have a "string formatting utilities" crate with a "left-pad" feature. (Note: this particular example is unlikely because the `format!` macro in the standard library can do it just fine)

comment 7y ago · link · parent

Performance culture has you measure the actual performance implications, then make an informed decision. Is the code on a performance-critical path? Maybe some of your serialization code is, but it's extremely unlikely that a dynamic dispatch when parsing command line args is the reason your app is slow. Also be aware that highly inlined code does nicely in microbenchmarks but might have significantly negative performance implications in a larger system when it blows out the I-cache.

comment 7y ago · link · parent

This reminds me of a person who somehow managed an invitation to give a presentation at UC Berkeley on database compression in 1993, with similar levels of snake-oil. I remember one of the funnier moments, a theme of the presentation was how there were more and more large data sets out there, including the Library of Congress. In a burst of enthusiasm, the presenter gushed about how they even had a Stradivarius violin in their collection. I turned to my friend and said, "well, I can imagine how to do data compression on that, but the decompression is going to be hard."

The actual technology was just a variant of Lempel-Ziv, and the claims about lossless compression were just hiding the entropy by not counting a huge dictionary off to the side. Even so, there were claims that this result "extended information theory" and the patterns found could be the basis of learning.

The presenter had climbed in their regional market, and gotten a puff piece in a business magazine, but obviously the grad students at UC Berkeley weren't buying it. The presenter's startup didn't go anywhere, but they have had a successful career, and are now a VP at Gartner.

I guess the lesson is that there's a network that runs on technical expertise and ability to deliver results, and a parallel network that runs on bullshit and the ability to convince people. There's a lot of money and power in the second network, and it intersects with respected, established institutions. Grant seems to be playing that game masterfully, and the publicity from being publicly attacked at a "Black Hat" conference plays into his hands beautifully. Maybe Gartner will be hiring?

comment 7y ago · link · parent

It's important to make the distinction between subpixel positioning and subpixel (RGB) rendering. I'd personally say yes to the former, even at high dpi, and no to the latter if you're on a mobile device. The kerning errors you get from quantizing the position of glyphs to integer pixels are, to my eyes, a noticeable degradation of quality.

comment 7y ago · link · parent

It's not mandatory. There should be good rope implementations already, though. If you're in Rust there's ropey and at least one other pretty good one.

On modern computers, you can get away with a flat buffer of text (not even a gap buffer) for documents up to a few megabytes. I don't really recommend a gap, because it adds complexity and doesn't help with the worst case, though of course it cuts your average case down.

If you're going for simpler than a rope, my recommendation is array of lines. You have to do logic to split and fuse lines (for example, when backspacing over a newline), but it's not too bad. The only thing they don't do really well is single long lines.

I don't recommend piece tables. They have superb performance on first load, but then fragment. The reason I'm such a huge fan of ropes is that they perform excellently in the worst case - long edit sessions, long lines.

Best of luck!

comment 7y ago · link · parent

Right, and if you're doing processing of ASCII code points (this is 95% of Markdown parsing, for example, the major exception being case folding and Unicode whitespace), then it's just as convenient to do those in UTF-8 as any other representation.

comment 7y ago · link · parent

Sure. I guess what I'm trying to say is: when do you care about code point boundaries at all? In my experience, it's actually fairly rare. If you're drawing text, you care about the result after shaping. If you're moving the cursor, you care about grapheme cluster boundaries. If you're doing stuff like sorting and collation, you should use specialized Unicode libraries that get this stuff right. When is the last time you wrote code that really needed to iterate Unicode code points specifically?

comment 7y ago · link · parent

Yes, the variable length nature of UTF-8 generally means more hard-to-predict branches. But sufficiently clever programmers can find ways around that, see Lemire's work on using SIMD to validate UTF-8 very quickly: https://lemire.me/blog/2018/05/16/validating-utf-8-strings-u...

comment 7y ago · link · parent

I would go further and say that UCS-4 is also a variable length encoding, mostly because of emoji and its endearing ZWJ sequences, not to mention the encoding of flags as two Regional Indicator Symbol codepoints (both in the astral plane, of course), which makes Unicode not self-synchronizing.

So the idea of ever having a fixed-length encoding for Unicode is basically impossible now. Best to just use UTF-8 for everything and logic to group it in to code points, grapheme clusters, or whatever other granularity is needed.

comment 7y ago · link · parent

So based on this research, what reconstruction filter and gamma curve should I use to render text so it looks good over a range of fonts? :)

Or, perhaps a better posed question. What research-informed model will accurately predict the results of a user study that presents various renderings of antialiased lines on a modern LCD monitor and asks subjects to choose "which line is thicker" types of queries?

comment 7y ago · link · parent

It's possible this research has been done, but if so I haven't seen it yet. Basically the reason I feel confident asserting it is that I'm talking very specifically about the stimulus produced by modern displays. I know there's some work by Avi Naiman on CRT displays from the very early 90's[0]. There might be some other work done on low-resolution LCD's, but even aside from resolution it's only modern, high quality displays that have good contrast and low dependence on viewing angle (which affects gamma greatly).

Another place to look is Kevin Larson's work on subpixel rendering, which informed Microsoft's ClearType efforts. But that was done mostly around 10 years ago, when displays also were different. A good representative is [1].

Here's another pretty good paper I found[2], but it focuses more on the display technology than the perception side.

So what I'm looking for is adjacent to general psychophysics results on visual perception, but much more specific to what real displays do. That literature is pretty thin on the ground.

[0]: Avi C. Naiman and Walter Makous. Spatial nonlinearities of gray-scale CRT pixels, 1992

[1]: https://www.researchgate.net/publication/264485766_Optimizin...

[2]: https://pdfs.semanticscholar.org/8fc4/ecc59380f24e363c6a5d6a...

comment 7y ago · link · parent

Absolutely, and I think there's a very strong case to be made for that. One of the points I'm trying to make is that you have to solve it somewhere. People who focus narrowly on "correct gamma" often miss this, especially when "incorrect gamma" is also plausibly a workable solution.
1
484950
63