▲ | ryandrake 10 hours ago | |||||||||||||||||||||||||
I don’t understand what goes through the developer’s mind. A method is marked as private. It’s documented as not to be used by developers. Further documentation says that using it may break your application in strange ways now or in the future. Despite all this, the developer concludes: “yea, I think it’s a good idea to use this API!” Then, later when something breaks, it’s Shocked Pikachu all around. | ||||||||||||||||||||||||||
▲ | runjake 9 hours ago | parent | next [-] | |||||||||||||||||||||||||
> I don’t understand what goes through the developer’s mind. I'm not defending anyone here, but sometimes it's to work around bugs in public APIs that never get fixed. And sometimes it's because some perceived needed functionality isn't exposed in public APIs. They figure "It'd be a lot easier to use this private API. We can just fix it if it breaks.", not really realizing the ramifications, for example a lot of apps use older versions of Electron -- some even EOL. Is the Electron team now going to backport this fix to several versions back? Sounds... involved. | ||||||||||||||||||||||||||
▲ | thfuran 9 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||
The alternative to using private methods or reflectively mucking about with library/platform internals isn't always "do the same thing but with only public API"; it's sometimes "you can't possibly fix the bug or implement the feature that you want to". It sure does increase maintenance burden though. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
▲ | tclancy 9 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||
I get it but a lot of the war stories from Raymond Chen's blog https://devblogs.microsoft.com/oldnewthing/ were about helping major corporations unscrew something that had relied on a private Windows API because there hadn't been a good way to do it. I would guess most cases of people choosing to rely on a private method are laziness or lack of knowledge about "the right way" (or call it bad documentation), but not 100%. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
▲ | toast0 9 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||
Ok, but > // By overriding this built-in method the corners of the vibrant view (if set) will be smooth. If you don't override the built-in method, the corners won't be smooth. Jagged corners cause thousands of eye injuries every day. Using (or overriding) private APIs comes with risks, but sometimes it's the only way to get things done. Of course, it comes with consequences too. Sometimes vendors test their new releases with commonly use applications and reach out when they've changed things and breakage results, but testing releases isn't webscale. | ||||||||||||||||||||||||||
▲ | grishka 6 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||
Sometimes you just can't achieve something with public APIs. Especially on Apple OSes, they love making genuinely useful APIs private for no good reason while heavily using them in their own apps. Of course, if you use a private API, you're on your own if your app breaks because of it. I myself have done my fair share of using private APIs on Android. Ideally, you should test your app on beta versions of every upcoming major OS release to make sure it doesn't break. Even more ideally, there's a public equivalent starting with some OS version and you only use the private one until that version, then nothing will ever break. | ||||||||||||||||||||||||||
▲ | jcelerier 3 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||
If breaking encapsulation delivers value under the form of features-making-users-happy for a couple years and the fix when it breaks is a matter of a couple weeks (and, like here, a line of code) then it's definitely the right tradeoff | ||||||||||||||||||||||||||
▲ | porridgeraisin 9 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||
> I don't understand Well. This is hardly the funniest example then. Check this one out: https://github.com/reactjs/react.dev/issues/3896 | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
▲ | stalfosknight 10 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||
And there are people who's default setting is to hate/blame Apple because it's fashionable to do so and they are defending not just the use of but also overriding an API explicitly marked as private. I don't get it. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
▲ | whywhywhywhy 8 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||
Apple has to take some of the blame from this, MacOS without Electron apps is a much less useful proposition. If they knew they were going to change this API in this release it would have made sense to reach out and offer a public way to Electron. End of the day the needs of users running Electron apps outweighs whatever opinions the internal Apple team has about their APIs | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
▲ | mvdtnz 7 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||
> Then, later when something breaks, it’s Shocked Pikachu all around This isn't really true. When something breaks it's generally "darn, we knew it would happen eventually". | ||||||||||||||||||||||||||
▲ | cyberax 10 hours ago | parent | prev [-] | |||||||||||||||||||||||||
Yeah, but you HATE how the system behaves because some great spark at Apple thought that corners must always be _this_ rounded. |