All the discussion of modulo arithmetic and the range operator syntax, it seems to me, is missing the boat. Surely these are minor features of the language.
Some things I've noticed that will matter a great deal include:
• Namespaces. No longer need every class be prefixed by an alphabet soup of initials. • Const correctness. • Chained initializers. • Hooks for willSet and didSet. • Null objects. The most sophisticated support I've seen for graceful response to failure.
Questions that I've not yet figured out in my first pass through the book -- and which I think will also matter a lot -- include:
• support for polymorphism. In C++, we dispatch on the type of the operand:
bool DoSomething(int); bool DoSomething(const string&); bool DoSomething(Widget*);
ObjC doesn't do this, which complicated writing Visitor patterns among other things. Where does Swift land?
• the beefy switch statement is interesting, but I think lots of sentiment views switch() as a code smell. What’s its motivation?
• the language is billed as offering better runtime performance, presumably because it's easier to optimize than ObjC. However, it does accept a number of performance hits, such as range-testing array references. I'm finding it a bit difficult to imagine that optimizations can make up for these; what am I overlooking?
• the language appears to encourage inner classes and inner functions. My sense of the community is that inner classes are now thought to be a code smell in C++ unless they're trivial functors or comparators. What am I overlooking?
• All top-level definitions are implicitly visible to clients -- private and protected members are coming in the future. No header files, no formal declaration of external interface. This strikes me as an odd choice for a language intended for moderately large and large systems. No doubt I'm simply missing a feature: what is it?
• The language has been touted for its performance, but it's not clear that it's been designed for runtime speed the way Go (say) was designed for compilation speed. The language has been touted for its accessibility to younger programmers, but the book is clearly pitched to pros, the frameworks are certainly pitched to pros, and a language that features generics, tuples, and functional programming so prominently is not going to be especially easy to teach. What am I missing?
I'd welcome answers to the above -- many will be low-hanging fruit and I'm not at WWDC -- and would be interested to know what questions occur to my colleagues.
Mark Bernstein bernstein@eastgate,com (617) 924-9044 134 Main St.
|