Live data from Hacker News

Ask HN: If learning to develop for iOS- start with Obj C or Swift?

news.ycombinator.com

41–50 of 53 posts

Re: Ask HN: If learning to develop for iOS- start with Obj C or Swift?

#41
post #7

Anecdotal evidence in favor of Objective-C (Swift wasn't around back then): at an early WWDC, a dev. who was completely unfamiliar with Objective-C finished his first Cocoa application during the "Intro to Cocoa" session, and spoke about his amazement during the feedback. Swift is way more complicated than Objective-C, even if the syntax may seem a lot more familiar if you're used to certain other languages. The reas…

> A small example are force-unwrapped optionals that you get out of a lot of the library calls (because nil ptrs. are OK in ObjC and Cocoa), which will blow up when you use them, without the compiler warning you! (So much for safety).

Care to elaborate? I get that an ObjC method potentionally returning nil would result in an optional on the swift side, but I don't really get how the compiler doesn't warn you the same way it would with anything else with Optional semantics. (ie. it's nullable.)

Re: Ask HN: If learning to develop for iOS- start with Obj C or Swift?

#42
post #7

Anecdotal evidence in favor of Objective-C (Swift wasn't around back then): at an early WWDC, a dev. who was completely unfamiliar with Objective-C finished his first Cocoa application during the "Intro to Cocoa" session, and spoke about his amazement during the feedback. Swift is way more complicated than Objective-C, even if the syntax may seem a lot more familiar if you're used to certain other languages. The reas…

Idk if I agree that objective-c is simpler to learn. I have been working as a full-time ios developer for almost 2 years now and I still have to consult fuckingblocksyntax.com on a weekly basis. And fully understanding objective-c's "message passing" idea is hard because it's so radically different from other languages. And sure you can whip together a simple app using all the documentation and tutorials out there fo…

Yeah, this is one of the reasons why Swift exists. The base Obj-C that we started with was pretty simple and reasonably elegant, but over the years we've been grafted pieces onto it in decidedly inelegant ways.

Block syntax, a ludicrous proliferation of __keywords and @keywords, the verbosity of GCD calls, all of it makes modern, complex Obj-C apps harder and harder to write.

In a lot of ways Swift is a reset. It offers a lot of the things we want from Obj-C/Cocoa (e.g., more block-based everything) in a clean syntax that was designed from the get-go to support it.

One of the complex bits of Swift right now is that the APIs haven't been ported. UIButton still expects targets and selectors (ugh), and an innumerable number of API calls still rely on the only C-style way of passing error pointers into calls to see if they get filled (and necessitating the idiotic NSErrorPointer class). A lot of the complexity of building in Swift right now is shoehorning Obj-C style APIs into Swift code.

Re: Ask HN: If learning to develop for iOS- start with Obj C or Swift?

#43
Learn C# instead:

0) easily very cross-platform (but you will have to pay), mainstream in mobile games via Unity3D;

1) not locked to one company: .NET by Microsoft, Mono by Xamarin;

2) open-source and welcoming feedback;

3) modern and innovative (not like Swift, but for real - introducing stuff like async/await, mixed dynamic/static typing etc.);

4) allows building mobile, web, desktop, butt software today;

5) first-class IDE, that will get an extensible compiler-as-a-service in 2015;

6) best in class automated refactoring via ReSharper.

Re: Ask HN: If learning to develop for iOS- start with Obj C or Swift?

#44
post #7

Anecdotal evidence in favor of Objective-C (Swift wasn't around back then): at an early WWDC, a dev. who was completely unfamiliar with Objective-C finished his first Cocoa application during the "Intro to Cocoa" session, and spoke about his amazement during the feedback. Swift is way more complicated than Objective-C, even if the syntax may seem a lot more familiar if you're used to certain other languages. The reas…

> A small example are force-unwrapped optionals that you get out of a lot of the library calls (because nil ptrs. are OK in ObjC and Cocoa), which will blow up when you use them, without the compiler warning you! (So much for safety). Care to elaborate? I get that an ObjC method potentionally returning nil would result in an optional on the swift side, but I don't really get how the compiler doesn't warn you the same…

Well, they're not mapping them to optionals, but to "forced unwrapped". This is how the superview property of NSView is declared:

    var superview: NSView! { get }

In a workspace:

   var view = NSView( frame: NSRect(x: 10, y: 10, width: 300, height: 100))   -> NSView 

   view.superview  -> nil
So now I have a nil in Swift that is not wrapped in an optional. No compiler warnings, boom! And of course, no way to catch exceptions, so BOOM!

Re: Ask HN: If learning to develop for iOS- start with Obj C or Swift?

#45

Earlier quoted context omitted.

Idk if I agree that objective-c is simpler to learn. I have been working as a full-time ios developer for almost 2 years now and I still have to consult fuckingblocksyntax.com on a weekly basis. And fully understanding objective-c's "message passing" idea is hard because it's so radically different from other languages. And sure you can whip together a simple app using all the documentation and tutorials out there fo…

Yeah, this is one of the reasons why Swift exists. The base Obj-C that we started with was pretty simple and reasonably elegant, but over the years we've been grafted pieces onto it in decidedly inelegant ways. Block syntax, a ludicrous proliferation of __keywords and @keywords, the verbosity of GCD calls, all of it makes modern, complex Obj-C apps harder and harder to write. In a lot of ways Swift is a reset. It off…

Yes, definitely. Objective-C was a lot more elegant before the odd grafting started, with everything hard-baked into the compiler and special cases added on top of special cases after the first special cases were found to be too special.

So I'd agree that a reset is a good idea. However, Swift pretty much represents the grafting-on approach. Even now, at the start, Swift is already more complex, with more special cases, than even grafted-upon-grafted Objective-C, let alone Objective-C as it started out.

That doesn't mean that there aren't a few things that are handled nicely, but overall it's a bit of a mess already, because of the insistence of stuffing everything into the language and compiler and having everything checked statically (except that it only pretends...).

"If you focus on just messaging - and realize that a good metasystem can late bind the various 2nd level architectures used in objects - then much of the language-, UI-, and OS based discussions on this thread are really quite moot."

-- Alan Kay (http://lists.squeakfoundation.org/pipermail/squeak-dev/1998-...)

This is not to say that it's correct because "Alan Kay", but to show a very different approach to language design that is, IMHO, much more powerful and durable than special-casing all the language-fads-du-jour into the compiler.

If you go back a bit and see where Objective-C came from, it was the desire to have Smalltalk, but with better performance and better C interoperability. So an obvious reboot of Objective-C would have been Smalltalk based, with C interop moved out of the base and better support for architectural interconnect. A real "Objective-C without the C", unlike Swift, which is more "Objective-C without the Objective-".

This is such an obvious thing to do that there have been several community projects, including, but not limited to StepTalk, FScript, Pragmatic Smalltalk and my own Objective-Smalltalk (http://objective.st).

In fact, Objective-Smalltalk was in part inspired by Alan Kay's work as expressed in that message: focus on the big things, get the right meta-system in-place, the rest will take care of itself. (here's my response: http://lists.squeakfoundation.org/pipermail/squeak-dev/1998-... ) As such, it Objective-Smalltalk isn't trying to be yet another Smalltalk implementation, but rather a new approach in the spirit of Smalltalk: identify the next bigger thing to handle (we now have the Web, for example) and then scale that down so it can handle everything else as well. I think I'm on a good road of achieving this, Higher Order Messaging and Polymorphic Identifiers in combination already handle a lot of what you need, in a user-extensible, late-bound fashion, governed by a very simple and powerful metasystem.

Starting with any of these Smalltalks (or a separate development along similar lines) would have been an easy road towards the goals that Swift aspires to, even considered by itself. When you add interop with the current class libraries, which are simply at odds with the Swift approach, it becomes a no-brainer.

Re: Ask HN: If learning to develop for iOS- start with Obj C or Swift?

#46
Most of what you need to learn is Cocoa Touch and whatever other frameworks you want to use. If you need to start today, use the production Xcode and Objective-C -- it will be far less frustrating.

Give the Swift book a quick read in a month or so, so you are familiar with the differences. Perhaps start thinking of Swift in August.

Re: Ask HN: If learning to develop for iOS- start with Obj C or Swift?

#47

This is a tough one. Swift is going to be the future of iOS development and very important. But at the same time I think Obj-C will allow you to explore all the existing source code that is out there without any problems. I'd say go with Obj-C and learn Swift in the future.

I see the dick riding down voter is here again. Ah go fuck yourself.

Re: Ask HN: If learning to develop for iOS- start with Obj C or Swift?

#48
It doesn't really matter, in my opinion, because the major learning hurdle generally isn't the languages, it's the Cocoa frameworks. Experienced programmers can pick up Swift or Obj-C in 2-3 days. The frameworks will take you considerably longer to feel comfortable with.

That said, Swift isn't production-ready yet, and there's not a wealth of books and documentation, but it's very, very likely the future of iOS and OS X application development.

Re: Ask HN: If learning to develop for iOS- start with Obj C or Swift?

#49
I've just started looking at swift since it was launched, and making really good progress so far. Having coded in Ruby, C#, C++, and C, I really enjoy and "get" swift as it's leveraging the strength from all these languages.

I also find it pretty easy to convert Objective C code (from tutorials/StackOverflow) to swift, in particular with the help of auto-completion. So in my opinion (from someone who just started, so take with a grain of salt), I would definitely suggest Swift

Re: Ask HN: If learning to develop for iOS- start with Obj C or Swift?

#50

This is a tough one. Swift is going to be the future of iOS development and very important. But at the same time I think Obj-C will allow you to explore all the existing source code that is out there without any problems. I'd say go with Obj-C and learn Swift in the future.

I see the dick riding down voter is here again. Ah go fuck yourself.

So the story is buried and I still get a downvote. Dick rider confirmed.
Post reply on HN