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

Or in the case of my recent Euler explorer, minimizes the L2 norm of tangent error. That said, most of the error norms will give similar results, as long as you're actually minimizing something. You're absolutely right about this though, the main reason people pick that one is that the math comes out easy, it's just a bit of trig.

comment 7y ago · link · parent

Actually https://link.springer.com/content/pdf/10.1007%2FBF02187690.p... is probably a better source, it's an image of the original paper.

comment 7y ago · link · parent

Right, this is also why it doesn't work in Safari. That's fixed now, but imperfectly (I don't know how to do the equivalent of setPointerCapture in ancient browsers, and also it only adds a mouse, not a touch handler, so still doesn't work in mobile Safari). Thanks!

comment 7y ago · link · parent

Thanks; that's fixed. I'll see if I can polyfill pointer events soon as well.

comment 7y ago · link · parent

Yes, that's about right. The only thing I'd qualify is that Spiro contains Euler spiral segments but also other things, especially smooth straight-to-curved transitions. This is only about the first, but the others are also important to font design. I wanted to keep it simple though.

comment 7y ago · link · parent

Argh, I used "modern web platform" but tried not to be too aggressive. I don't see any errors in the Safari console, so not sure what's wrong. The source is not (yet) in a public Git repo, but when it is, I'll happily accept PR's to improve browser compatibility.

comment 7y ago · link · parent

Fun fact that I came across while researching this. Hobby's PhD work (which I probably should have cited) was reviewed by one Kevin Karplus, who is perhaps best known for his role in the Karplus-Strong algorithm for plucked string sound synthesis.

http://i.stanford.edu/pub/cstr/reports/cs/tr/85/1047/CS-TR-8...

comment 8y ago · link · parent

I think this is a major loss of innocence moment for open source. The only sustainable solution to this sort of problem is to pay people to do at least minimal curation and maintenance of open source libraries.

In an ideal world, the payment would go to people who actually create open source value. However, I'm cynical enough about human nature and business to suspect that it will mostly go to middlemen like record distributors and academic publishers, who create very little actual value but somehow make themselves indispensable in the ecosystem.

comment 8y ago · link · parent

There was a talk at ADC '18 on this: https://youtu.be/UHK1QQM0bnE?t=918

I haven't watched it yet, but am intrigued. I'll post a tl;dw if nobody else beats me to it.

comment 8y ago · link · parent

That might be mine as well, https://medium.com/@raphlinus/towards-a-unified-theory-of-op... . It's very much unfinished work though. Certainly wrapping my head around the OT and CRDT literature took huge amounts of brainpower exertion, comparable to what I did for my PhD.

Also, I have your essay in my queue to read more thoroughly, it's high on my list of stuff to study as we possibly rethink the way this stuff works in xi-editor.

comment 8y ago · link · parent

"Just contact sales@zulipchat.com and we’d be happy to discuss your situation!" (https://zulipchat.com/plans/)

That's what I did. Thanks again to them, I really appreciate it.

comment 8y ago · link · parent

We've been using Zulip for just over a week in xi-editor and related projects, and I'm thrilled. Huge improvement over the pastiche of IRC and Reddit we were using before.

comment 8y ago · link · parent

This is a subtle point. It's not the array assignment that's the race here, but the update to the shared (by closure capture) `a` variable. You'd get the same data race if `a` were an `Int`, and we don't say that integers are non-thread-safe. If each closure had its own reference to the array, it would be copied on write.

I believe this is pretty good evidence for my claim that understanding the thread safety is confusing.

comment 8y ago · link · parent

Totally. If it means they live an actually good life rather than a form of hell, I would consider it a very good deal. (Of course, things get a lot dicier when there are "treatment programs" optimized for siphoning money as opposed to helping people, a criticism that can be leveled against large swathes of the drug treatment industry. I would of course not feel good about 10-15% of my income lining their pockets)

comment 8y ago · link · parent

JVM has two additional advantages over Swift (sorry for repeating) - an actual memory model, and data races can cause logic errors but not the full undefined behavior of LLVM languages.

comment 8y ago · link · parent

C and C++ are sharp tools. They have extensive undefined behavior, but also a formal memory model, so it means something to say, "this code is correct." They also have a culture of people who understand how to deal with undefined behavior, and tools (sanitizers) that make it more feasible.

Rust is safe, unless you go out of your way to be unsafe. It's not just "use a lock," it's "if you try to access shared mutable data without a lock, your program won't compile."

Java has data races but not undefined behavior. It also has a formal memory model.

Swift gives you none of that. Treating threads as a library rather than something with language support is something that might have seemed like a good idea 20 years ago, but now I think we know better.

comment 8y ago · link · parent

> This is addressed in the article, and a resolution is provided.

"Undefined state" is the language used in the article, and has no precise technical definition. The article suggests to me simply that a method might be called twice, and makes no mention of your bank account being emptied or demons flying out of your nose, which is the consequence of undefined behavior you should expect.

> Modifying an array is not atomic, AFAIK. You cannot safely do this concurrently.

I'm happy to correct errors (I'm not a Swift expert), but I'm going on the basis of copy-on-write semantics and the fact that `isUniquelyReferenced` seems to be implemented atomically - this is stated fairly clearly on the official Apple blog at https://developer.apple.com/swift/blog/?id=10 , but that might be out of date.

comment 8y ago · link · parent

This might be contentious, but I'm going to say it. If your program is multithreaded in a nontrivial way, Swift is not the language for you, at least yet.

First, this article understates the danger significantly. It's not just that your token loader might be called twice, if you call this from two different threads you're fully in undefined behavior. Swift is "safe-ish" in that it's mostly safe in single-threaded contexts, but with data races that breaks down. It's even more confusing because some things are properly atomic (reference counts, manipulation of value types like arrays), but some aren't (access to fields in classes).

Second, the language is missing basic features that in modern programming would help tame this beast - the most important of which is a wrapper for internally mutable state that is protected by a mutex. Grand Central Dispatch can help with some of this.

Third, there are unexpected performance losses. For example, the closure for running a block on a sync "queue" is heap allocated (because the type of such a closure is the same for sync and async, and of course the latter has to be heap allocated). This will probably be fixed, but I think is symptomatic.

Fourth, there's no official concurrency model. Again, it's confusing because there are some things that are obviously intended to run with concurrency. In fairness, Rust doesn't have a formal concurrency model yet either, but it is straightforward to apply reasoning from C++, and also reasonable to expect guarantees if the primitives such as Mutex, channels, etc., are used properly.

Fifth (and related), there are no atomics in the language or the standard library. Apparently OSAtomic is deprecated, and they now recommend the use of C atomics, but you're in the territory about having to reason about the polyglot combination of Swift and C.

Likely all this will improve, but in the meantime it's important to realize how immature Swift's concurrency is.

comment 8y ago · link · parent

At Google the lunch is not scored. It's a chance for the candidate to decompress a bit (the rest of the day is back-to-back) and also to sell Google culture a bit, but it's not about getting feedback.

comment 8y ago · link · parent

Same here. Plus for some reason Yakov Zeldovich's books on calculus really sang to me, much more than American textbooks.

comment 8y ago · link · parent

Agreed. And (as was largely the point of my thesis) these things are tradeoffs, a spline that's perfect in all these ways is not possible. I played around a bit and am not feeling that they'd be great for font design (they play pretty similarly to Séquin's circle splines, which of course you cite, though I think better).

We're now pretty far afield from the subject of the superiority of Rust over C++^W^W^W tau over pi^W^W^W geometric algebra over quaternions. I'd be more than happy to continue the discussion somewhere else.

comment 8y ago · link · parent

Very cool! Some of the later sections are broken. The fact that this is interactive is great, maybe I'll get around to putting my stuff in this form.

comment 8y ago · link · parent

I would replace the last two operations by another multiplication and one reciprocal square root. There is extensive SIMD support for very fast approximations, and getting better in newer chips.

comment 8y ago · link · parent

This is great stuff. I've also done some work in the space, and did a writeup called "A matrix approach to the Moog ladder filter", which is a pretty different perspective from Vadim's, but the concepts and principles are pretty much the same under the hood. That's the filter in music-synthesizer-for-android, and I think it holds its own, both in audio quality and (SIMD-optimized) CPU efficiency.

[1] PDF: https://pdfs.semanticscholar.org/8fba/b35e5235fa2f6006c0f889...

[2] Discussion on KVR Audio: https://www.kvraudio.com/forum/viewtopic.php?f=33&t=385262

comment 8y ago · link · parent

Likely that was xiph on why excessively high sample rates don't do much for the listening experience: https://people.xiph.org/~xiphmont/demo/neil-young.html

comment 8y ago · link · parent

From the asm you posted I have no idea whether it's optimized or not; it looks like two virtual function calls (calll %eax). Also, while I'm sure Julia is nice, the GC makes me worry about whether it'll work well in real-time audio synthesis (my primary use case).

comment 8y ago · link · parent

_This_ is why I linked to my undefined behavior post. Your comment is about as clear an example of being in the semi-portable camp as any I've seen. And I'm not blaming you, because in C you _can't_ do SIMD in the standard camp, so it's actually one of the more compelling reasons to remain in semi-portable. Rust is different though.

Also: the linked crate does use the type system in pretty much this way so that code that clients can be safe. However, there are limitations; it's not just whether a particular instruction can be used, which remains immutable once it's detected, but also which _registers_ (and, by extension, calling convention) can be used. That varies from function to function, and requires the `#[target_feature(enable)]` annotation to control, so just having an `Avx` type in hand is not quite enough to ensure that you're in a context where using the ymm registers is ok, and the intrinsic will be inlined to a "V" variant asm instruction. This is discussed in some detail in the "caveats" section.

comment 8y ago · link · parent

LLVM does (quite recently!), but Rust currently does not. I think it's likely that Rust should add it, but a large part of my post was exploring how far we could go with Rust as of today.

Edit adding citation: http://lists.llvm.org/pipermail/llvm-announce/2018-September...

comment 8y ago · link · parent

I've spent quite a bit of time looking at autovectorization, but didn't write about it much here, as it's only good for a pretty small subset of problems. One subtle gotcha I ran into is that `round` doesn't autovectorize, but `float` does, even though today's chips have perfectly good vector round instructions. See rust issue #55107 for a deep dive into that problem.
1
545556
63