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

Not GP, but the following come to mind: Jai, Zig, Odin, and Hare, all of which aspire in one way or other to be a modernized take on C. There is also a larger class of languages I call "safe-ish" as they are generally safe for single-threaded programs but can exhibit undefined behavior from data races; this includes Swift and Go, and likely other newer languages inspired by those.

comment 4y ago · link · parent

Thank you for posting such a beautiful example of a false claim about your language.

The front page of vlang.io has prominently featured under "Safety" the line "No undefined behavior". Saying that C-like undefined behavior[1] is "expected" directly contradicts that. I'll also point out that Nim, another language which compiles to C as a target, addresses this correctly.

[1]: https://raphlinus.github.io/programming/rust/2018/08/17/unde...

comment 4y ago · link · parent

Hey, I went through another one of the examples, the lack of SFINAE, here's how I tested: I used the same methodology as the linked blog post. I'm getting the same compiler error as the blog post. Are you able to reproduce this?

comment 4y ago · link · parent

It's legit, here you go: https://news.ycombinator.com/item?id=19086589

I'll also add, my personal reading of the quote has more than a note of "this sounds too good to be true." But that could well be a matter of interpretation.

comment 4y ago · link · parent

The claims made in that blog post are easily verifiable. Your claim that all issues have been fixed was hard to believe, so I checked myself. The first two have indeed been fixed (these involve printing "nil" for a null pointer rather than crashing), but the third (undefined behavior on integer overflow) still reproduces. I didn't go through the rest of them, but expect a similar pattern.

I encourage people following the progress of the V language to look at actual facts rather than trying to evaluate claims based on the language of those claims. One of the reasons why V is so divisive is that a lot of untrue claims are being made (unusually so for a programming language), and people don't respond well to that being called out.

comment 4y ago · link · parent

Thanks for the explanation. I would consider that type of logic error more or less impossible to defend at the language level, but I can see how analysis tools can be helpful.

comment 4y ago · link · parent

I am skeptical until I see the details, and strongly suspect you are dealing with a "safe-ish" language rather than one which has Rust-level guarantees. Uninitialized memory reads are undefined behavior in basically all memory models in the C tradition. In Rust it is not possible to make a reference to a slice containing uninitialized memory without unsafe (and the rules around this have tightened relatively recently, see MaybeUninit).

I say this as someone who is doing a lot of unsafe for graphics programming - I want to be able to pass a buffer to a shader without necessarily having zeroed out all the memory, in the common case I'm only using some of that buffer to store the scene data etc. I have a safe-ish abstraction for this (BufWriter in piet-gpu, for the curious), but it's still possible for unsafe shaders to do bad things.

comment 4y ago · link · parent

Here are the first few sections: https://gist.github.com/raphlinus/f6b34f85d63c4b73a0242481ed...

I'll keep going if there's positive feedback, delete it if the author doesn't appreciate it.

comment 4y ago · link · parent

I might be willing to give this a shot. I appreciated the charm and humor in the original, but especially for readers who don't have English as a first language it probably gets in the way of the message.

comment 4y ago · link · parent

If you're not able to remember, it seems like you're suffering from some form of amnesia. You know who wrote about amnesia in this context? Murray Gell-Mann, that's who!

comment 4y ago · link · parent

I think the operative trope is more Sturgeon's Law than Gell-Mann Amnesia. I had a period where I was reading obsessively about Covid, including reading papers and listing to TWiV (which is very informative but requires a massive time commitment). What I found is that the best of the science journalists (Helen Branswell, Jon Cohen, Kai Kupferschmidt, Amy Maxmen, Ed Jong) were excellent, writing with a deep understanding of the subject material and providing useful context. The median news story was just awful, and the WSJ and NYT opinion pages were for the most part a dumpster fire ("There Isn't a Coronavirus 'Second Wave'" is a masterpiece, chef's kiss).

I've generally found the same thing is true in other domains. Seek out writers who know their stuff. They exist, they're just not consistently the most popular.

comment 4y ago · link · parent

Entirely joking about being offended, that work was a long time ago. I think it was an interesting exploration but we were not able to get compelling results, I think mostly because we did not at that time have affine types (move semantics). Thus if you put something into a container in one place and took it out in another, it would have to infer the region that spans both, which might as well be the whole program in most cases.

These days I program in Rust and find Rust's approach to explicit regions to be a workable compromise, though reference-heavy types can get pretty ugly and hard to work with (and I'm pretty sure that variance of lifetimes is confusing to everybody who isn't a PLT theorist and some who are).

The approach I personally find most interesting is the Lobster language. There (and I'm probably oversimplifying) the semantics are reference counting, but you so analysis to remove a huge fraction of RC operations. I believe the Perceus work is similar.

I'm happy to chat anytime. Recent work has been using somewhat exotic types provided by Rust (associated types, existentials, lots of inference through product types) to represent UI. So far I've basically been using what Rust gives me, but it's interesting to imagine what changes to the language/type system might buy you. For example, there are a few places in the code where there are downcasts, but I suspect that with a sufficiently strong type system you could prove those downcasts are infallible.

comment 4y ago · link · parent

Hey, thanks for calling my work "not viable!" (Co-author of "Better Static Memory Management" here)

Seriously, this looks promising and I'm very interested to see where it goes.

comment 4y ago · link · parent

I so want to own this coin, and was initially disappointed by this news, but then realized that by an application of hard work and a certain amount of investment, it is possible for me to own just over half of the total market cap. Good thing it is provably safe against 51% attacks.

comment 4y ago · link · parent

I've been talking to Nathan and think he has a good handle on the issues. One of the biggest mistakes in xi was an over-reliance on async and a loose coupling between the main logic and the UI surface. Zed isn't making those mistakes. I'm eager to see what the come up with and look forward to friendly competition in the open source Rust UI space when they release their toolkit.

comment 4y ago · link · parent

I don't have an actual answer, but I strongly suspect that the compensation of library authors is going to somehow be tied to supply chain assurance. At some point it will be considered irresponsible (perhaps to the point of liability) to ship software containing FLOSS libraries without paying somebody to do a minimal audit that the version shipped has not been hijacked by malware. The only question in my mind is whether any of that money will flow to actual creators, or whether it will just sustain a self-licking ice cream cone.

comment 4y ago · link · parent

I think of "text rendering hates you"[1] as the classic "falsehoods" analog about text.

[1]: https://gankra.github.io/blah/text-hates-you/

comment 4y ago · link · parent

These are very good questions. I'm not 100% sure where this will go. Your comments are helpful in helping define the contours of the space to explore.

comment 4y ago · link · parent

Yes, Dreams is also strong evidence that SDF-based rendering is viable. That project also put an enormous amount of effort into creating new design tools :)

comment 4y ago · link · parent

I am fairly excited about these techniques. I consider SDFs to be a very powerful representation of 2D scenes, and of course Inigo Quilez has been demonstrating the incredible power of SDFs in 3D. Of course, the big challenge is, what tools do you use to author content in SDF form? In Inigo's case, it's essentially a text editor, coming up with the math yourself, but that doesn't scale unless you're a genius like him.

So using machine learning and optimization techniques in general to solve inverse problems, so your input is something meaningful, is a way to unlock SDF rendering without requiring a reinvention of the whole tool universe.

If someone wants a modest-scope project, it would be applying these kinds of techniques to blurred rounded rectangle rendering[1]. There, I got the math pretty close, fiddling with it by hand, but I strongly suspect it would be possible to get even closer, using real optimization techniques.

[1] https://raphlinus.github.io/graphics/2020/04/21/blurred-roun...

comment 4y ago · link · parent

Yes, most definitely. My main work these days is on supporting high performance drawing of such large data sets on GPU. It's not entirely wrong to say that my continued explorations into UI architecture are motivated by wanting to drive the renderer with really high-bandwidth input.

comment 4y ago · link · parent

I've thought about it. Your "etc" in the first paragraph is doing a lot of work, especially on Windows. The idea that there is a "native" widget set is increasingly a fiction. I agree though that on mac and iOS it makes quite a bit of sense.

A somewhat galaxy-brain approach to this is to make views generic over Cx, and add "factory" methods to Cx for creating button, stack, slider, etc.

All that said, my personal feeling is that while this would give promising early results for creating simple property-sheet like UI, it will be extremely difficult to make polished, truly native-feeling UI in it, as ultimately the seams will show. The first 90% will go well, but the second 90% will be painful.

I don't want to discourage people from trying it though!

comment 4y ago · link · parent

I think your skepticism is well placed, and I think you are asking the right question.

Here is why I'm hopeful. SwiftUI is as you say wonderful, but is very much a closed ecosystem. You can't really implement your own custom views, rather you can assemble the premade ones in various (cool and interesting!) ways. If you wanted grid layout before iOS 14, you were on your own.

By contrast, in what I'm building, everything is open-ended, and you are invited to build fully custom versions of every piece of the system - change propagation, async resource loading, layout, drawing, animation, everything.

So yes, I am hopeful this approach will give good results for especially those highly intensive applications you mention. And if not, we'll learn something why not. I'm looking forward to trying!

comment 4y ago · link · parent

If two components generate events in the same cycle, they get queued, and the corresponding callbacks are run sequentially, each time with a mutable borrow of the app state. This seems like the most correct and ergonomic approach to me.

comment 4y ago · link · parent

First question is easy: yes, the widget tree can be updated. That's generally done by diffing data stored in view nodes, but in fact the View trait is open-ended and you can implement the rebuild method to do anything you like. And yes, selection state lives in widgets and it is absolutely a goal to have that persist.

The second question is more challenging (see the "advanced topic" under identity for a little more background). View id's cannot be re-parented, in other words when a parent relationship is expressed in an id path (by virtue of having the child id follow the parent in a path), that relationship cannot be changed. However, widget ids and view ids are not necessarily the same, though they can be. I think what's needed for your use case is a level of indirection so the view id paths remain stable, but the widget id structure relationships can be changed. I haven't worked out all the details, but think it can be done, and if it's done right it wouldn't require any rebuilding of widget subtrees.

comment 4y ago · link · parent

I would say that they were even greater inspirations for the Druid architecture that predated this latest work - we were hoping that a lot of the incremental/reactive patterns could be expressed using combinators over immutable data structures. That didn't work out as well as hoped; I think it's possible to build things that way, but it's also pretty hard going and the community never really reached critical mass.

A semi-explicit goal of this work (that somehow didn't make it into the blog post) is that developing for this architecture, both building the UI components and using them, should be a lot more fun than before. Of course, that's a slippery goal to quantify. We'll just have to see how it goes, but I'm hopeful.

comment 4y ago · link · parent

Good catch! Yes, the plan is to implement _ConditionalContent. It would look something like this:

    if_view(bool_predicate, || view1(...then...), || view2(...else...))
Whether we end up having a proc macro that has similar functionality as ViewBuilder in SwiftUI is an open question. For the time being, I'm seeing how far I can get with just vanilla Rust.

I'm generally pretty hopeful about the ability of the Rust compiler to handle big complex types, but it is a risk. There other projects out there that also stress it, and the compiler team is pretty serious about making this work well.

comment 4y ago · link · parent

To be honest, I haven't looked too deeply into Sycamore. A lot of the reactive machinery looks pretty similar to Dioxus (threading a context scope, using explicit observable objects for change propagation). I think it's worth comparing more carefully, and would be more than happy to link a writeup to such a comparison.

comment 4y ago · link · parent

The other responses have this right. I think the Redux pattern is similar enough to Elm that I didn't feel a need to make a finer distinction.

I'll also say this: the tools that Rust provides for reasoning about mutation are powerful and principled. A central philosophy of Rust is that mutation isn't the problem, it's shared mutable state. If you believe that philosophy (and I do), then restricting yourself to pure functions over clonable state feels like tying one hand behind your back. I hope I've made the case that providing finer grained access to mutable app state is an approach at least worth exploring.

comment 4y ago · link · parent

Heh yes, somebody else caught that. I think the current state is ok. This closure won't capture any locals, but in general closures in the view tree will. I'll take a PR if you think it should be improved further :)
1
171819
63