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

This is most likely crank bullshit. Previous discussion here: https://news.ycombinator.com/item?id=50593195

comment 2d ago · link · parent

Thanks.

The point I'm making is a subtle one. I do think you can go very far with an immediate mode GUI paradigm, and it's also certainly the case that most of the imguis you see are performant. But I still wouldn't choose it for a design or productivity app.

Once you do all the caching of text layouts and building of intermediate trees for a11y, you no longer have a pure imgui, but rather a hybrid.

I'm going to try to get this point across in an analogy, apologies to people not familiar with the referent.

Let's say you're frustrated with the size and complexity of a modern C compiler like clang or gcc, and want to do something simpler. One of the design decisions is whether use SSA (static single assignment) as the basis for the intermediate representation. If you're going for simplicity, you might quite reasonably choose to skip it; you can generate reasonably good code straight from the AST.

But then, you and your users get dissatisfied with merely reasonably good code, and want some of those optimizations that make production compilers generate actually fast code – constant folding, common subexpression elimination, strength reduction, etc. You can certainly implement them as AST transforms, but it gets difficult to track everything? You add a bunch of logic and eventually get those optimizations to work about as well as the SSA-based version in real compilers.

Another compiler designer has similar goals but uses a different strategy: dive in and do SSA from the beginning, which is not as simple at first, but then you can just do those optimizations "from the book," without a lot of friction.

Basically what I'm saying is that I prefer the second compiler. It's not to say the first can't be made to work.

3.

Advice for the next 100 Rust GUIs(linebender.org ↗)

264 points · by raphlinus · 3d ago · 159 comments

comment 5d ago · link · parent

You're thinking about it from the perspective of an individual. And I've had a similar experience. But take a closer look what it does to systems, processes, and communities.

comment 6d ago · link · parent

A retrocomputing Stack Exchange [1] thread looks like a really good source. That in turn cites [2] with Stephen P Morse, 8086 architect, as first author. I'd consider that pretty authoritative.

The exact quote from the latter source is:

"Several other instructions that had been contemplated were not made available because of the software ramifications and the compatibility constraints they would place on the forthcoming 8086."

[1]: https://retrocomputing.stackexchange.com/questions/8040/whic...

[2]: Intel Microprocessors: 8008-8086 published in IEEE Computer, Vol 13, No. 10, page 46, October 1980

comment 1w ago · link · parent

What, no elliptic integrals?

It turns out the math for the pendulum is the same as the math for the elastica. I go into this in some depth in my history of the elastica [1].

[1]: https://www2.eecs.berkeley.edu/Pubs/TechRpts/2008/Archive/EE...

comment 1w ago · link · parent

I think a rounded rectangle is defined as 4 straight line segments joined with G1 continuity to quarter circle arcs. I'm unaware of any other definition. The only variation I know is whether the radii have to be the same or can be different. Flexible implementations do allow the latter.

8.

Squircles(linebender.org ↗)

231 points · by raphlinus · 1w ago · 58 comments

comment 1w ago · link · parent

Yes, it's all software, and FM synthesis is using the same engine as dexed. It's a Blackfin chip, which has pretty good throughput for DSP (digital signal processing). A ton more detail is at [1], including the operating system, which is a FreeRTOS-derived SMP kernel.

[1]: https://github.com/AL-255/FM-1-RE

comment 1w ago · link · parent

I get your point but disagree strongly. One topic that's been on my mind a lot is durability. The culture of LLMs is that everything is transitory. Why bother keeping a vibe coded codebase around for more than a few weeks, when the next big model iteration will be able to vibe code it better?

By contrast, free software in general, and Rust very much in particular, has cultural norms that things should last a while, rather than immediately being thrown away. I think that's worth preserving.

comment 2w ago · link · parent

If you can run compute shader code, the fingerprinting and side channel possibilities become very rich. [1] is one paper among many on this topic.

[1]: https://dl.acm.org/doi/10.1145/3634737.3656283

comment 2w ago · link · parent

For this experiment I had it write directly.

I should add, part of the experiment was to test whether having variable names and (C style) types would help the LLM. For a task of this size (about 1.5 kLoC Rust, 3k insn asm) it was inconclusive, but for larger projects I suspect it would make a difference.

And the plan for symbolasm is to move past C style types into Rust style and maybe dependent typing, specifically to facilitate automated proofs.

comment 2w ago · link · parent

Yes, and? As the cost of code generation approaches zero, this starts to make more sense, especially if you do have mechanisms in place to ensure safety and correctness.

I did an experiment a couple weeks ago of having Opus 5.5 translate an MP3 decoder from Rust into Cortex-M33 assembly language, both raw asm and symbolasm. The code was 3x smaller and ~1.5x faster than Rust -O3. These seem like gains that are worth it.

comment 2w ago · link · parent

That's quite cool. I haven't dug deep into using the PIO but it clearly has potential, as shown by Linus Åkesson's demo work.

comment 2w ago · link · parent

Thanks! I had a feeling there was something out there, but couldn't easily find it. I can see this is well optimized for speed, but the RAM usage looks scary from the perspective of a really memory constrained chip.

On the RP2350, a load from memory and a move-immediate both take 1 cycle, because there's a separate data bus to fast SRAM. If I did want more speed and didn't mind an expansion in font size, I could store each glyph in its own byte/word and avoid the ubfx instruction. But on this chip, for a reasonable speed/space tradeoff I'm going to optimize for space every time.

comment 2w ago · link · parent

Hi! I'm doing something similar: vic-2350. But I'm not porting any existing system, I'm doing it to match the constraints of the hardware we have now.

17.

JIT bitmap text rendering for microcontrollers(linebender.org ↗)

5 points · by raphlinus · 2w ago · 1 comment

comment 2w ago · link · parent

I think you're right, but rather surprisingly I have some experimental data on this question that is inconclusive at best. My hobby project is symbolasm, which is intended to close exactly the gaps you describe: by naming variables and introducing types, it re-adds much of the context that assembly language erases. I ran a quick'n'dirty experiment to see if it would make the LLM more efficient at writing code than raw assembler.

The task was rewriting an MP3 decoder from Rust into ARM assembly language, Cortex-M33 flavor specifically, optimizing for both speed and code size. The output is approx 3k instructions. The tl;dr is that Opus 5.5 nailed the task, whether writing assembly or symbolasm. It took approximately 2x tokens for the latter, which I think is largely explained by the fact that it was dealing with a novel language nowhere represented in its training set.

The quality of the result was comparable; the raw asm was slightly faster and slightly less dense, which I consider insignificant because I think you can get the same effect just by tuning the prompt. In particular, if I were re-running the experiment, I might set a strict code size budget and then ask it to optimize for speed within that budget, allowing comparison on a single scalar.

The experiment was compelling in another way: the code was 3x denser and 1.5x faster than -O3 output from Rust. So for certain applications, going to assembler will be worth it, especially as the cost of generating the code goes to zero.

[1]: https://github.com/raphlinus/symbolasm

comment 2w ago · link · parent

No, it's Knuth. The exact quote is "Beware of bugs in the above code; I have only proved it correct, not tried it." [1]

[1]: https://staff.fnwi.uva.nl/p.vanemdeboas/knuthnote.pdf

comment 2w ago · link · parent

Worth noting, WGSL does this too, and is mostly a bit stricter than Zig: `a + b & c` and `a << b & c` are errors in WGSL but accepted by Zig. (Quick: off the top of your head, how do those parse)?

I'm thinking of doing this for symbolasm also.

comment 3w ago · link · parent

They should send me a t-shirt. But in any case, thanks!

comment 3w ago · link · parent

Both the image compression and the symbolasm language started out being entirely hand coded, but I have used Claude to move it forward. I have complicated feelings about this. Basically I would have gotten these results even without the LLM, but it would have taken a lot longer.

I feel like one of the main tasks in front of us as an industry right now is to figure out how to use LLMs well, how to create quality and resist slop. As part of that, I'm taking care to write the prose myself.

I totally understand how any LLM usage can be a turnoff, though. I've felt that myself.

comment 3w ago · link · parent

I don't believe macro assemblers do a flow-based analysis to verify that the register allocation for variables is consistent; from what I understand the most you get is just a scoped alias for the name of the register. Of course, I could be missing something. If you know of anything beyond the relevant work I cite, please let me know.

comment 3w ago · link · parent

If you have an Adafruit Fruit Jam, you can run the demo on that board [1]. It can stream 640x480 video off an SD card at 60fps, as well as display a static image from flash.

Also possibly of interest to HN, the decoder[2] is written in a new low level language called symbolasm[3], which seeks to combine the advantages of assembly language (it's possible to reason about and optimize performance with few limits) with some of the affordances of C, especially named variables and struct fields.

[1]: https://github.com/raphlinus/vic-2350

[2]: https://github.com/raphlinus/vic-2350/blob/main/image.sy

[3]: https://github.com/raphlinus/symbolasm

comment 3w ago · link · parent

Absolutely. This is optimized for highly resource constrained devices, not modern machines. I can tweak the README if that's at all confusing.

26.

The RP2350 can do full motion video playback(github.com ↗)

2 points · by raphlinus · 3w ago · discuss

27.

Nibnib: Image compression with extreme decompression speed(github.com ↗)

188 points · by raphlinus · 3w ago · 36 comments

comment 1mo ago · link · parent

Oooh, I hadn't seen that. It's very cool.

The main difference is that it primarily targets 8-bit chips, so often has to expand a statement into multiple instructions, while I'm targeting ARM, which can get quite a lot done in a single instruction. But I absolutely will cite it as precedent.

comment 1mo ago · link · parent

Blackfin is one of the things I looked at. I go quite a bit farther, with named variables, richer types (struct fields are named), block syntax, and generally capturing as much programmer intent as possible while maintaining an almost 1-1 mapping between statements and assembler instructions.

Time is a circle. Assembler could come back if it's an appealing target for LLMs. Currently it's not, but that's my hypothesis.

comment 1mo ago · link · parent

I haven't implemented debugging yet, but I expect the situation to be good, for the following reasons:

* It's possible to embed variable names into the debug info, so your debugger inspects those rather than just numbered registers.

* Optimizing compilers can do transformations which highly obscure the relationship between source and binary code. Here they closely match.

Thanks for your interest!

12345
63