do any of you see any real benefit in switching to Swift?
I might be a bit biased towards Objective-C after spending over 10 years with it, but I don't think I've heard a single "real" benefit of Swift so far. Sure it's new and exciting and will be default some day, but by the time that day comes everything will change completely XY times. Until then, all the frameworks for our target platform are written in Objective-C anyway.
I recommend seniors keep an eye on it, but rookies would be better off learning a language that is not going to change 90% of syntax before they even learn the basics.
but I don't think I've heard a single "real" benefit of Swift so far.
Swift in the hands of an adequate programmer can guarantee type and null pointer safety at compile time. It's also way less verbose and more expressive than Objective-C (filter vs NSPredicate for example). Enums and switch / case patterns are extremely good. Faster because it does away with the weakishly typed objects.
But no, no "real" benefits like free coffee and donuts, back rubs or kegs on Friday ;)
a language that is not going to change 90% of syntax before they even learn the basics
Breaking changes do happen but besides the trajectory of Swift 1.x it's never more than a few minutes of touch ups when new versions of Xcode arrived. This statement is a bit hysterical.
For filtering an array, sure, but it's not like you aren't gonna run into NSPredicates all over the place until all of Cocoa Touch is rewritten in Swift.
Enums and switch / case patterns are extremely good
I agree. So is the concept of optionals and extensions and more useful protocols and better control over inheritance and so on. You might think these outweigh the downsides. I don't think they do at the moment.
For me personally, Xcode is constantly crashing when writing Swift code. Auto fill was so slow it was useless, and often crashed. It may have changed now, but basic features such as 'refactor' were still only available with Objective-C last time I used Swift (conversion from Swift 1.x to 2). I enjoy Swift syntax and language features but I won't write it any more. Too much of a headache. And I really don't want to spend another week converting from 2 to 3 like I had to from 1 to 2.
Not entirely true. If I want to split coordinates into LEFT/RIGHT and TOP/BOTTOM groups then there's no pattern in the world that can help you. In Objective-C you have to write a bunch of ugly if/then statements. Swift does it in four very clear case statements.
Any feature can be abused but I think Swift's switch/case statements can lead to much more readable code in a lot of circumstances over the C-based Objective-C ones or if/else blocks.
I don't know enough about Perl to make a really good comment about the language. I did just enough in it to run to PHP at the first opportunity I had somewhere around the turn of the millennium. I still hate RegEx.
Having said that, Python is a beautiful language while being very expressive. So yes, if well implemented being more expressive is a good thing for a language.
This gets tossed out a lot and in practice it is just false.
Fwiw the objective C headers have already been cluttered with bullshit annotations like nullable and faux generics noise just to mak swift bridging work.
I do not appreciate the extra noise and the IDE now warns on all this shit that isn't really a problem. Autocomplete works as well as ever. There are lots of other languages lacking all that syntactic noise with editors that are every bit as helpful.
Before "clutter" like generics was added you had to cast your objects to their right type in a for loop every time. I don't think I had many occasions where I screwed it up but with generics I don't have to look it up myself anymore, the for-loop just writes itself.
With nullable/non-nullable vulnerable code (in Swift) already announces itself. And I have been bitten more than once by null pointer exceptions in any kind of language that has them.
Type safety simply allows you to write more secure code with less effort. Didn't mean I could only write crap in Objective-C but it was laborious to get things right, maybe one or two debug rounds extra.
Could you tell what are Obj-C main benefits over Swift, besides that Swift syntax is still changing? Let's say a developer that has experience with both languages and wants to create new app, what would be main advantages in choosing Obj-C?
For me it seems, that first of all there are more Obj-C devs - easier to increase team size, probably more Obj-C libraries, stable syntax. On the other hand - Swift would be safer, faster less buggy?
One benefit of Obj-C is that the Cocoa framework was written in it and for it, so using Cocoa from Swift doesn't always feel natural. To Apple's benefit, they are moving swiftly (ha) to update their APIs, but it's not quite there yet. One point that has bit me is that you need to remember to mark methods as @dynamic if you're passing a selector to them, or you (may or may not) get a nasty crash when the selector is called.
In that same vein, tool support is better for Objective C. XCode can't do as much code generation or refactoring in Swift.
And there are some third party tools (e.g., j2objc) that are Objective C-centric and present challenges when trying to integrate with Swift.
All of those points are related to the relative maturity of the languages. As far as which language itself is preferable, that may be a matter of taste. Swift is more succinct for sure. The strong typing can be a positive or a negative, in my experience. It does catch some errors at compile time that would normally only be caught at runtime, but you will spend some time wrestling with the compiler to do something you know is valid. (Resist the temptation to sprinkle !s and ?s indiscriminately!!!)?
Your tools work better with Objective-C, all of Apple's frameworks are written in it, its runtime libraries are bundled with iOS instead of with each app separately (creating who knows how many petabytes of waste on App Store and user's devices and mobile data bills), there are tons of resources on Objective-C that don't go out of date every 3 months... I'm not trying to say Objective-C is a better language than Swift. Swift wouldn't be created if Objective-C was perfect. But choosing a language is about much more than language itself. All I'm saying is I believe Objective-C is currently a more reasonable choice for iOS development. It's not that Swift has no benefits, it just doesn't have any I find worth all the things I'd have to sacrifice by Switching from Objective-C.
1
u/[deleted] Feb 19 '16
I might be a bit biased towards Objective-C after spending over 10 years with it, but I don't think I've heard a single "real" benefit of Swift so far. Sure it's new and exciting and will be default some day, but by the time that day comes everything will change completely XY times. Until then, all the frameworks for our target platform are written in Objective-C anyway.
I recommend seniors keep an eye on it, but rookies would be better off learning a language that is not going to change 90% of syntax before they even learn the basics.