Better Software Development with Swift

Swift is the new programming language for Apple development, and possibly for non-Apple environments in the future. It follows and expands on recent trends in languages. Older languages have problems keeping up with modern development methods, and Swift addresses these issues.

A huge problem with C and similar languages is that they encourage using raw pointers into memory. Objective-C, Apple's previous development language, shares this weakness. Coding errors can let software overwrite arbitrary memory locations. Malware takes advantage of this to make buggy code alter itself, so it will do damage or communicate sensitive information back. Swift makes pointers available where they're really needed, but provides safe alternatives for any case that doesn't require direct address manipulation.

Null values are a related problem. The absence of a value is some flavor of "null" in most languages, but accidentally using it causes problems. In C, a null is a pointer to location 0 in memory. Trying to read or write it will cause a memory access violation, bringing the program to a bumpy stop. Other languages will throw exceptions; that's a better solution but still likely to stop any further progress.

Swift solves the problem with optionals. Normally a variable can't have a nil (that's Swift's term) value, but the programmer can declare a variable optional by putting a question mark after the type (e.g., "String?"). That's a reminder to check if a value is nil and handle that case; after checking, it can be assigned to a normal variable.

Long lists of arguments can confuse programmers. If they call a function with arguments in the wrong order, the compiler may not be able to tell. Swift encourages assigning arguments by name, making mistakes less likely.

Fewer chances to make careless programming errors means code with fewer bugs and fewer security holes. Languages like Swift will result in better and safer software.

Folio1 provides custom software solutions to help your business work better. Please contact us to learn what we can do for you.