4 ms·
This might explain it, in the opposite way it was meant to: https://fxtwitter.com/trq212/status/2014051501786931427 https://fxtwitter.com/trq212/status/2014051
by airstrike 5mo ago
This might explain it, in the opposite way it was meant to:
https://fxtwitter.com/trq212/status/2014051501786931427 https://fxtwitter.com/trq212/status/2014051501786931427
> Most people's mental model of Claude Code is that "it's just a TUI" but it should really be closer to "a small game engine".
- applfanboysbgon 5mo agoI hadn't seen that quote before, what an embarrassing thing to go on the internet and write...
- pragmatic 5mo agoSomebody read/watched too much Casey Muratori.
- CamperBob2 5mo agoNo, somebody didn't read/watch enough Casey Muratori.
- layer8 5mo ago> For each frame our pipeline constructs a scene graph with React then -> layouts elements -> rasterizes them to a 2d screen -> diffs that against the previous screen -> finally uses the diff to generate ANSI sequences to draw That’s rather sickening.
- deleted 5mo ago[deleted]
- Fr0styMatt88 5mo agoSo I’m wondering what ‘rasterizing’ literally means in this case. I imagine it’s just creating a 2D map of elements at a very low (probably character) resolution, then diffing that against the last generated map to come up with an optimal ANSI sequence to send to the terminal, would that be right? Seems like a cool puzzle to solve. I wonder what the engineering and organisation tradeoffs were that lead to it — does it let them reuse a bunch of existing code? I wrote a TUI library back in the day for Turbo Pascal — it was essentially taking an immediate-mode approach (which in this context is just a fancy way of saying it was procedural haha).
- fluoridation 5mo ago"Rasterizing" means just one thing in this context: to transform a data structure into an array of pixels. It seems absurd to do this, given that the next step must be to convert back from pixels to text data, but maybe they have some way to generate predictable sequences of pixels (e.g. the character "t" is always rendered as the same pattern of pixels), such that they're cheap to convert back. If they're doing anything else, the word "rasterizing" is being misused.
- fc417fc802 5mo agoYes, the much more plausible explanation is that the word rasterize was misused there. They are generating and diffing text data which has been a standard approach to drawing a TUI since the dawn of computing. It is not even remotely resource intensive.
- skydhash 5mo ago> They are generating and diffing text data which has been a standard approach to drawing a TUI since the dawn of computing. It is not even remotely resource intensive No one has ever done that. Even top[0], which does full screen refresh, clear the screen (if necessary) and write the new information (the period is in seconds, not ms). No need to diff. That would be like diffing a file, just to find which bytes to update. [0]: https://cvsweb.openbsd.org/checkout/src/usr.bin/top/display.c,v?rev=1.67 https://cvsweb.openbsd.org/checkout/src/usr.bin/top/display....
- fc417fc802 5mo agoI don't understand why you would make such a confident negative claim rather than ask for an example or otherwise engage in discussion. Particularly given that you replied to a comment elsewhere in this very thread that links to a real world example of exactly such an implementation! [0] See in particular this part of the source. [1] I agree that most programs don't bother to do that but please recall that my claim was merely that what Claude Code is claimed to be doing with regards to diffing is a well established and long standing optimization. The important point being that it is neither expensive, novel, or particularly complex thus not an excuse for poor performance. [0] https://news.ycombinator.com/item?id=48405259 https://news.ycombinator.com/item?id=48405259 [1] https://github.com/emacs-mirror/emacs/blob/c29071587c64efb30792bd72248d3c791abd9337/src/xdisp.c#L73 https://github.com/emacs-mirror/emacs/blob/c29071587c64efb30...
- replwoacause 5mo agoWhy the hell does it need to be so complex? People have been making TUIs for decades. Did we need a small game engine to run claude code?
- Quekid5 5mo agoMust have 120 fps for answers arriving in [buffering] 30 seconds.
- imjonse 5mo agoThey forgot to add 'make it as simple as possible' in the prompt is one possible cause. On a more serious note using a react-like lib for TUI in the hope you'll share the codebase with the web version is a more likely explanation. Still not the best idea.
- javcasas 5mo agoReact is not that stupid to re-render in a loop at 60fps and instead waits for changes to happen before re-rendering. It even batches changes and stuff.
- the_gipsy 5mo agoYou don't need React for reactive TUIs - at all. I can understand chosing React for web, but for a TUI it sounds like a really poor idea. And in practice we can see that the claude code TUI is also poor.
- uxhacker 5mo agoSo how much more improvements are there for efficiency in the Claude code base if they are using react for a tui, in the rest of the code? I also wonder about the wasted cycles and just the environmental damage caused by all these wasted cpu time . (Edited added a comma for clarity)
- wyre 5mo agoI can't help but think it's their engineer's and PM's making these decisions, since I know that if you asked Claude to write a TUI there is no world it would recommend whatever the frontend architecture of claude code is.
- javcasas 5mo ago> For each frame our pipeline constructs a scene graph with React then > -> layouts elements > -> rasterizes them to a 2d screen > -> diffs that against the previous screen > -> finally uses the diff to generate ANSI sequences to draw Yup. Overengineering.
- Animats 5mo agoWhat is "frame" in this context? Video frame, or something else?
- layer8 5mo agoThe contents of the terminal screen at any given point in time.
- javcasas 5mo ago> -> rasterizes them to a 2d screen > We have a ~16ms frame budget so we have roughly ~5ms to go from the React scene graph to ANSI written. It looks like video frame, full framebuffer, generated and parsed at 60fps. It surprises me they haven't introduced GPU shaders, 16x oversampling and raytracing. Maybe for next release.
- Melatonic 5mo agoIt's like the Citrix of AI :-D
- stego-tech 5mo agoOOF. As a former Citrix admin, I felt that burn in my bones. An upvote well earned.
- Aperocky 5mo agoIt's product bloat. It's not recognizing that they are just one building block that should do one thing well, like tmux. You don't need a computer display on your fridge for the same reason, but Anthropic think you do. You should see virtual ice getting created and they should correspond to the actual ice behind the door - think of how amazing that is! And it's not even completely a bad idea. make it claude-code-react-beauty of some way to take it off, it would be far more palatable.
- munificent 5mo agoAs someone who maintains a roguelike with a terminal-like UI that: 1. Maintains an internal representation of what the game thinks is on screen. 2. Runs the game for one frame which updates that representation. 3. Generates a diff to see how that differs from what's actually on screen. 4. Executes the minimum set of draw calls to get the screen to match the internal representation. It's really not that hard. It's a few hundred lines of code.
- javcasas 5mo agoSure. For a videogame. > -> rasterizes them to a 2d screen Also you forgot "render to a framebuffer, then parse the framebuffer back to chars". Anyway, I'm off to construct the new `ls` command. It will render the list of files to a mesh of billions of polygons in a GPU with advanced shaders, 16x oversampling, HDR and all the graphic acronyms I don't understand, then read the resulting image, find the nearest character in the ANSI charset and use that one. It will be _glorious_ (and profoundly stupid)
- ux266478 5mo agoCould be improved. Encode the image to webp with high compression settings and handle the ASCII mapping by spinning up a local LLM to do OCR on it. Individually. For each cell.
- javcasas 5mo agoThanks for the idea for V2.0. Hopefully the Claude team doesn't do it first.
- tikimcfee 5mo agolol... I know you meant this comically, but you just called me out and it's glorious: https://glyph3d.dev https://glyph3d.dev I built a truly glyph based instanced quad system to render millions of characters in space at once.
- munificent 5mo agoMy roguelike's "graphics" are a simulated terminal, so it's a 2D grid of colored characters. It's essentially a TUI, just like Claude Code, except instead of rendering to a real terminal using ANSI escapes, I render to a web canvas using... something probably more complex than what Claude has to do. It's still not hard.
- qwery 5mo ago~ "it's not a TUI! <describes an outrageously overengineered TUI> and my dad works at Nintendo" curses, bud. curses. It's genuinely difficult to tell how much of this is true. The post is obviously 100% posturing, but some of the words describe things that could be done. Very few game engines do anything I'd describe as rasterisation. That's kind of the point of a GPU. Well, it used to be. I suppose "small game engines" might be more likely on average to include a rasteriser. The typical reason for this is because the author wanted to write it. Whereas big engine make triangle give hardware go brrr. So I assume here 'rasterize' means 'printf'. And diffing screens means diffing 50..150 lines of text. And "generating ANSI sequences to draw" means 'printf' with some ANSI sequences interpolated in. Then there's the frame budget. You have to understand they are operating within a strict frame budget -- they're not messing around, OK. They have a 16 ms frame budget, so they burned 11 ms and now have a (roughly) ~5 ms approx. budget for the final 'printf' in the chain???
- fc417fc802 5mo agoYour broader point is well taken but I thought I'd stop by with some trivia. High end engines such as unreal will rasterize absurd quantities of micro-geometry manually using compute shaders in order to avoid the bottleneck of the hardware rasterizer.
- solid_fuel 5mo ago> High end engines such as unreal High end engines such as unreal have the excuse of being tasked with rendering millions of polygons, in which case a complex approach makes sense. Claude Code is only being asked to render a few thousand UTF-8 characters.
- fc417fc802 5mo agoHence my prominent note that it was trivia which implies it to be at least somewhat tangential to the original conversation.
- PunchyHamster 5mo agoWell it runs on something they didn't design (Electron) using GUI library they didn't design (React) For company with that much AI you'd think if it was actually good, doing that part in fast and performant way would be "easy"
- f311a 5mo agoIt runs in a terminal, it’s not electron
- overgard 5mo agoAnd yet, nobody that writes game engines would do it this way because game engines need to be efficient..
- 0xbadcafebee 5mo agoIf they used an actual game engine to render a 3D UI from scratch it would be more efficient
- agumonkey 5mo agothis allows for comfortable ergonomics IMO not that it could be leaner for sure but i get the reasoning behind the tui rendering layer
- airstrike 5mo agocomfortable ergonomics? you can't scroll up more than 50 lines before it starts to garble up text i'd be ashamed of publishing software with this level of polish as a solo dev, let alone as the hottest multibillion startup on the planet
- agumonkey 5mo agoHmm I thought this was due to me using tmux with claude-code, also it seems that `claude agents` doesn't have this issue. By comfortable ergonomics, meant the forgiving and asynchronous input system. You can start typing, cancel, retry with previous input, accumulate messages while the agent is active. I don't know all TUIs but this is not common IMO. Other than that I agree with you.
- skydhash 5mo ago> You can start typing, cancel, retry with previous input, accumulate messages while the agent is active. I don't know all TUIs but this is not common IMO. Literally every audio player or anything that uses threads.
- agumonkey 5mo agogood point, i didn't classify tui audio players in a way, they don't converse, they allow asynchronous effects and stacking, that said i might be lagging about these, last i used was mocp, any names i should check out ?
- dom96 5mo ago> https://fxtwitter.com https://fxtwitter.com What is this?
- orliesaurus 5mo agowhen they announced /pet mode or whatever - that was really the end of the line for me.
- yrds96 5mo agoI can't still conceive the fact that a tool that only send/receive text from an external API consumes an absurd amount of RAM
- ariwilson 5mo agoMaybe Claude is operating at a higher, self-improving level than all of us poor HN commenters. Wasting the local machine's resources to look pretty is a plausibly deniable way to make the Claude Code FE unusable with local LLMs, starving the competition.