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

Right, I've run into this a number of times, especially when porting code originally written for 32 bit to 64 bit. Besides compilers getting better, I think there's another factor - it used to be that a compelling reason to write asm is to get good utilization of a limited number of registers. But especially on aarch64 (and, in the not too distant future, AVX-512), there are a lot more.

Higher level abstractions are a good idea, but the problem is, are you able to exploit the capabilities that the chip exposes? For simple things like computing a scalar function elementwise over a vector, no problem, but a lot of the more interesting problems don't fit such simple templates.

comment 8y ago · link · parent

I agree that WASM is only really interested for embedding untrusted code, but am not sure that the browser is the only place where you need that. A good example is Cloudflare's workers, which they talked about at the last SF Rust Meetup.

Once you get a _good_ solution to embedding untrusted code, you might find it turns out to be pretty useful.

comment 8y ago · link · parent

It's missing the Net Promoter Score survey. Other than that, pretty spot on.

comment 8y ago · link · parent

The name definitely made me think of Rust's mio. On the other hand, `namespace cplusplus` and `mod rust` maybe are disjoint.

comment 8y ago · link · parent

My personal feeling is that the world is moving on from distance fields, and the state of the art is doing vector rasterization in the GPU. There are a few approaches to these, and currently one of the most promising is pcwalton's Pathfinder. Distance fields require lots of memory, have an expensive preprocessing step (and doing that ahead of time, as in this work, limits flexibility), and don't render very thin fonts well. GPU vector rasterization doesn't suffer from any of these limitations, but does of course require more sophisticated GPU programming.

comment 8y ago · link · parent

I loved this book as a kid, but I'm really not sure I would recommend it today. The Lisp of that era had "dynamic scope," and a great deal of Allen's book is concerned with fancy data structures and techniques to implement it in a reasonable fashion. But today I think we understand that stuff as basically wrong, and that "lexical scope" works better (and is much closer to the original lambda calculus that served as an inspiration). There are probably some proponents of dynamic scoping, but I think it's a lost battle.

So definitely yes, if you want to implement a historic Lisp. Otherwise, not so much.

comment 8y ago · link · parent

The Vintage Synthesizer Museum in Oakland has one, I got to play with it. They might be able to do something with the disks.

comment 8y ago · link · parent

I think wasapi has more or less superseded asio and has more support from Microsoft.

If you're programming in Rust, you can use the cpal crate, which wraps all these. I'm not sure cpal has astonishingly good performance in all cases, but I plan to work with the authors. It doesn't have an Android back-end yet, but such a thing should be possible.

comment 8y ago · link · parent

Yes to both, and also plan to write blogs about the content, and documentation for the library as it matures. I'm gratified to see the interest!

comment 8y ago · link · parent

Wrong on both counts. However, I'm very much back in the audio synthesis game, and will give a talk at next month's SF Rust Meetup on the topic.

comment 8y ago · link · parent

Thanks! I think a unification of OT and CRDT is a very promising space, both for practical implementation and for deeper academic understanding. To be honest, I only skimmed the posted paper, but it didn't grab my attention. It's very difficult these days for me to motivate spending time in this space.

comment 8y ago · link · parent

Now working on a game after 11 years as a Staff SWE at Google. I left for a complex mix of reasons, largely because I can and because I wanted to work on my own stuff, also not least because I don't have a good feeling about the digital world the big companies are creating. I wrote just a bit about this on my blog on leaving.

comment 8y ago · link · parent

And modern alternatives (for example c2t, which is for Apple II) can achieve even much higher data rates. I prototyped an encoding that packs 4 bits per pulse, achieving 23kbps but not reliably. One difference, though, is that this is designed for output from a modern digital sound interface, not designed to withstand degradation from analog tape recorders.

https://groups.google.com/forum/#!topic/comp.sys.apple2/qXZy...

comment 8y ago · link · parent

I'm with you. Whichever side you're on, Facebook's products and services now have a role in society where their decisions will inevitably have a deep impact. In some cases, like the Rohingya crisis, lives are literally at stake.

It's not just Facebook, either. I got tired of getting a sick feeling every time I woke up to see my employer in another controversy, which is a large part of the reason I'm an indie game developer now.

comment 8y ago · link · parent

Another implementation people might find interesting is the one in Minikin, the text layout library inside Android. It's all free software. This one has been optimized and tuned fairly carefully.

https://android.googlesource.com/platform/frameworks/minikin...

comment 8y ago · link · parent

It's possible to set compiler flags to optimize for size. That said, I've also seen large binaries, and monomorphization can contribute to that. Some projects are taking that more seriously, for example miniserde is designed to explicitly minimize monomorphization and this improve both code size and compile time.

comment 8y ago · link · parent

For what it's worth, these observations track closely with my own experience. I like that Cantrill emphasizes values rather than simply technical decisions. The Rust community, I believe, tries to get things right.

There's a learning curve, but with much experience, I find myself naturally thinking and writing in Rust code. I can get in the flow, and it feels just as high level and productive as languages prized for those qualities. I'm happy to see other very talented programmers have similar experiences.

comment 8y ago · link · parent

Yeah, that's one of the main things I'm looking at this for. I'm working on some new synthesizer code (written in Rust). If someone else is looking to make an inexpensive audio board with this part, we should talk.

comment 8y ago · link · parent

I've always said that RSS is Dave Winer's gift to the world.

comment 8y ago · link · parent

I had this question all the time. I agree, they should do something like google20p, which would have the side effect of advertising the fact that 20 percent still exists.

comment 8y ago · link · parent

As steveklabnik says, it absolutely is about tradeoffs. The anymap crate may provide enough of "generic container types" to be useful, and can avoid a lot of repetition of per-type code. A graph with heterogeneous node types is definitely possible, Box<Any> is one solution and there are others.

comment 8y ago · link · parent

Another major evolution is that SIMD is becoming part of stable Rust. It is available in C and C++ as GCC and Clang extensions, but not part of the standard language. Careful use of SIMD can result in fairly massive speedups across a wide range of problem domains.

comment 8y ago · link · parent

Aww, thanks :)

comment 8y ago · link · parent

I found this excellent talk to be complementary to my talk[1] on data-oriented GUI in Rust, not to plug my own work too much.

I found a lot of common ground:

* Trying to write object-oriented code in Rust doesn't work well. Writing data-oriented code does.

* "Fighting the borrow checker" is a sign you might be doing it wrong. Try data-oriented approaches instead.

* Use a structure-of-arrays rather than an array-of-structures.

* Use what I call "state splitting" to borrow mutable references to just the state you need; this works well with the structure-of-arrays approach and is a powerful motivator to use it.

* To build graph-like structures, reach for a Vec of components, and indexes into the Vec for relationships, as your first choice. Self-references, arena allocators, and Rc are viable alternatives, but you should have a good reason to use them instead of Vec.

* Some form of dynamic typing is useful to keep your system loosely coupled (though we ended up with very different forms of dynamic typing, see below).

* Data-oriented approaches have taken root in the C++ gaming community, mostly motivated by performance, but adapt well to Rust, and some of the ideas may be useful in domains beyond gaming.

There were some other points that went beyond what I talked about, but could fit in well:

* A "generational index" is a good way to avoid use-after-free style errors that result from the use of a stale index. The slotmap crate can help.

And now for the things that are different.

* The exact nature of dynamic typing is different. An ECS usually uses a registry of the different component types (anymap is a useful crate) and is quite open-ended in adding new types of components. My xi-win-ui, by contrast, has two main component types, Widget and listener, and does dynamic dispatch on a Widget trait.

This naturally raises the question, which is better? From my perspective, both are valid. The pure ECS approach definitely makes sense when the components are interacting with each other in diverse ways (collisions, damage, etc). In a GUI, the components are mostly interacting with the framework, and have diverse behaviors within standardized interfaces (input, layout, paint).

Thus, one point of my talk is that you don't have to reject all vestiges of object oriented programming, it's perfectly reasonable to hybridize, using data-oriented approaches for state splitting and graph structure, and dynamic dispatch for the behavior variation.

My talk also went deeper into the ideas of "data flow rather than control flow" and the use of an event or command data structure rather than method calls. I'm not sure how deeply these ideas apply to games, but wouldn't be surprised if they do.

[1] video: https://www.youtube.com/watch?v=4YTfxresvS8 , slides: https://docs.google.com/presentation/d/1aDTRl5R-icAF38Di-qJ4...

comment 8y ago · link · parent

I actually did this a few years ago, for my work on what's now the Dexed engine. But it's likely I've lost the work, it was probably on my work computer and I've left the job. Happy to chat if you want to see what rusty recollections I have.

comment 8y ago · link · parent

I'm with you, I don't cookie up any of my websites and have no intention of doing so. (Right now, my sites are super-primitive; my main one I've had for 22 years or so, but I'll be doing more).

But I do need to say that third-party fonts are not the problem here, or shouldn't be. Neither Google Fonts[1] nor Typekit[2] sets cookies. I don't know off the top of my hand if any of the other services do, but if so I would agree it's a good reason not to use them.

Disclosure: I helped launch Google Fonts and was involved in the decisions to make it privacy-friendly.

[1] https://developers.google.com/fonts/faq#what_does_using_the_...

[2] https://www.adobe.com/privacy/policies/typekit.html

comment 8y ago · link · parent

I used this trick in my Fizz-Buzz in my interview to get into Recurse Center. I might have been showing off a bit, but it didn't sink my application.

comment 8y ago · link · parent

I think it's worth continuing to explore as well, but the basic observation holds. Whenever you have a metric, the wannabes and self-promoters will game it. The people who are actually expert usually don't have the same kind of motivation to get their voice heard above the noise.

I've had some discussions with the lobste.rs folks about another attempt to do a sophisticated trust metric, but nothing ever rose to the level of "we should do this."

comment 8y ago · link · parent

That is more or less what the sanitizers do, and it's a reasonable approach to trying to discover UB.

comment 8y ago · link · parent

That puts you pretty firmly in what I call the "semi-portable" category (I would say "unportable" but wasm is very likely going to have flavors, such as a 64 bit pointer variant).

But if you're being careful, you can do type-punning. The "modern" way is generally with memcpy, but union can be valid if done carefully. The clearest statement I was able to find of this is [1]. I find it frustrating that it's so hard to get a clear read on this. For example, if as Regehr says union-based punning is reliable, then what was the concern that the linked Linux kernel patch trying to address? I haven't dug into it in super detail.

[1] https://blog.regehr.org/archives/1307#comment-18418

1
555657
63