Archive for February 15, 2019

Friday, February 15, 2019

Using Tuples As Lightweight Types in Swift

John Sundell:

Even though a tuple can have labels, you are always free to ignore those when creating an instance. This can help make call sites look really nice and clean, for example when dealing with vector types, like coordinates.

[…]

Tuples can also be super useful when checking if multiple values are equal. Even though they don’t conform to the Equatable protocol (or any protocol for that matter), the Swift standard library defines == overloads for tuples that contain values that themselves are equatable.

[…]

It turns out that the argument list of any closure can in fact be described using a tuple, and since - thanks to first class functions - all functions are also closures, we can actually use a tuple to pass arguments to a function. All we have to do is to make Swift treat a function as a closure. To do that we could define a call function that takes any function and applies its required arguments to it[…]

John Sundell:

Tuples can not only be super useful in order to group multiple related local variables into one, but can also be a great way to combine throwing expressions

Pixelmator Pro vs. Photoshop CC

Victor Agreda:

If you do heavy print work, you rely on other Creative Cloud apps, or if you’re plugged into a workflow reliant upon some of the connected features available in Creative Cloud, I can save you some time: forget it. Adobe offers a decent deal for subscribers: between online storage, fonts, and other workflow niceties; you won’t easily replicate that with a single application. However, if you simply need to work with photos and manipulate them for the Web—which is likely a big chunk of Photoshop users out there—then Pixelmator Pro offers some advantages for a lot less money.

[…]

That said, Pixelmator Pro takes advantage of numerous macOS features, including Versions, which lets you move among previous saves with ease. In fact, as I alluded to earlier, the macOS features in Pixelmator Pro give it somewhat of an edge over Photoshop. By relying on macOS features like Metal 2, Wide Color, and CoreML (which powers its machine learning features), Pixelmator Pro moves like a speedboat to Photoshop’s battleship. I wound up launching Pixelmator Pro to do a lot of my photo work simply because (on a 2017 27-inch iMac, anyway) it launched instantly and ran like a cheetah.

I recently used Photoshop for the first time in many years and was surprised at how it feels less like a regular Mac app than I remember.

Color Spaces

Bartosz Ciechanowski:

A color space can specify how the numeric values of the red, green, and blue components map to intensity of the corresponding light source. In other words, the position of a slider may not be equal to intensity of the light the slider controls.

[…]

This may seem all like a pointless transformation, but there is a good reason for doing all this nonlinear mapping. The human eye is not a simple detector of the power of the incoming light – its response is nonlinear. A two-fold increase in emitted number of photons per second will not be perceived as twice as bright light.

If we were to encode the colors using floating point numbers the need for a nonlinear encoding function would be diminished. However, the numeric values of color are often encoded using the familiar 8 bits per component, e.g. in the most common configurations of JPEG and PNG files. Using a nonlinear tone response curve, or TRC for short, lets us maintain more or less perceptual uniformity and use the chunky, quantized range to keep the detail in the darker parts.

Previously:

Accessing the Log and Utilities From the macOS Installer

Twocanoes:

Check out the video to see how to use the keyboard shortcut command-option-control-w to switch back to the standard macOS installer. Also, get access to a grayed out menu for accessing the Terminal and Disk Utility by holding down command-option-control when selecting the menu items.

Your Apps Know Where You Were Last Night

The New York Times (tweet, Hacker News):

At least 75 companies receive anonymous, precise location data from apps whose users enable location services to get local news and weather or other information, The Times found. Several of those businesses claim to track up to 200 million mobile devices in the United States — about half those in use last year. The database reviewed by The Times — a sample of information gathered in 2017 and held by one company — reveals people’s travels in startling detail, accurate to within a few yards and in some cases updated more than 14,000 times a day.

These companies sell, use or analyze the data to cater to advertisers, retail outlets and even hedge funds seeking insights into consumer behavior. It’s a hot market, with sales of location-targeted advertising reaching an estimated $21 billion this year.

[…]

Many location companies say that when phone users enable location services, their data is fair game. But, The Times found, the explanations people see when prompted to give permission are often incomplete or misleading. An app may tell users that granting access to their location will help them get traffic information, but not mention that the data will be shared and sold. That disclosure is often buried in a vague privacy policy.

Jason Koebler:

Along with the investigation, the New York Times published a guide to managing and restricting location data on specific apps. This is easier on iOS than it is Android, and is something everyone should be periodically doing. But the main takeaway, I think, is not just that we need to be more scrupulous about our location data settings. It’s that we need to be much, much more restrictive about the apps that we install on our phones.

[…]

What this means is that the dominant business model on our smartphones is one that’s predicated on monetizing you, and only through paying obsessive attention to your app permissions and seeking paid alternatives can you hope to minimize these impacts on yourself.

Jason Koebler:

Don’t think Apple or Google get enough shit for incentivizing an app economy that relies on free apps that make money by monetizing the data collected by your phone. Allowing the “app is free but we sell your data” as a business model for flashlights and games was disastrous

This is another reason why I think Apple’s Walled Garden is so terrible. For years, it was completely fine to make sketchy apps that monetized data. Why wasn’t Apple protecting its users from that business model?

I suspect Apple would argue this is why you need a walled garden, but Apple has not done a great job of policing it, anyway, so it seems more like protectionism and an obsession with control than anything.

Will Strafach:

I see some are speaking about this as if apps keep their own location databases, but that is not the case. it is so much worse. the location data is sent directly from your phone to big centralized tracking databases owned by one or more of the 75 tracking firms.

Nick Heer:

App developers should, at the very least, be required to be completely forthright in their permissions request dialogs. If a developer is scooping and selling user data, they should be able to defend that practice to users in language that they can understand; if they cannot, then perhaps that’s a practice they should cease.

Previously: