Best practices differences between Swift and ActionScript3

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.

Constant naming
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)

Type definitions
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)

Semi colons
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?

iOS development with Swift - book: video course:

Tagged with:
Posted in Flash, Swift
One comment on “Best practices differences between Swift and ActionScript3
  1. […] Best practices differences between Swift and ActionScript3 […]

Leave a Reply to Swift resources for Flash and ActionScript developers - Easy Native Extensions Cancel reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: