TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

My misalignment with Apple's love affair with Swift

139 pointsby mgraysonalmost 7 years ago

21 comments

chadcmulliganalmost 7 years ago
Its interesting how languages divide opinion. For me I think Swift is the best language around. One of the issues not addressed in the article (I believe) is performance, Swift is faster than Objective C because of the static type checking, which is a good thing.<p>It has the advantages of C# as a language but no garbage collection, granted the reference counting in Swift can be problematic, but it seems to be improving with each release.<p>The functional programming aspect of swift I find useful. There are a number of features in swift that decreases the amount of code - e.g. if let&#x2F;guard. The use of optional types increases program safety.<p>The fact that you can use classes declared elsewhere without any consideration of dependency I find very powerful, and of course with great power comes great responsibility.<p>The power of swift collections is fantastic, and the syntax compared to Objective C is so succinct.<p>Many more...
评论 #17280554 未加载
评论 #17282200 未加载
评论 #17280286 未加载
评论 #17281544 未加载
评论 #17280990 未加载
jordansmithnzalmost 7 years ago
As someone with a significant amount of experience in both ObjC and Swift (4+ full-time years in each), I don&#x27;t agree with this article. Yes, Swift isn&#x27;t perfect, it has its flaws. Totally agree there. It&#x27;s not perfectly integrated with Cocoa either, as the author mentions.<p>However, to say that Swift is a regression over Objective C seems very short sighted to me. Can you imagine if Apple continued with Objective-C? There would be no way to reverse decade old decisions that simply aren&#x27;t the right decision anymore. Every new feature would need to be built on top of code from 1984. Swift was very future focused from the get go, and is a bid to ensure that developing for Apple devices in 2025 is not an archaic mess.<p>Like anything new, it&#x27;s not perfect at first. That is the world we live in now. However, Swift is getting incrementally better at a very good pace. There are some reasons left to prefer Objective-C right now, but I&#x27;m sure that in a few years these reasons will be far fewer.<p>My own opinion is that I&#x27;m much more productive writing Swift, after spending a similar amount of time with each language. If you think the same is true of Objective-C, then that&#x27;s great - there are certainly still some upsides to developing with Objective-C. However, to say that Swift is a mistake is something that I can&#x27;t reason with, since it&#x27;s one of Apple&#x27;s most forward thinking decisions to date.
评论 #17281307 未加载
评论 #17287914 未加载
评论 #17281211 未加载
rockshassaalmost 7 years ago
IMO Swift is a language written by a compiler guy to solve compiler problems. the syntax is dense because it forces you to make a lot of decisions that could otherwise go unmade in objc.<p>If a variable is read-only, you&#x27;re forced to think about that by deciding between let&#x2F;var. contrast this with objc, where all vars are writable unless you do the extra work of adding the const keyword. objc makes us do more work to get the faster (and safer) behavior.<p>Similar with Optionals, you&#x27;re now forced to decide right away if a parameter can ever be nil, whereas with objc you didn&#x27;t need to declare nullability. Again, it makes the safest and fastest choice easier to make, and allowing nullability is actually more work.<p>Generally Swift forces you to pass as much information to the compiler as possible at compile time, and it does it with a delightfully readable syntax. This theme repeats itself throughout the language. more information at compile time is always going to result in safer and more predictable behavior.<p>full disclosure: i&#x27;m an iOS dev working in objc and swift. i love both languages, and i think swift is the obvious path forward.
评论 #17281561 未加载
评论 #17281485 未加载
ardit33almost 7 years ago
I agree with the author.<p>&quot;So now contrast that to Swift. First of all: Which question did it desire to answer? Think about it. There is no one clean answer.&quot;<p>I feel that Swift is more just like a language designed to be a syntax swap of objective-c, making few things better, yet some other ones worse.<p>Sure, it might be more welcoming to people used to java&#x2F;javascript type of language syntax, but overall I think it is two step backwards on language design and functionality.<p>To folks that are proficient with Objective-C,<p>1) How do you like working in Swift?<p>2) Are you more productive (for medium or large projects)?<p>3) Do you enjoy it more?<p>In my part (if you are already very proficient with Objective-C), those answers are Nos. If you are new to iOS though, Swift is easier to get started.<p><a href="https:&#x2F;&#x2F;www.hackingwithswift.com&#x2F;articles&#x2F;27&#x2F;why-many-developers-still-prefer-objective-c-to-swift" rel="nofollow">https:&#x2F;&#x2F;www.hackingwithswift.com&#x2F;articles&#x2F;27&#x2F;why-many-develo...</a>
评论 #17280155 未加载
评论 #17280665 未加载
评论 #17280103 未加载
评论 #17281631 未加载
评论 #17280398 未加载
评论 #17282122 未加载
评论 #17284042 未加载
评论 #17280771 未加载
评论 #17289902 未加载
评论 #17281061 未加载
elcritchalmost 7 years ago
&gt; It seems to have been driven by the needs of the compiler and the gaps that needed to be filled for the static analyzer. Those seem to have been super-charged instead of catering to app developer&#x27;s actual needs: efficient, hassle free, productive (iOS) App development.<p>This. Even then Swift (the last I really looked like v2) was full of special one offs and smacked of design by committee.<p>It would’ve been much more interesting if they’d worked on making an updated Objective C language. Maybe even break C superset constraint and add in some new syntax. It’s even more sad that ObjC message passing can support distributed systems.<p>Probably time to move back to Linux. Too bad GNUStep never took off. Or Etoile (?).
评论 #17280297 未加载
评论 #17282305 未加载
评论 #17280304 未加载
bsaulalmost 7 years ago
As a mobile &amp; fullstack developper, my road also takes me to different languages but for very different reason. To me swift is at its core the best language by far. I love the way it lets me model pretty much every problem using combination of enum and struct, while keeping everything value-based and type safe. If you add null safety, there is no other (mainstream) language that checks all those marks.<p>But the OP is right in that Swift aims at being a silver bullet, yet the pace at which it evolves compared to that goal is absolutely scary. Concurrency hasn&#x27;t moved at all, and in the meantime server side performance is a total disaster (<a href="https:&#x2F;&#x2F;www.techempower.com&#x2F;benchmarks&#x2F;#section=data-r16&amp;hw=ph&amp;test=fortune" rel="nofollow">https:&#x2F;&#x2F;www.techempower.com&#x2F;benchmarks&#x2F;#section=data-r16&amp;hw=...</a>).<p>There is also nothing for cross-platform development (<i>real</i> cross-platform, not just iOS and macOS).<p>So, personally, my next experiment is going to be full stack dart.
评论 #17280413 未加载
评论 #17281034 未加载
majewskyalmost 7 years ago
&gt; Swift code might end up being more correct in the end. It also might alert you to edge cases early on. However, the flip side is it inhibits your creativity while writing. When starting out to program, the way I enjoy working, I don&#x27;t yet know how the API is best expressed. So I try out different ways to express it until I find a sweet spot. Then I go back and unify accordingly.<p>&gt; Swift actively distracts me in that endeavor by making me answer questions I really don&#x27;t want to answer right now. Yes, stuff might be less correct in the meantime, but heck that is what I want during the design phase. Find my concept, sweet spot, iterate, pivot quickly.<p>I have much of the same feelings with Rust.
评论 #17282171 未加载
protomythalmost 7 years ago
I find myself in the same boat. I&#x27;ve programmed in Objective-C since 1995 on NeXTSTEP. I love Objective-C, but realize it has quite a lot of warts.<p>My problem with Swift is my feeling that the people who developed it don&#x27;t like Objective-C. It really feels like the Java direction Apple tried to take in the late 1990s. You can argue Nil messaging but its part of the landscape.<p>Plus, I really find weird way they adapted message passing to the C++&#x2F;Javascript like syntax. A simple obj.(selector: value selector2:value) would have made it much easier to go back and forth. This is mismatch affects things. Never mind the added punctuation that need not be there.<p>I should be much more productive, but I&#x27;m not and that sucks.
lxcidalmost 7 years ago
I love Swift but at 4.2, its still a distance from being useable for me.<p>Swift is suppose to be modern, only to be burden by API compatibility work, which is non trivia.<p>This significantly slow certain important developments like ABI Stability (5.0), Full Generic (5.0), Concurrency (Maybe 6.0)?<p>A year since 4.0 release and in the coming few months, 4.2 will be release and not 5.0. This mean the timeline for 6.0 get push even further back.<p>While Swift is modern in area like optionality, first class immutable struct and (my favourite feature) enum with associated values, it lack many other modern features we come to expect from modern language. e.g. callback are still the way for async path control (1 of the regret of Ryan Dahl in his JSConf EU talk <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=M3BM9TB-8yA" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=M3BM9TB-8yA</a>)<p>1.0 to 3.0 was spent getting the API right. This is a significant positive investment in the long run, but as someone who have to maintain codes, it was not pleasant at all and I still have code stuck in 1.0&#x2F;2.0 eras. I have crashes with getting conditional conformance working with generic. Some wasn&#x27;t crashing on 1.0 or 2.0 but crash on 3.0. Swift clearing is a WIP.<p>---<p>At the same time, TypeScript happened. TypeScript turn JavaScript into optional typed language. I see JavaScript and Objective-C in similar light. Since Objective-C start getting some syntactic sugar (generic, nullability), I wonder what if they have taken the TypeScript approach instead.<p>TypeScript have no choice but be pragmatic (probably after seeing how Dart was not adopted by the larger community for going the Swift way).<p>Apple basically act like a benevolent dictator, whatever direction they take is more or less the future, we have to figure out how to work around the new &quot;world&quot; order, which get updated every year at June.<p>The best iOS&#x2F;Mac developer thrive in this environment and get handsomely rewarded (App Store ranking, recognition from Apple), I tried and failed miserably.
nextstepalmost 7 years ago
This post is lacking in details. What does this mean?<p>&gt;&gt; “It wants to be strongly typed, but at the same time so convenient in type inference, that it falls over its own feet while trying to grasp simple expressions, and they become too complex to manage. By design.”<p>What is an example of an expression that is tripping over its own feet?
评论 #17282068 未加载
pkulakalmost 7 years ago
I think the problem it solves is developer PR with Objective C, which looks like absolute hell the first time you see it. Swift looks like a sleek scripting language.
评论 #17280740 未加载
lifeisstillgoodalmost 7 years ago
&gt; Swift actively distracts me in that endeavor by making me answer questions I really don&#x27;t want to answer right now. Yes, stuff might be less correct in the meantime, but heck that is what I want during the design phase. Find my concept, sweet spot, iterate, pivot quickly.<p>This is also what annoys me about TDD - writing code is a process of refinement - if I know exactly what the API I am going to program against looks like, if I know the API I will offer and I know the internals of my code are <i>before</i> I write code then hell, I have done it before.<p>Often times coding is exploring.
评论 #17280343 未加载
评论 #17280654 未加载
Apocryphonalmost 7 years ago
Steven Sinofsky thread here: <a href="https:&#x2F;&#x2F;twitter.com&#x2F;stevesi&#x2F;status&#x2F;1005848814048047105" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;stevesi&#x2F;status&#x2F;1005848814048047105</a><p>Some other good ones tracked by Michael Tsai: <a href="https:&#x2F;&#x2F;mjtsai.com&#x2F;blog&#x2F;2018&#x2F;06&#x2F;10&#x2F;on-my-misalignment-with-apples-love-affair-with-swift&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mjtsai.com&#x2F;blog&#x2F;2018&#x2F;06&#x2F;10&#x2F;on-my-misalignment-with-a...</a>
评论 #17282450 未加载
bla2almost 7 years ago
There have always been heated arguments about which language is better, but not many languages get as many &quot;I don&#x27;t like it&quot; blog posts as Swift (maybe Go). It&#x27;s probably just because people are usually free to choose a language, but are getting their arm twisted to use Swift on iOS. That&#x27;s fine for people who like Swift, but leaves no option but complain to the others.
评论 #17282459 未加载
saagarjhaalmost 7 years ago
The author seems to not be up-to-date with modern Swift:<p>&gt; Adding compile time static dispatch, and making dynamic dispatch and message passing a second class citizen and introspection a non-feature.<p>There was a proposal recently to make this first-class, and not just limited to Objective-C.<p>&gt; Classify the implicit optionality of objects purely as a source of bugs.<p>Not purely, but often optionality is a source of bugs.<p>&gt; At the same time it failed to attack, solve and support some of the most prominent current and future computing problems, which in my book all would be more important than most of the areas it tries to be good in:<p>&gt; concurrency<p>Concurrency is being hashed out, and will probably be available in a later version of Swift.<p>&gt; overall API interaction complexity<p>The Swift API is refreshingly small. Are you talking about Foundation?<p>&gt; debug-ability<p>What&#x27;s wrong with the debug-ability, especially with solutions like playgrounds?<p>&gt; actual App and UI development<p>…this is literally the main use of Swift.<p>&gt; developer productivity<p>Personally, I feel it&#x27;s much improved.<p>&gt; While Apple did a great job on exposing Cocoa&#x2F;Foundation as graspable into Swift as they could, there is still great tension in the way Swift wants to see the world, and the design paradigms that created the existing frameworks. That tension is not resolved yet, and since it is a design conflict, essentially can&#x27;t be resolved. Just mitigated. From old foundational design patterns of Cocoa, like delegation, data sources, flat class hierarchies, over to the way the collection classes work, and how forgiving the API in general should be.<p>This is almost a non-issue these days, unless you&#x27;re interacting with C APIs.<p>&gt; Just imagine a world where Objective‑C would have gotten the same amount of drive and attention Swift got from Apple?<p>The ten years before Swift existed?
评论 #17280510 未加载
评论 #17280727 未加载
评论 #17281651 未加载
_0w8talmost 7 years ago
A friend of mine have been working with porting to iPhone some Android and web apps. I recently asked his opinion of Swift. He said he had no idea as the essential libraries the apps use are in C or Objective-C, so there were no choice but to use Objective-C for the apps. This was surprising, as I thought that calling Objective-C from Swift should be transparent. But it turned out it was not as many small but important details make the whole thing rather messy. So I also wandered what exactly Apple wanted to get with Swift if it lacks even in Objective-C interoperability.
评论 #17280362 未加载
评论 #17280370 未加载
评论 #17281657 未加载
seandougallalmost 7 years ago
These complaints largely seem to come down to Swift not really being what the author expected it to be. His list of speculations as to Apple&#x27;s motivations, in particular:<p>&gt; It should scale from App&#x2F;UI language down to system language.<p>Did I miss something where Apple or the Swift team said anything about writing a kernel in Swift? They wanted to make it fast enough for performance-critical situations, yes, but there are plenty of those in userspace -- and I haven&#x27;t found Obj-C&#x27;s inability to perform in those situations to be an asset.<p>&gt; It should inter-op with existing Foundation and Cocoa, but still bring its own wide reaching standard library, adding a lot of duplication.<p>This is missing the forest for the trees. Bringing Swift-native Foundation APIs into the standard library means they&#x27;re available on non-Mac platforms, which is huge. I&#x27;m also not sure what alternative would be preferable -- should it _not_ interop with Foundation&#x2F;Cocoa, and totally fragment the ecosystem? Or should _not_ reimplement them with native calls, so that it inherits the performance penalty of objc_msgSend?<p>&gt; It is functional, object-oriented and protocol oriented all at the same time.<p>Apple describes Swift as protocol-oriented. It&#x27;s flexible enough to support other paradigms, but I don&#x27;t see how that&#x27;s a liability, and I haven&#x27;t seen Apple claim &quot;Swift is an FP language&quot;.<p>&gt; It wants to be strongly typed, but at the same time so convenient in type inference, that it falls over its own feet while trying to grasp simple expressions, and they become too complex to manage. By design.<p>[citation needed]<p>This complaint is so vague as to be impossible to address, except to say that I haven&#x27;t managed to come across a case of it yet. An example would really help make the case.<p>&gt; It is compiled and static, but emphasized the REPL and playground face that makes it want to look like a great scripting solution. Which it isn&#x27;t.<p>Again, I haven&#x27;t heard any claim that &quot;Swift is a scripting language&quot;. Sure, it&#x27;s not, but neither is Objective-C, so... I&#x27;m not really sure what the complaint is here?<p>&gt; It seems to have been driven by the needs of the compiler and the gaps that needed to be filled for the static analyzer. Those seem to have been super-charged instead of catering to app developer&#x27;s actual needs: efficient, hassle free, productive (iOS) App development.<p>This sounds like a complaint about strong typing and static dispatch in general. Yes, you have to code more carefully, but the flipside is that a huge number of errors that crop up at runtime in Objective-C become compile-time errors in Swift. I&#x27;d much rather bang my head against the compiler for a while before I ship than have reams of undebuggable crash logs pour in.<p>&gt; It is meant offer progressive disclosure and be simple, to be used in playgrounds and learning. At the same time learning and reading through the Swift book and standard library is more akin to mastering C++. It is quite unforgiving, harsh, and complex.<p>That&#x27;s true, but that&#x27;s also kind of a big part of why playgrounds exist. So again, what&#x27;s the complaint? Is the fact that playgrounds make the language more accessible a problem somehow?<p>Also, the only way I can view Objective-C as &quot;simple&quot; is by ignoring the C underpinnings and looking only at the relatively thin layer of classes and message passing on top. For somebody coming to coding with fresh eyes, both Swift and Objective-C are going to have a learning curve; the difference is that with Swift you don&#x27;t have to pick up K&amp;R first.
mmjaaalmost 7 years ago
I agree with the author on all points, except one: there isn&#x27;t any reason not to just use Lua for everything.<p>Yes, thats right. Lua for everything. Lua on iOS, Lua on MacOS, Lua on Linux. Lua on Windows.<p>I absolutely love the freedom, flexibility and downright sexiness of using one language on all of the platforms. Its a beautiful, difficult, lonely place to be - but if you haven&#x27;t tried it, you can&#x27;t really knock it.
评论 #17280047 未加载
评论 #17280328 未加载
pjmlpalmost 7 years ago
&gt; However, the flip side is it inhibits your creativity while writing.<p>The old adage of C devs against us on the strong type side of the fence of Algol family.<p>We all know how the freedom for creativity end up.<p><a href="https:&#x2F;&#x2F;www.cvedetails.com&#x2F;vulnerability-list&#x2F;opmemc-1&#x2F;memory-corruption.html" rel="nofollow">https:&#x2F;&#x2F;www.cvedetails.com&#x2F;vulnerability-list&#x2F;opmemc-1&#x2F;memor...</a>
评论 #17280915 未加载
评论 #17280523 未加载
dwaitealmost 7 years ago
&gt; So now contrast that to Swift. First of all: Which question did it desire to answer?<p>From Swift.org: Swift makes it easy to write software that is incredibly fast and safe by design. Our goals for Swift are ambitious: we want to make programming simple things easy, and difficult things possible.<p>&gt; It should scale from App&#x2F;UI language down to system language.<p>I don&#x27;t see how say Go can be a system language and Swift can&#x27;t.<p>Much of Apple&#x27;s investment has been around making App and Framework development more productive on their platforms, but Swift is open and other companies like IBM have been focused on things like Web frameworks.<p>&gt;It should inter-op with existing Foundation and Cocoa, but still bring its own wide reaching standard library, adding a lot of duplication. I assume they mean the standard Swift package as the standard library, since they listed Foundation separate. Swift is <i>tiny</i>, basically holding core types like Int, String, Optional, and pointers, Collections (Dictionary, Set, and Array), ranges like 1..&lt;10, and essential common protocols like Equatable and Hashable.<p>It isn&#x27;t until you get to foundation that you get things like I&#x2F;O &#x2F; networking or binary data types.<p>&gt; It is functional, object-oriented and protocol oriented all at the same time.<p>Several of the languages listed in the article as being above as positive (like Ruby) are also multi-paradigm. Swift is hardly a functional language, it just has functional influences - like nearly <i>all</i> the languages listed.<p>&gt; It wants to be strongly typed, but at the same time so convenient in type inference, that it falls over its own feet while trying to grasp simple expressions, and they become too complex to manage. By design.<p>Since there wasn&#x27;t an example given, all I can really say is there&#x27;s nothing that <i>requires</i> you to use type inference. My experience from multiple languages is that usually such an expression is wrong, and the compiler cannot figure out any suggestions on how to fix it because a broken expression doesn&#x27;t give any type inference hints. A dynamic language would just let it crash and burn at runtime, which (if you have a test suite capturing the issue) is such a different process for debugging from fixing type inference at compile-time that they are hard to compare.<p>&gt; It is compiled and static, but emphasized the REPL and playground face that makes it want to look like a great scripting solution. Which it isn&#x27;t.<p>REPL and Playgrounds are both for experimentation, not necessarily for scripting. You can do command-line swift scripts, but generally the compiler makes them a bit heavyweight for many things.<p>&gt; It seems to have been driven by the needs of the compiler and the gaps that needed to be filled for the static analyzer. Those seem to have been super-charged instead of catering to app developer&#x27;s actual needs: efficient, hassle free, productive (iOS) App development.<p>Can&#x27;t say much here vs having a computer analyze your code is meant to be a boon, not a hinderance. My experience is that now when I write Java projects I wish I could get back the expressiveness, performance, and personal productivity I have writing Swift code.<p>&gt; It is meant offer progressive disclosure and be simple, to be used in playgrounds and learning. At the same time learning and reading through the Swift book and standard library is more akin to mastering C++. It is quite unforgiving, harsh, and complex.<p>If nothing else, someone is underestimating the effort of mastering C++.
评论 #17281068 未加载
评论 #17282166 未加载
khitchdeealmost 7 years ago
Call me a purist, but I find no reason to have gone beyond C Not C++, not ObjectiveC, nor anything else that followed I find C++ and ObjectiveC add a lot of complexity and the benefits of adding this complexity are very limited I think it would be better to stick with C and pursue other ways to improve developer tools
评论 #17280849 未加载