14,081 karma · joined Mar 7, 2014 (12y ago) · 1,887 submissions
comment 2d ago · link · parent
comment 2d ago · link · parent
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 6d ago · link · parent
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
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
8.
231 points · by raphlinus · 1w ago · 58 comments
comment 1w ago · link · parent
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
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
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
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.
17.
JIT bitmap text rendering for microcontrollers(linebender.org ↗)
5 points · by raphlinus · 2w ago · 1 comment
comment 2w ago · link · parent
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.
comment 3w ago · link · parent
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
comment 3w ago · link · parent
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
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
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
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
* 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!