How do you feel about type safety and encapsulation with Swift?
I'm having some concerns about a few things in the language. So far it looks like almost everything is global. This can be solved by moving encapsulated objects in to functions, but it changes the thinking with developing iOS apps a bit. What are your thoughts?
Additionally, it seems like there's a lot of inferred types, using the var keyword. You can explicitly set a type but from interfacing with the Cocoa API I'm seeing a lot of 'AnyObject' objects, which I guess are something like ids.
Posted Jun 3, 2014, 4:13 AM UTC
32
With my primary language being JavaScript and just finishing a semester building a compiler, I don't find this to be a problem.
Granted, to someone who is used to a statically typed language without the more modern conventions found in scripting languages, I can see the concern. It seems that Apple has been working on Swift for the past few years to meet your concerns while still providing scripting functionality.
Apple's priority has always been safety first with code. They would not just supplement a language with 20+ years of use without a solid reason. That reason is the baggage of C and a need for modern programming in the mobile development landscape.