Archive for April 28, 2021

Wednesday, April 28, 2021

Swift Generics 2: Existentials Boogaloo

Tim Ekl:

It’s been just over two years since we first saw “Improving the UI of generics,” the discussion post about potential changes to make generic types easier to work with in Swift, and five years since the first version of the Swift Generics Manifesto. (Time flies when you’re building a language!) Last week, generics landed back in the spotlight, as Anthony Latsis, Filip Sakel, and Suyash Srijan proposed SE-0309, with a major change that addresses one of the most infamous errors in Swift:

Protocol can only be used as a generic constraint because it has ‘Self’ or associated type requirements.

While this change is still in review (through May 1), it looks very promising — but, as often happens when dealing with the corners of the type system, the details can be a bit opaque. Much like last time, this post will walk through the nitty-gritty of the proposed changes in SE-0309, and offer some practical scenarios where they might improve day-to-day Swift usage.

Previously:

How Facebook Encodes Videos

Facebook (via Hacker News):

But while more advanced codecs like VP9 provide better compression performance over older codecs, like H264, they also consume more computing power. From a pure computing perspective, applying the most advanced codecs to every video uploaded to Facebook would be prohibitively inefficient. Which means there needs to be a way to prioritize which videos need to be encoded using more advanced codecs.

Today, Facebook deals with its high demand for encoding high-quality video content by combining a benefit-cost model with a machine learning (ML) model that lets us prioritize advanced encoding for highly watched videos. By predicting which videos will be highly watched and encoding them first, we can reduce buffering, improve overall visual quality, and allow people on Facebook who may be limited by their data plans to watch more videos.

Mighty

Suhail Doshi (tweet, Hacker News):

We’re excited to finally unveil Mighty, a faster browser that is entirely streamed from a powerful computer in the cloud.

After 2 years of hard work, we’ve created something that’s indistinguishable from a Google Chrome that runs at 4K, 60 frames a second, takes no more than 500 MB of RAM, and often less than 30% CPU with 50+ tabs open. This is the first step in making a new kind of computer.

[…]

One answer is moving more client-side compute to the cloud. […] If you can move the most demanding processing, then battery life can finally improve because video decode and render times (we’re streaming video here) get more efficient with better chipsets. […] If most of the time people spend is in a browser and most of the processing and system resources are offloaded, their computer won’t feel slow as apps become more demanding.

This sounds like an amazing technical achievement, if it works as described, yet also an indictment of the modern hardware/software stack. Personally, I mostly work in native apps and don’t find the Web unacceptably slow, certainly not to the point of wanting to rent a VM in the cloud or give a company all my data.

Previously:

Update (2021-05-03): Francisco Tolmasky:

Anyone who asks “why would anyone need Mighty?” has their critique backwards. It should be: how is it that Mighty is a compelling value prop? How is performance of native apps a non-issue on a $600 iPad, but we’re moving mountains to make web apps bearable on high-end hardware?

Traditionally, the strategy for a disruptive platform that has a built-in disadvantage (in this case performance) is to attack new or neglected markets. The web however has repeatedly insisted on focusing on areas that highlight its weaknesses, while seldom offering anything new.

[…]

@Suhail is right, the web of 2021 isn’t for reading blogs. You know how I know this? Because when I go to a medium.com link, it bounces me into to Medium iOS app. Because not only have we failed to offer the the future, we somehow managed to lose ground too.

The web lost mobile, full stop. And yet I’m still seeing pitches for how “the future of the Desktop is the web” like it’s JSConf 2009.