News for hackers. Stuff that matters.
Re:App Developers on Swift Evolution by kstrauser on Tuesday December 22, 2015 @07:10PM (#10781219)
Because I have no experience with Swift, could someone more informed explain this to me? How would my subclassing an Apple-provided class and overriding its methods affect anyone but me? In Python, if I write:

    class MyRequest(requests.Request):
        def get(self): do_something_stupid()
then my coworkers can still use `requests.Request` itself without getting my bad behavior, and if they find themselves looking at a flaw in my code, they know not to blame the upstream author. What's different about the Swift situation?

I'm kind of horrified at the idea of an OOP language that wouldn't easily let me override a parent class's behavior. If I break something in the subclass, it's on me to fix it. That never reflects poorly on that parent class.

Re:App Developers on Swift Evolution by winstonewert on Tuesday December 22, 2015 @07:58PM (#10781407)
Sure, it only affects you. The problem is that changes to superclass can now break your code.

For example, perhaps right now the function looks like this:

    def get(self, url, method='GET'):
        ...

    def post(self, url):
        self.get(url, method='POST')
You override get, to add some additional functionality. All is fine.

Then somebody realizes that the original code was silly, and rewrites it:

    def get(self, url, method='GET'):
        if method != 'GET':
           print "DEPRECATED!"
        self.request(url, method=method)

    def post(self, url):
        self.request(url, method='POST')
It seems to do the same thing, and probably passes all the same tests. But suddenly, now your code doesn't get called for post requests and your additional functionality breaks in a mysterious way.

Perhaps its still your fault for doing a bad job subclassing, but its going to look like its the fault of the person who fixed the parent class.

Re:App Developers on Swift Evolution by dplgk on Sunday January 03, 2016 @02:49PM (#10832016)
> changes to superclass can now break your code

The same exact thing happens when using composition.

Re:App Developers on Swift Evolution by kenferry on Tuesday December 22, 2015 @07:16PM (#10781244)
When a point release of the operating system breaks your app, the user doesn't care (or understand) whose fault it is, they're just ticked off. Apple cares about that.
Re:App Developers on Swift Evolution by coldtea on Tuesday December 22, 2015 @09:02PM (#10781597)
How is that different from your code not working because of an Apple bug (which they take months or years to solve in some cases)?

The end result is still a broken app (just due to a different reason), and the user will blame either the third party programmer or Apple, and mostly usually the programmer.

Re:App Developers on Swift Evolution by eridius on Tuesday December 22, 2015 @11:27PM (#10781956)
Part of the reason why it's hard to fix bugs that people have worked around is because the fix often breaks the workarounds. Which causes a problem for Apple either way; either they can leave the bug in and let everyone work around it, or they can fix the bug and break all of the myriad apps that use the workaround. Depending on the circumstances, they can actually put workarounds into the frameworks to preserve bugs for apps linked against older versions of the SDK or for apps with specific bundle IDs, but not every fix is amenable to that kind of solution.

Which is to say, there's a good argument for the idea that reducing the ability to monkey-patch framework classes will make it much easier to actually fix bugs in the frameworks.

Re:App Developers on Swift Evolution by coldtea on Wednesday December 23, 2015 @05:22AM (#10782753)
>Part of the reason why it's hard to fix bugs that people have worked around is because the fix often breaks the workarounds.

That was a problem for Microsoft, Apple, from all we publicly know from their releases, never treated that as a problem. They went ahead with the fixes even if it broke previous workarounds.

Re:App Developers on Swift Evolution by Someone on Wednesday December 23, 2015 @04:05AM (#10782559)
If an OS upgrade breaks lots of programs or even one heavily used program, chances are users will blame Apple, not the developers of said apps.

Also, part of the reason that it takes them long to fix certain bugs may be concerns about seemingly internal changes breaking applications. They cannot refactor methods (rename or even change an argument list) in any class they ship because someone, somewhere, might override one of its methods.

In that light, I think the change makes sense. Of course, Apple could just add private/sealed to all their classes, if only just before shipping, but why make the typical choice more work to write than the exception?

Re:App Developers on Swift Evolution by coldtea on Wednesday December 23, 2015 @05:21AM (#10782749)
>If an OS upgrade breaks lots of programs or even one heavily used program, chances are users will blame Apple, not the developers of said apps.

The user just knows said program doesn't work. And it's not necessary that an OS upgrade will break lots of programs that a user has, it can break this or that program in subtle ways, or classes of programs (e.g. those using the X api) of which a typical user will have only few installed.

E.g. if it breaks third-party camera apps, users might not normally have 5 of those, to see that they all break at the same time, but just 1 additional on top of Apple's (if that).

Re:App Developers on Swift Evolution by Someone on Wednesday December 23, 2015 @04:13PM (#10785686)
The user knows the program worked yesterday, before (s)he upgraded the OS. Correlation is not causation, but I think you will get more hits googling "<OS> update breaks <application name>" than googling "<OS> update uncovers bugs in <application name>" for whatever currently used choices you pick for "<OS>" and "<application name>".
Re:App Developers on Swift Evolution by coldtea on Saturday December 26, 2015 @09:03AM (#10794134)
Users don't always use all of their apps apps every day. If you go to the app 20 days after updating the OS, good luck remembering the OS update 3 weeks ago and deducing it was that which broke it.

Especially since, with the ability for apps to upgrade automatically, many don't even keep track when this or that app was updated.

Of course it usually is even more obscure, e.g. the bug only affects PART of the app's functionality, a part which you might have not invoked in your last run before the OS update. So, another deduction for many would be that that feature works intermittently because it's not coded well, etc.

Besides, even when the user can deduce that the OS broke the app, they don't complain to Apple, but to the software maker "fix your app", "where's the update release?", etc.

Re:App Developers on Swift Evolution by kalleboo on Thursday December 24, 2015 @02:42AM (#10787479)
Users even blame us when the App store fails to download updates and leave 1-star reviews
Re:App Developers on Swift Evolution by kenferry on Wednesday December 23, 2015 @04:10PM (#10785662)
The difference is that in that case the bug never makes it out to the end user.

Apple writes a new API. It has a problem. You try to adopt it, it doesn't work. You don't just ship that, you do something else.

Unpleasant, but doesn't hit the user.

Re:App Developers on Swift Evolution by coldtea on Wednesday December 23, 2015 @04:42PM (#10785843)
You missed the obvious fact that the bug change might happen to an API you already use. It doesn't have to be a new API -- just a new release of it by Apple.

So the problem remains: you can't easily extend the class with your own fix to bring out a bugfix release for your app.

Re:App Developers on Swift Evolution by kentosi on Tuesday December 22, 2015 @07:33PM (#10781315)
If you're the final user of an API, then yeah, go for gold and change whatever you want.

But if you're working in a team (or contributing a patch to a Github project), and you override something crutial like String.subtring(), then things could get out of hand.

Re:App Developers on Swift Evolution by twoodfin on Tuesday December 22, 2015 @08:01PM (#10781417)
As pcwalton points out above, allowing (potential) dynamic dispatching behavior for every method is a significant performance drag, especially when (as with Swift) you won't be supplying a JIT to devirtualize and inline at runtime.