5 ms·
A domain specialist writing software for embedded devices, perhaps has not a lot of use for polymorphism or functional programming. Not everyone needs to know e
by pinopinopino 6y ago
A domain specialist writing software for embedded devices, perhaps has not a lot of use for polymorphism or functional programming. Not everyone needs to know everything, tat is ok.
- ChrisMarshallNY 6y agoTrue, dat (I believe that Linus is a rabid "straight C" man). However, these were people answering Swift questions. Swift introduces "Protocol-Oriented Programming" as dogma, which has some really salient points, but is not the Philosopher's Stone of software development. EDIT: Added "as dogma"
- mpweiher 6y agoWell, for one it's not actually new. Protocols are interfaces, sets of messages. Hmm...that would be message-oriented programming, which is what Smalltalk for example has been all about. First equating OO with heavy use of static typing and inheritance (which wasn't the idea), noting that that doesn't actually work (surprise!) and then "inventing" POP...sigh. https://blog.metaobject.com/2015/06/protocol-oriented-programming-is-object.html https://blog.metaobject.com/2015/06/protocol-oriented-progra...
- zozbot234 6y agoNo, Smalltalk does not have "protocols", traits or interfaces. Everything is dynamically typed ala Objective C.
- mpweiher 6y agoLast sentence first: Objective-C certainly has (optional) static types and protocols[1][2], or as Java calls them, interfaces. In fact Java interfaces were "borrowed" from Objective-C[3]. In fact, Objective-C needs the types of a message's arguments and return value in order to generate correct code in the general case, and since message names can be ambiguous it needs to know the static type of the receiver (or "close enough") in order to know those static types in the message. If all arguments and the return value are objects, then this is not necessary, this "id subset" has some nice properties.[4] In Smalltalk, the messages an object responds to are called its protocol.[5] "Every object in Smalltalk, even a lowly integer, has a set of messages, a protocol, that defines the explicit communication to which that object can respond." Now that that single protocol for the entire object can be split into multiple meaningful protocols should be obvious, but Alan Kay has also explicitly talked about objects embodying "multiple algebras"[6] The basic idea of "protocol oriented programming" is that you focus on what an object can do (its interface/protocol) rather than what it is (its class/type) and that Smalltalk certainly did. Whether you check this statically is a secondary and certainly orthogonal concern, but of course there were and are statically typed variants of Smalltalk (such as Strongtal) and type-systems for others Smalltalks. Traits were introduced in 2003 for Squeak Smalltalk.[7] [1] https://en.wikipedia.org/wiki/Objective-C#Protocols https://en.wikipedia.org/wiki/Objective-C#Protocols [2] https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithProtocols/WorkingwithProtocols.html#//apple_ref/doc/uid/TP40011210-CH11-SW2 https://developer.apple.com/library/archive/documentation/Co... [3] https://cs.gmu.edu/~sean/stuff/java-objc.html https://cs.gmu.edu/~sean/stuff/java-objc.html [4] https://blog.metaobject.com/2014/05/the-spidy-subset-or-avoiding-copeland.html https://blog.metaobject.com/2014/05/the-spidy-subset-or-avoi... [5] https://www.cs.virginia.edu/~evans/cs655/readings/smalltalk.html https://www.cs.virginia.edu/~evans/cs655/readings/smalltalk.... [6] http://www.cs.uni.edu/~wallingf/blog/archives/monthly/2014-06.html http://www.cs.uni.edu/~wallingf/blog/archives/monthly/2014-0... [7] http://scg.unibe.ch/archive/papers/Scha03aTraits.pdf http://scg.unibe.ch/archive/papers/Scha03aTraits.pdf
- wool_gather 6y agoSwift did not introduce "Protocol-Oriented Programming". As misinterpreted and broadly applied, it's been present in (among others) Java and Objective-C forever. As actually intended (listen to Dave Abrahams clarify what he meant on John Sundell's recent podcast) it has much more to do with parametric types and functions that operate on them, and is almost directly inherited from ideas that have been in C++ since the STL.
- mpweiher 6y agoNot aimed at you, but... Misinterpreted? Sorry, but the definition of a protocol, particular in the context of Swift/Objective-C has been fixed for around a quarter of a century. And of course, those protocols were what he talked about in his presentation. If he meant something different, possibly he should have (a) picked a different term and (b) talked about something else at WWDC.
- wool_gather 6y agoGood points; I can't really disagree.
- ChrisMarshallNY 6y agoYou guys are both right, but I should have rephrased that "introduces as dogma." I get a bit discouraged, when smart, energetic engineers (usually young), latch onto the buzzwürd du jour, and declare it to be "The One, True, Path; all heathens and apostates must be cleansed with fire." I say that, as having done exactly that, myself. Looking back at my thinking, then, makes me wince.