There are the obvious technical differences in Swift compared to other languages such as ActionScript – optionals, strict data typing, namespacing, syntax, etc. What I find interesting though is where there aren’t technical differences, but there are differences in approach, philosophy and best practices. It’s interesting to watch these best practices philosophies in different programming communities evolve. Here are a few I’ve noticed:
this – self
Despite both languages having a keyword for classes to reference themselves explicitly(avoiding conflict with local variables), when to use them has shifted. In ActionScript most folks recommended always using `this` if possible(link). In Swift, the consensus is generally to avoid using `self` where possible(link) Explicitly naming `this` in Flash was partially required for code hinting.
In ActionScript, the consensus was to name constants all capitals with underscores to mark spaces(link). In Swift, constants are more ubiquitous so share camel case convention with variables. (link)
In Swift, as it is a type-safe language, the preference is to infer type from its contents rather than specify it, if possible. (link) In ActionScript, it’s possible to set a variable without explicitly specifying the datatype, however this variable would not be strongly typed, which is probably why in ActionScript the recommendation is generally to always specify your variables’ data types. (link)
Both languages actually are agnostic about whether lines of code are terminated by a semi-colon. While the recommendation in ActionScript is to use semi-colons, recommendations in Swift is to avoid semi-colons.
Have I missed any? Are they other interesting differences in best practices with other languages?