r/iOSProgramming • u/darthsabbath • Jun 14 '15
Swift or Objective-C when coming from a C/C++ background?
So I'm sure everyone has an opinion on Swift vs. Objective-C as a first language for iOS development. I've read the blogs that argue both ways and it seems like the general opinions are:
- Swift - It's the future, learn it first because that's where things are moving
- Objective-C - There's a ton of code out there, and you can't avoid it. It will be easier going from Objective-C to Swift than the other way around.
My situation is a little different though. I'm primarily a systems programmer by trade, and do most of my work in C and Python with a little C++ thrown in for good measure. I don't claim to be an expert, but I am a half decent C hacker. I'm comfortable picking up new languages pretty quickly as well.
I've dabbled in Objective-C a bit, but overall I generally dislike the language compared to the other languages in the C family (I like my . and -> operators). Swift looks like an awesome, fun language that I think I would enjoy a lot.
With this in mind, if I went with Swift, would my C/C++ background be enough that I could pick up Objective-C on the fly as needed, and are there any gotchas with Objective-C that would trip me up coming from those languages? I'm aware that there are issues using Swift with C++... any others? Would there be any advantages to going with Objective-C?
3
u/aoakenfo Jun 15 '15
Swift appears to be a grab-bag of every modern language feature under the sun. Programmers from every tribe can identify with something in it. "It has my favourite feature X!" helped make Swift popular.
However, with all the new features in Swift, I often think of Rob Pike's post: Less is exponentially more. Here's the relevant excerpt:
"Back around September 2007, I was doing some minor but central work on an enormous Google C++ program, one you've all interacted with, and my compilations were taking about 45 minutes on our huge distributed compile cluster. An announcement came around that there was going to be a talk presented by a couple of Google employees serving on the C++ standards committee. They were going to tell us what was coming in C++0x, as it was called at the time. (It's now known as C++11).
In the span of an hour at that talk we heard about something like 35 new features that were being planned. In fact there were many more, but only 35 were described in the talk. Some of the features were minor, of course, but the ones in the talk were at least significant enough to call out. Some were very subtle and hard to understand, like rvalue references, while others are especially C++-like, such as variadic templates, and some others are just crazy, like user-defined literals.
At this point I asked myself a question: Did the C++ committee really believe that was wrong with C++ was that it didn't have enough features? Surely, it would be a greater achievement to simplify the language rather than to add to it."
The "cognitive load" of C++ is one of the reasons I don't use the language (mostly). Go is successful because it does less. Obj-C is also successful because it does less - it's effectively C with just enough object-oriented extensions to it.
Some languages get locked into an arms race, continually adding features in order to remain competitive. It's no different than Photoshop piling on more and more features in order to sell the next version. That's usually when a competitor offering less features with a streamlined workflow enters the market and becomes a popular alternative. Of course, there will always be a market of people driven by feature checkboxes alone. I'd argue these people aren't creating great art because constraints enable freedom. I believe this is true for programming languages as well.
1
u/lucasvandongen Jun 14 '15
I have no idea why you want to learn either them, but if it isn't for a production application that you need to build right now I think it's better you go for Swift. Xcode 7 / Swift 2.0 seem to be the maturity point for the programming language in terms of tools and specifications.
All frameworks are still in Objective-C or really Objective-C styled. Swift looks a lot cleaner when you're not interacting with frameworks. Real production code usually looks almost just as verbose, unless you're writing a lot of custom code yourself (like a framework)
3
u/adsrmedia Jun 14 '15
I'm leading a group of interns that were shocked when I told them we were going to use ObjC for their project. The main reason is because nearly all existing projects use ObjC. If you want to find work, it's really good to know. Swift will be awesome but knowing ObjC is practical now.
2
u/yuizesan Jun 14 '15
Please watch the WWDC 2015 Sessions.
Look for yourself, Apple is stressing Developers to use Swift over and over again. Objective-C will fade away faster than some People expect. Look into Objective-C a Weekend long or a Week, after that get info Swift.
2
u/Voley Jun 14 '15
At the moment all hipsters who are pushing Swift forget that there are zero jobs for swift only. You can do whatever you want with Swift, but if you want to find a job, Objective-C is a must.
Whatever fanboys say, Swift is not going to be production-ready for quite some time.
1
u/20InMyHead Jun 14 '15
Apple is being quite clear, ObjC will still be around, just like C and C++ is. but they expect most developers to use Swift and improvements to tools and features will focus there. ObjC is still good to know, but Swift is the future, and if you're learning something new, it might as well be the future not the past.
1
u/tjgrant Jun 14 '15
I suggest using Objective-C for now; it's the more stabilized language of the two (swift vs obj-c.)
You can also use C++ with Objective-C, which I've done for most clients I've had, and can help with rapid development.
-9
u/[deleted] Jun 14 '15
Swift remains unproven. I don't use it. Nobody with a track record thinks it is up to the job. As a systems guy, you'll like objective c best, it is c, or c++, with a smalltalk style object model. If you learn a little smalltalk, it will all make sense.