Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I like Swift and my overall answer is still yes that it is easier to learn than Objective C and that having to deal with types is worthwhile for the safety it brings and increased chance that it will do the right thing when it does run but it is still a barrier to a limited degree.

I remember initially struggling with the stuff in ML in the first year at university, I got it but I and many others had an initial struggle. I think that at least for beginners and maybe those coming from runtime duck typed languages Python, PHP, Ruby etc. it will be more of a barrier than you think.

For #1 in Objective C you inherit from NSObject (or a subclass thereof) for every class anyway so it is in all the examples and it isn't something that you need to do especially for a protocol.

For #2 yes of course you can have an array of a generic type but firstly you need to understand enough about the type system to create your array in that form and secondly what you get out will <AnyType> objects rather than <id>'s which get automatically cast to whatever you assign them to. But I do like the idiom for downcasting using as?:

  if let movie = item as? Movie {
      println("Movie: '\(movie.name)', dir. \(movie.director)")
  } else if let song = item as? Song {
      println("Song: '\(song.name)', by \(song.artist)")
  }
[0] Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/gb/jEUH0.l


Yeah - the central point is that there aren't really caveats about Swift being simpler than objective-c. It's not perfect, but Objective-C has a much greater number of rough edges so is strictly harder for new users.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: