4 ms·
As someone who started learning Objective-C only after Swift become firmly established, I have to say I strangely like the language. I picked it up fast and hav
by lenkite 5y ago
As someone who started learning Objective-C only after Swift become firmly established, I have to say I strangely like the language. I picked it up fast and have had no issues with adding features to a legacy codebase.
When I started, I thought it would be some complicated beast, but no - its a reasonably simple and elegant C superset with the only disadvantage of some extra verbosity. (but Apple API's suffer from verbosity as a principle)
I have to wonder: why did Apple create Swift ? Objective-C is quite nice, especially for C/C++ programmers. With Objective-C++, interop with C++ libraries is also terrific. Swift offers nothing like this yet.
- pjmlp 5y agoChris Lattner has mentioned that in a couple of interviews, there is a limit how much they could improve Objective-C towards being a safe systems programming language, exactly due to its C heritage.
- Someone 5y ago> I have to wonder: why did Apple create Swift? They wanted a safe, performant language that interoperates with Objective-C. Safety gets them fewer vulnerabilities, interoperability means they can gradually decrease (Objective-)C usage. Also: - opinions on the nicety of Objective-C differ (but the only arguments I’ve heard why it would be bad more or less are “I don’t like the syntax” and “it’s verbose”, both of which, IMO, are weak. Both, IMO, are acquired tastes. I don’t think anybody is born preferring terse K&R C, for example. - as you probably know, work is being done on C++ interop (https://github.com/apple/swift/blob/main/docs/CppInteroperabilityManifesto.md https://github.com/apple/swift/blob/main/docs/CppInteroperab...), so that may improve.
- ksec 5y ago>I have to wonder: why did Apple create Swift ? I asked this many times over the years, even in this thread [1]. Still no concrete answer. I still think overall it is a distraction. [1] https://news.ycombinator.com/item?id=30418197 https://news.ycombinator.com/item?id=30418197
- pjmlp 5y agoPlenty of Chris Lattner interviews answer that question. https://atp.fm/205-chris-lattner-interview-transcript https://atp.fm/205-chris-lattner-interview-transcript
- ksec 5y agoI know Chris lather's intention. And I have read and listen to all the interview he did. I think the question should be, Why was it necessary for Apple to bet on Swift. Something I dont think Bertrand Serlet or Avie Tevanian would have done.
- skohan 5y agoI thought it should be obvious. Apple was competing with Google/Android for mobile developers. For Android, you programmed in Java, which everyone learned in school. For iOS, this funny language with smalltalk syntax was a barrier to entry. So Apple needed a nice language with C-like syntax to woo developers.
- Grustaf 5y agoBecause they wanted a modern language to power their platforms. Objective C is ancient, and showing it.
- mekster 5y agoIt seems you like some ancient language which can't even concatenate a string without writing this dull statement with bunch of symbols. NSString *string1 = @"Some"; NSString *string2 = @" string"; NSString \*string3 = [string1 stringByAppendingString:string2]; Not to mention it didn't have ARC back in the days. For sake it was built nearly 40 years ago. Not sure if there's any room to question why Apple and devs wanted a new language. I was amazed why anyone would want to use this language before Swift but people didn't have a choice. There were efforts like MacRuby.
- lenkite 5y agoARC has been there for almost a decade now. Also if you wish to do heavy string concatenation, please use a NSMutableString and you can simply do: [string1 appendString:string2]; It is amazing that people forget to simply use the right tool for the right job and blame the PL instead.
- Apocryphon 5y agoTo be fair, while Swift includes nice convenience methods for strings, the new API comes with a considerable cost: https://www.mikeash.com/pyblog/friday-qa-2015-11-06-why-is-swifts-string-api-so-hard.html https://www.mikeash.com/pyblog/friday-qa-2015-11-06-why-is-s...
- Grustaf 5y agoThat article is from 2015. A lot has changed, though some people still complain.
- Apocryphon 5y agoDoubtful that the technical underpinnings of the API have changed all that much since 2015.
- saagarjha 5y agoThey very much have.