How Swift is Swift?
realm.io
realm.io
WAT. Because Ruby and Python programmers are just bleeding to death from the thousand cuts of overriding methods during subclassing. Or... not?
More seriously, is there something to Swift here that I'm missing? Because in just about any language I've run across with inheritance, either the superclass(es) are part of a framework that defines a protocol for the inheriting code (e.g. you may/must provide methods X, Y, and Z. These methods must behave according to the following rules {...}), or else the programmer writing the inheriting code takes on the full responsibility of integration.
I probably have no shot of convincing you that inheritance kind of sucks in a short post on a friday night, but I'd just point out that it's not an obscure opinion, there are a sizable number of people that really have no love for the "classic" inheritance model of OOP.
It was surprising enough in context of an otherwise incisive article that I was honestly wondering if there was something specific to Swift and/or the ObjC framework world that posed a unique hazard.
In unsafe languages with raw pointers the issues may be more severe than languages like Python and Ruby but they are generally similar.
I may have overstated the point too, I had notes but not a script. The point is that you need to be careful designing and documenting for subclassing.
Inheritance should evolve...there is plenty that can be done with it (e.g. mixin-style inheritance, dynamic inheritance, family inheritance). At the very least, we should have that conversation on how to address inheritance criticisms.
Invariants aren't things like whether methods are overidden or not, it's things like whether area for a shape can be computed by just knowing a side, exemplified with the familiar case of whether a rectangle should be a subclass of a square, or the other way around
That's a pretty harsh stance. I don't mean to be a jerk, but how much professional experience do you have? Even in good code bases there are frequently complicated hierarchies with non-obvious dependencies that are very easy to screw up even by people who know what they're doing. Good teams find ways of automating the checking on these things so that they can spend their time thinking about other problems, or avoiding the complication altogether, rather than blaming the victim.
Of course, to clarify, it's not really possible to avoid in languages like Java, where it is more or less mandatory due to the design of its standard library (unless you avoid that too, which is a considerably worse idea), but you can still keep your own CODE clean with liberal use of `final` and interfaces.
Personally, I'm consistently baffled when programmers like yourself, who have come to appreciate that "inheritence [sic] is a very, very dangerous tool," continue to defend it so vigorously. If it offered really powerful or unique advantages, sure--but if you take a hard at what it actually provides, it's just syntactic sugar and a performance "optimization" (thin pointers) that's usually pessimal compared to other approaches. The downsides are significant and well-known (as mentioned above, Liskov substitution being undecidable is one consequence, but there are plenty of others). There's no point in making life harder for ourselves.
Adjectives shouldn't be capitalized.
They stole it from a previous language and then swiftly forged the wiki:
http://en.wikipedia.org/wiki/Swift_(parallel_scripting_langu...
SCNR.
Really? How can you design a new language with such a problem? It's not the 80ies anymore.
(I'd like to compare it to a static function call but I haven't yet worked out how to write a static function call in such a way that I can run it in the profiler correctly but it doesn't inline down to nothing.)
It never was the eightyies.
1) there are 5 OSes with more than 100million users. Apple makes two of them 2) there are 4 major web browsers out there, apple makes one of them 3) there are 3 major office suites out there, Apple makes one of them
Apple is one of the biggest software companies in the world. I suspect they are second only to Microsoft in that regard, and yes, I do include Google in that assessment.
If you think what is required to call an instance method on the class it is significant. Roughly, read the address of the object, read the pointer to the class, read the vtable of the class for the function pointer then set registers and stack values and make the function call.
In ObjC method calls are actually via objcmsg_send calls to do the dynamic dispatch.
Computers are fast and they do these things quickly but not having to do them is much faster.