Ask Slashdot: Objective C Vs. Swift For a New iOS Developer?
RegularDave writes: I'm a recent grad from a master's program in a potentially worthless social science field, and I've considered getting into iOS development. Several of my friends who were in similar situations after grad school have done so and are making a healthy living getting contract work. Although they had CS and Physics degrees going into iOS, neither had worked in objective C and both essentially went through a crash courses (either self-taught or through intensive classes) in order to get their first gigs. I have two questions. First, am I an idiot for thinking I can teach myself either objective C or Swift on my own without any academic CS background (I've tinkered in HTML, CSS, and C classes online with some success)? Second, if I'm not an idiot for attempting to learn either language, which should I concentrate on?
For wanting to learn something.
Helping with organizational effectiveness is our job.
I agree, as long as you pick up some guides or literature focusing on best practices, rather than just the semantics of the code. There are just toooo many "self-taught" programmers who cannot write professional quality code in a team environment because they were never really exposed to doing it properly. It's perfectly fine to teach yourself - just try to be flexible and adaptable and not get stuck in horrible bad habits - and for god sakes, if someone says you're doing it wrong, at least consider what they have to say.
I've been doing Obj-C for a few years now and I'm using Swift in a new project.
Swift all the way, mainly because Swift is just a much nicer language. Obj-C has a bizarre late 80's syntax which is not found anywhere else so it's very strange. Except for random places where it's not. There was a half-assed "Objective-C 2.0" which introduced dot notation but not everywhere or consistently. There's tons of things you can do with it that are unsafe and shouldn't work (found out a lot in translating some Obj-C code to Swift)
There's still going to be a bunch of Cocoa stuff to mess with (i.e., there's no intrinsic date concept so you have to mess with NSDate) but at this point learning Objective-C is a waste of time. At best you will have a few more online resources to consult with versus Swift but Swift is the biggest new language in a long time - a language designed by the biggest company on earth for one of the most popular platforms on the planet. The uptake is more or less unprecedented.
Anyone who prefers Obj-C just doesn't want to learn something new. Apple didn't invent a new language because of hipness reasons, they did it because their platforms are saddled with this shitty language which is missing modern conventions and is difficult to learn and use.
Just use Swift.
Schnapple
The noob has a problem with obj c: everybody in the world is already good at it. At least with swift, everybody is a noob and w six months of work you already know more that most. Also I highly recommend classes as a supplement to independent learning.
HR will still demand five years of experience in Swift.
No header files confuscate passed-on intended usage by exposing ALL class details rather than the intended consumable APIs.
Which is OK within the same app, especially since you can mark methods as private now.
Visibility is limited to what you can use when using a framework written in swift, you get what is essentially an automatic header view.
The idea is to write more small frameworks for more modularity.
Real-world test code being written showed you end up peppering your code with ? and ! symbols.
Not as true since the iOS frameworks were re-worked to indicate properly to Swift when something is an optional or not. The choice to use an optional should be a thoughtful one in your own code.
var view: NSView = anyObject as NSView
What's wrong with being explicit in casting? You had to do that a lot in ObjC also ( NSView view = (NSView *)myObject ) only now without the pointer syntax... as the tested casting is a much nicer concept since it fails gracefully if wrong, instead of just proceeding and crashing.
Your code end up having full of "as othertype" in it.
No, it really hasn't, not in real use.
Integration with existing code: Obj-C require Swift mangled name
Don't know where you got that, but just no. I've worked with mixed Swift/ObjC code, there is no need to use the mangled name - that has not come up in any way for real use.
String-types enums are a major fubar
Oh no, you have to call toRaw()? Never mind that in ObjC enums can ONLY be integers, not strings at all, which means you have to write a whole method somewhere to translate those ints into strings if you want an enum of strings, and also figure out where that method belongs... enums in Swift are a HUGE advancement.
The localized strings would thus expose the structure layout
Now that's just plain silly given that format strings in ObjC are simply passed the various objects in the call to format, and structure discerned from those pass parameters every bit as easily.
In fact what is REALLY silly is that ObjC is way more hackable, since it's all message passing... Swift takes that aspect away unless you re-enable it with things you mentioned like explicitly enabling KVC for methods.
I created a REST/JSON multi-threaded transaction framework with full JSON object parsing through an object factory that returned fully instantiated objects
That's interesting but sounds dubious since all of the JSON parsing Swift code I've seen is really compact, and I've been dealign with a lot of REST/JSON code in a production app myself, using swift. It's smaller. I've not measured speed but it's not much slower, if any.
Of course is real life you are just using NSJSONSerializer, right? Right?
That test framework was built with a multi-programmer, globally-spread coding team such as what I have to deal with at the office
I have to deal with the same stuff all the time, I'm a full time iOS consultant who has worked with a number of very large teams. I like the idea of a more modular app with more internal frameworks myself, it will REALLY help in a case like that.
I really think you are greatly mistaken about swift, you should use it in real development and not just a test case. Swift has already seen a lot of advancement and uptake...
"There is more worth loving than we have strength to love." - Brian Jay Stanley
No one's going to run a high availability web server, database or number-cruncher on a mobile.
Yes in fact they do. In fact if you stopped to think about it, all aspects of mobile computing correlate strongly to "high availability" concepts because the user wants an application that works fluidly, with as little delay or error as possible, and because it's a small portable device always with them, is less tolerant of said delay/error than with a desktop where we are all used to applications being slow at times.
Also of course, many mobile apps are simply arms of a larger system that is considered a high availability system, so the applications by default fall under that umbrella.
I've worked on mobile applications that have very large datasets, or a tremendous amount of processing of data from a server... it's not that uncommon.
Lag due to an algorithmic choice would be an even more unlikely occurrence
You are SO naive. That is in fact a HUGE problem for new developers on mobile platforms, something I have helped correct for many times, making a HUGE difference in how an application responds to the user. Any number of times it has been the difference between a feature even being possible on a mobile device.
A programmer will always be better with a solid grounding in CS, obviously; but your argument is misdirected.
Sorry if I only speak with several years of real world mobile development behind me, including some J2ME work in the past...
"There is more worth loving than we have strength to love." - Brian Jay Stanley