3 ms·
Why Swift Sucks
- hot_gril 4y agohttps://stackoverflow.com/questions/39677330/how-does-string-substring-work-in-swift https://stackoverflow.com/questions/39677330/how-does-string... https://stackoverflow.com/questions/32305891/index-of-a-substring-in-a-string-with-swift https://stackoverflow.com/questions/32305891/index-of-a-subs... https://stackoverflow.com/questions/24037711/get-the-length-of-a-string https://stackoverflow.com/questions/24037711/get-the-length-... https://stackoverflow.com/questions/38454952/map-array-of-objects-to-dictionary-in-swift https://stackoverflow.com/questions/38454952/map-array-of-ob... https://stackoverflow.com/questions/24250938/swift-pass-array-by-reference https://stackoverflow.com/questions/24250938/swift-pass-arra... https://stackoverflow.com/questions/34540185/how-to-convert-index-to-type-int-in-swift https://stackoverflow.com/questions/34540185/how-to-convert-... The language is irredeemable if the simplest tasks are that complicated.
- billconan 4y agoto add to that list https://stackoverflow.com/questions/24508592/how-to-iterate-for-loop-in-reverse-order-in-swift https://stackoverflow.com/questions/24508592/how-to-iterate-... https://stackoverflow.com/questions/33463511/how-to-reverse-array-in-swift-without-using-reverse https://stackoverflow.com/questions/33463511/how-to-reverse-... they removed the c-like for-loop in swift, which IMO is a wrong decision. c for-loop is an example of "less is more", a single syntax to cover all cases. their argument is that c for-loop is not "swifty" and not beginner friendly (I don't understand why the above is). But if one can't learn c for-loop within 5 minutes, perhaps the person is unsuitable for any programming activities.
- hot_gril 4y agoI've used Swift since version 1 and stopped using it at 4-ish. Not surprised to see they're still finding ways to mess with people, and glad you could add to the list. For the project I used to work on, we were dealing with strings a lot and decided one day to make our own strings (implemented basically as arrays of characters*) because even the patient guy on our team had lost patience with Apple's strings. Apple changed how strings work several times after that, and we were unaffected. I guess if the project were still around, the loops would've gotten it one day. * 1 character to us = 1 extended grapheme cluster aka what a human would see as one character
- bobbylarrybobby 4y agoHow did you handle characters of different lengths? Was each extended grapheme cluster its own array?
- chmaynard 4y agoChris Lattner must be rolling over in his grave. Oh wait, he's alive. https://devclass.com/2022/02/22/chris-lattner-leaves-swift/ https://devclass.com/2022/02/22/chris-lattner-leaves-swift/
- hot_gril 4y agoThose are interesting internal details, thanks for sharing.
- mark_l_watson 4y agoI don’t use Swift very often, one App Store product and many evenings of hacking. I find the language to be really nice in general. Swift 5 and SwiftUI all seem well engineered and documented.
- adamnemecek 4y agoYou understand why it’s like that right?
- hot_gril 4y agoIf you're referring to the link in the title about substrings, I understand the reasoning behind the current version, but it's still bad. It's even worse that it's changed at least 5 times.
- tpmoney 4y agoIs String and Substring in swift all that different from String and &str in rust? It's definitely an odd thing to have such an explicit memory management construct in a language that largely tries to make you not have to think about memory management (unlike rust) but it's not like it's unprecedented in a modern language either.
- hot_gril 4y agoNot conceptually very different, but Swift's syntax for that is just overly complex, and yeah there's the mismatch as you've pointed out. &str in Rust never confused me.
- kristianp 4y ago(2016), actual title: "How does String substring work in Swift"