3 ms·
Interesting. I almost though this was going to be an advertisement for Swift, since I saw this exact argument in a WWDC talk. Apple calls Swift a "protocol-ori
by EdJiang 10y ago
Interesting. I almost though this was going to be an advertisement for Swift, since I saw this exact argument in a WWDC talk.
Apple calls Swift a "protocol-oriented" programming language, and with the addition of first class value types, tries to solve these problems in their own way.
I'd definitely suggest people frustrated by the problems outlined in this post to check out the Apple talk on protocol-oriented programming in Swift.
https://developer.apple.com/videos/play/wwdc2015/408/ https://developer.apple.com/videos/play/wwdc2015/408/
- Chyzwar 10y agoThis video only work on Safari or specific app.<lol>
- eyelidlessness 10y agoIt's a great video, and clearly the design behind Swift has tried to address many of the biggest problems with modern OOP. But Swift is by necessity a multi-paradigm language that has to interface with existing OOP code. If you're writing a Mac or iOS app, you're generally writing Cocoa with either Swift or ObjC syntax. Cocoa is unbearably stateful. For a simple app, you not only don't get to work with value types, you typically don't even get functions or methods which return anything. Obviously for something more complex, your non-UI code can absolutely be written with the principles described in that video in mind, but if you try to apply those principles to Cocoa APIs directly, you're going to be fighting against its stateful nature constantly.
- astrange 10y agoIn ObjC everything is a "reference type" since it's a pointer, but most of the data structures are immutable, and some of them are stuffed into tagged pointers, so they really are values after all. (Try implementing that in C++!) CoreAnimation and bindings make AppKit very slightly more functional, but not really.
- rimantas 10y agoEven before Swit apple advocated composition over inheritance. Alas, when teaching programming and OOP somehow inheritance comes up as the most important and interesting part, so few learn proper architecture and a doomed to write articles like this.
- pjmlp 10y agoProtocols are as old as Objective-C, and were the inspiration for interfaces. They are also widely explored in languages that support some kind of polymorphism. The problem is getting the common developer interested in making good use of them.