6 ms·
How Swift is Swift?
- nn3 11y ago>Function calls are really slow Really? How can you design a new language with such a problem? It's not the 80ies anymore.
- TillE 11y agoAren't non-inlined function calls in any language "slow"? I'm not seeing any details here, but as Swift is a compiled language with little support for runtime monkey-patching, I assume it's not doing anything especially ridiculous with normal function calls.
- jerf 11y agoYou'd have to define "slow" before you can answer that. I say this not because Go is the epitome of speed, but merely because I happen to have the number on hand from recent testing: Go can call an interface method with no arguments and no return value in a tight loop in about 5 nanoseconds. Is that fast? Is that slow? Depends on your definition. On the machine in question that's about 15 cycles. That strikes me as pretty good in the broad sense, but certainly 15 cycles slower than an inlined call. (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.)
- asQuirreL 11y agoAFAICT Swift does the sensible thing to maintain backwards compatibility with ObjC: When Swift code calls Swift code, the dispatch is static (a jump, and some stack fiddling, when you're counting the change). But if it's interfacing with ObjC then it must necessarily resort to the ObjC runtime's message based dispatch, which is a bit slower.
- ChristianGeek 11y ago"It's not the 80ies anymore." It never was the eightyies.
- M8 11y agoApple is not a software company, they should focus on hardware.
- SiVal 11y agoThey do, usually edge on. Every year they get more focused on what their hardware looks like from the side and seem less concerned with how their software works when you're facing the screen.
- demallien 11y agoI was just going to down vote you, that's all trolling deserves on HN, but on the off chance that you're just ignorant, and not actually trolling: 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.
- rimantas 11y ago"If you are serious about software you should make your own hardware." So Apple not only is software company, they are serious about it.
- josephlord 11y agoIf you put a dynamically dispatched function call in the middle of a tight loop you will slow it down significantly. As I say in the talk in most code it just doesn't matter. It is all relative. A function call is fast relative to a context switch or and I/O operation. 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.
- zyxley 11y ago> Exactly how Swift is Swift? Adjectives shouldn't be capitalized.
- bcherry 11y agotl;dr Swift could not be more Swift but could definitely be more swift.
- savanaly 11y agoIt was honestly confusing to me. I was like, is the language named after some design philosophy that it is supposed to embody? Because then the title would make sense.
- _random_ 11y ago"is the language named after some design philosophy that it is supposed to embody" They stole it from a previous language and then swiftly forged the wiki: http://en.wikipedia.org/wiki/Swift_(parallel_scripting_language) http://en.wikipedia.org/wiki/Swift_(parallel_scripting_langu...
- deleted 11y ago[deleted]
- Alphasite_ 11y agoI think that's the joke.
- xrstf 11y agoThat's not an adjective, that's a reference to Taylor Swift on Security. SCNR.
- brudgers 11y agoOnce Carly Rae Jepson began speaking out about database partitioning, surely it was only a matter of time.
- MBCook 11y ago
- saidajigumi 11y ago> With most classes, unless you design them really carefully, your methods are often at risk from being overridden by others in ways that don’t meet expectations — especially if it mutates the object and does so in a different way. 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.
- overgard 11y agoI can't speak for the author, but you could take it as an argument against inheritance in general. There are a lot of smart people in that boat -- I think at one point even James Gosling said he might have left inheritance out of java if he had it to do over again. 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.
- cpeterso 11y agoConsider that neither Rust nor Go have traditional class inheritance. It's definitely out of favor these days. :)
- saidajigumi 11y agoNo doubt, and I'm not really debating the language design tradeoffs involved in various approaches to OOP (or heck, typing in general). It's just this kind of talk comes up from time to time, seems to be fear-driven, and ignores the pragmatic practices that have been developed to work with inheritance (or any number of other language features that trigger a similar reaction, c.f. Pythonistas vs Rubyists on the topic of monkey-patching). 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.
- MichaelCrawford 11y agoHe had a price put on his head by the British Crown.
- josephlord 11y agoSpeaker here, a little late to the conversation though. Let me know if there are any particular questions, I'll read through everything later and respond.