Archive for August 19, 2015

Wednesday, August 19, 2015

Top 10 Worst C# Features

Eric Lippert (via Chris Lattner, comments):

When I was on the C# design team, several times a year we would have “meet the team” events at conferences, where we would take questions from C# enthusiasts. Probably the most common question we consistently got was “Are there any language design decisions that you now regret?” and my answer is “Good heavens, yes!”

This article presents my “bottom 10” list of features in C# that I wish had been designed differently, with the lessons we can learn about language design from each decision.

WebKit Backdrop Filters

Brent Fulgham:

The User Interface design language for iOS 7 and OS X Yosemite changed to incorporate some beautiful backdrop blur effects. This layering gives a sense of depth, while preventing detail from the content underneath from cluttering the foreground.

The following image shows the WebKit media controls on top of a video. Notice that you can see some of the background content through the frosted glass effect.

[…]

Until recently, there was no standards-compliant method for producing these kinds of effects. Many designers were forced to create the illusion of blurred backdrops using pre-rendered background content and carefully clipping and positioning these assets to achieve the desired effect.

The regular system media controls respect the “Reduce transparency” setting in the Accessibility preferences pane. The WebKit background filters do not.

Generic “Functions” in Objective-C

Arkadiusz Holko:

Since the only way to declare generic parameters and return values is through a class interface, we’ll wrap our map method in a new class[…]

[…]

AHKArrayMapper’s only method takes an array of InputType objects and a block mapping from InputType to OutputType. It returns an array of OutputType objects. The implementation doesn’t really differ from the one without generics, because generics aren’t available in implementation files[…]

Objective-C generics are useful for interfacing with Swift and for documenting APIs. I’m not sure that it really makes sense to code with them this way.

Creating a Kill-Switched VPN With PIA and Little Snitch

Matt Henderson:

PIA provides a kill-switch feature, but just like Cloak, enabling it will affect local-network services. I’ve discovered a solution, however, achieving the same functionality without affecting local-network services, through the use of Little Snitch—a Mac OS X application-level packet filter—and it’s support for automatic profile switching.

[…]

So, in summary, whenever my Mac is not connected to a VPN (with the exeption of mobile tethering as described below), my “Public (Kill Traffic)” Little Snitch profile is automatically selected, preventing all incoming and outgoing connections.

[…]

I have one other Little Snitch profile, unrelated to VPN connectivity, called “Mobile”. This profile is activated whenever my Mac is connected to my iPhone’s or iPad’s “Personal Hotspot”. The purpose of this profile is to minimize my iOS device’s data usage. As you can see from the screenshot, this profile kills traffic from apps like Dropbox and BitTorrent Sync.

Update (2015-08-21): Matt Henderson:

The [iVPN] app seemed to function just fine in terms of establishing a VPN connection, and the data rate was fine. But the UI did behave a bit wonky at times. For example, often when I’d open the app (after being logged in), the main information window continually displayed a spinner, as if it were stuck. The second issue I noticed was that it didn’t offer the feature provided by Cloak and PIA to auto-detect the best server for connection. Finally, I found that it didn’t offer a kill-switch—which, alone, wouldn’t have been a show-stopper, as I found a work around with Little Snitch.

[…]

Having read this article, Sam from iVPN reached out. In a very thoughtful email, he explained how BitPay’s platform currently doesn’t allow for sub-management accounts, and so in fact, only the main administrator (who has access to all the account’s funds) can issue a refund, and he explained that BitPay’s refund process has been very unpredictable. He also sent a few screenshots of their forthcoming update to their Mac client and it looks very good!

Ripping CDs and Backing Up Content Is Illegal in the UK

Ernesto Van der Sar (via Nick Heer):

The High Court recently overturned private copying exceptions introduced last year by the UK Government, once again outlawing the habits of millions of citizens. The Intellectual Property Office today explains that ripping a CD in iTunes is no longer permitted, and neither is backing up your computer if it contains copyrighted content.

[…]

The IPO specifically notes that copying a CD to an MP3 player is not permitted. This means that iTunes’ popular ripping feature, which Apple actively promotes during the software’s installation, is illegal.

Also, under the current law iTunes is actively facilitating copyright infringement by promoting their CD-ripping functionality. This means that the company could face significant claims for damages.

Caitlin McGarry:

But the British government is apparently not thrilled with the High Court’s decision. The IPO office told TorrentFreak that the government is “carefully considering the implications of the ruling and the available options before deciding any future course of action.”

And if you live in the UK and have copies of your music library on your computer like a normal human, don’t fret too much. Apparently the government is pretty sure that no one has been taken to court over CD-ripping for personal use.

Testing Swift’s ErrorType

Marius Rackwitz:

Further investigation via LLDB reveals that the protocol has some hidden requirements.

(lldb) type lookup ErrorType
protocol ErrorType {
  var _domain: Swift.String { get }
  var _code: Swift.Int { get }
}

It becomes clear how NSError fulfills this definition: it has these properties, backed by ivars, which Swift can access without dynamic dispatch. What is still unclear is how Swift’s first class enums can automatically fulfill this protocol. Perhaps there is still some magic involved?

[…]

Sure, you could catch it as any generic error and then manually check the fields _domain and _code, but there are more elegant alternatives.