Comparing Swift and C#

Lately I've been reading through the Swift book released by Apple to introduce their new programming language. Overall, Swift is a big change from the verbose syntax of Objective-C. It's also exciting to have the opportunity to learn a new language while it's still in beta. Swift borrows elements from several existing languages, including C#, and I thought it would be interesting to compare the two.

Perhaps the most drastic change is the absence of semi-colons. There are an average of 45 characters in a line of code (my sample size was one line of C# that looked to be of about medium-ish width, so my calculations may be a little off, but bear with me). Not having to type a semi-colon at the end of a line means that a line of code will now be about 2% shorter (compared to C#). Think of the time savings. After a year of programming in Swift you will have an additional 7 or 8 minutes left over to do whatever you want! Are you ready to really have your mind blown? They also removed parenthesis from for and if statements.

Take note managers, switching to Swift may very well be the productivity boost you've been needing for your team.

Seriously though, the syntax does look pretty.

Check out the samples below:

At the risk of beating a dead horse, the C# example above took 1m 47s to write and the Swift example only took 1m 31s.

comments powered by Disqus