The language is called Swift, and on June 2, Apple released a test version to coders outside the company, billing it as a faster and more effective means of building software apps for iPhones, iPads, and Macs. Even then, four years after Lattner first envisioned the language, it came as a shock to all but a limited number of Apple insiders. Vikram Adve was Lattner’s graduate adviser at the University of Illinois, Urbana-Champaign, helping him fashion the software that would serve as the foundation for Swift, but Adve was just as surprised as anyone that his former student had spent so many years building a new programming language. “Apple is so tightlipped, and Chris has drunk the Apple Kool-Aid,” Adve says, laughing. “I knew he was working on a project that dominated his time, but that’s all I knew.”
‘Apple is so tightlipped, and Chris has drunk the Apple Kool-Aid. I knew he was working on a project that dominated his time, but that’s all I knew.’
Typically, when a new language appears like this—out of nowhere—it needs years to reach a mass audience. This is true even if it’s backed by a tech giant the size of Apple. Google unveiled a language called Go in 2009, and though it was designed by some of the biggest names in the history of software design--Ken Thompson and Rob Pike—it’s still struggling to gain a major following among the world’s coders. But Swift is a different animal. When it’s officially released this fall, it could achieve mass adoption with unprecedented speed, surpassing even the uptake of Sun Microsystems’ Java programming language and Microsoft’s C# in the late 1990s and early 2000s.
Part of Swift’s edge is that it’s built for the average programmer. It’s designed for coding even the simplest of mobile apps, and with a rather clever tool Apple calls “Playgrounds,” it offers an unusually effective way of teaching yourself to code. But the larger point here is that such an enormous number of programmers have an immediate reason to use Swift. Today, hundreds of thousands of developers build apps for iPhones and iPads using a language called Objective-C, and due to the immense popularity of Apple’s consumer gadgets, these coders will keep building such apps. But Swift is a significant improvement over Objective-C—in many respects—and this means the already enormous community of iPhone and iPad developers are sure to embrace the new language in the months to come.
“With Google Go, there was no real incentive to use it,” says Paul Jansen, who has tracked the progress of the world’s programming languages for nearly fifteen years with the Tiobe Index, an independent, if rather controversial, measure of coder mindshare. “The difference with Swift is that there is incentive.”
‘People will jump to this new language because it’s so much easier to code in. They have to use either Objective-C or Swift, and most people will go for Swift.’
Even now, with the new language available to only a limited number of coders, over 2,400 projects on GitHub—the popular repository for open source software—are already using Swift, and this month, it debuted at number 16 on Tiobe’s list of the world’s most-discussed languages. Yes, something similar happened when Go debuted in 2009, and the Google language has since fallen much lower on the list. But that automatic incentive that Jensen describes will only push Swift higher up the ladder.
Because of Swift’s unique position at the heart of the Apple universe, says Facebook programming language guru Andrei Alexandrescu, all it has to do is “not suck.” There’s a certain truth to his quip, and at the same time, the language very much exceeds this low barrier to entry. “People will jump to this new language because it’s so much easier to code in,” Jensen says. “They have to use either Objective-C or Swift, and most people will go for Swift.”
More Than a Language Chris Lattner oversees all of Apple’s developer tools—all the tools that let both Apple engineers and outside coders build software for the company’s PCs, laptops, phones, and tablets. As a graduate student at the University of Illinois, Urbana-Champaign, working under Vikram Adve, he created a kind of meta developer tool called LLVM, and this creation now underpins Xcode, Apple’s primary tool for building software, a tool who’s latest incarnation has been downloaded over 14 million times. Basically, LLVM is a way of generating and running new applications, and it can be molded for use with any programming language.
In other words, Swift isn’t just a language. It’s a language that’s tightly woven with everything developers need to build their software. This includes not only an integrated development environment, or IDE—an interface where coders can actually write their software—but also various other tools, such as a debugger that can help weed errors from their code. And most of these tools are familiar to every Apple developer. In short, there’s a clear on-ramp to Swift for the tens of thousands of coders already building apps for iPhones, iPads, and Macs.
‘A lot of people were really put off by Objective-C and its unusual syntax. Swift, with its more regular syntax, standard syntax, can really help with getting those people interested.’
Coders still need good reasons to make the switch from Objective-C to Swift. After all, they’ve never worked with Swift—”I’ll be the first and only guy with four years of Swift programming experience,” Lattner wrote on Twitter—and learning something like this requires some time and dedication. Typically, that’s a big hurdle to overcome. “Most new languages just don’t go anywhere and the few that do, it takes a long, long time for them to get any traction,” says Mike Ash, a developer who has spent the last fifteen years building software for Apple hardware and is now delving deeply into the company’s new language.
But for Ash and others, Lattner and Apple have already provided those good reasons. In and of itself, Swift isn’t that much more attractive than many other languages available to the world of software coders, including C#, Ruby, Python, and others. But it’s a big advance over Objective-C, a language that dates back to the mid-80s and, frankly, isn’t as easy to use as more modern languages. “A lot of people were really put off by Objective-C and its unusual syntax,” Ash says. “Swift, with its more regular syntax, standard syntax, can really help with getting those people interested.”
Swift is not only more familiar to contemporary coders—offering things like “generics,” basic building blocks you can use over and over again—it includes several tools designed to better protect programmers from mistakes and bugs. Among other things, it provides what’s called “inferred typing,” which basically means that coders don’t have to spend so much time defining what types of variables they’re using. “It’s more of a helpful language. It understands what you’re doing a little bit better and allows the computer to help you figure it out a bit better,” Ash says. “It makes for a more productive programmer. It lets you get more done in less time.”
And then there’s Playgrounds, which many, including Vikram Adve, call the most interesting aspect of the new language.
Inside the Playgrounds
Playgrounds, Lattner says on his homepage, is meant to make programming “more interactive and approachable.” It was heavily influenced, he explains, by the philosophies of a designer named Bret Victor and an existing interactive programming system called Light Table. Much like Light Table, it lets you write code on one side of your computer screen and see the results appear on the other side. In other words, you can watch your program run as you write it.
‘I hope that by making programming more approachable and fun, we’ll appeal to the next generation of programmers and to help redefine how computer science is taught.’
The aim is not only to make coding easier, but to provide a better way of learning to program—to bring this skill to a whole new type of person. “I hope that by making programming more approachable and fun,” Lattner writes, “we’ll appeal to the next generation of programmers and to help redefine how computer science is taught.”
This too gives people an immediate incentive to adopt Swift. For any programming language, the main thing that prevents widely spread adoption is that coders just don’t have the time to learn it. But Playgrounds has the power to actually reduce the time that’s needed. According to Ash, Playgrounds is still a bit buggy, but the potential is there to significantly streamline the coding process. “Usually, there’s this really long cycle—long feedback cycle—where you try to figure out what you’re doing,” he says. “But the instant feedback provided by Playgrounds can be huge in getting new people into the field.”
The Need For Complete Speed
What Playgrounds also shows is that Swift is extremely fast—in every respect. It compiles quickly, transforming from raw code into an executable software app, and then that app executes quickly, meaning it runs on your phone or tablet at high speed. This, too, can set Swift apart from other popular languages.
Traditionally, there was a gap between compiled programming languages, such as Objective-C and C++, and interpreted languages, such as Python and Ruby and PHP. With compiled languages, after you wrote your code, you had to wait for your compiler to turn it into executable software, but once it was built, this executable software ran extremely fast. Interpreted languages let you test your program nearly instantly, but in the end, it didn’t run as quickly.
Swift bridges this gap, giving you the best of both worlds. The new language makes it far easier to build and run something without sacrificing how quickly it can run. As Ash puts it, Swift is “friendly to programmers and still friendly to the machine.” He says “it still remains to be seen how this will work out,” but he calls Apple’s work “promising so far.”
As Ash puts it, Swift aims to be ‘friendly to programmers and still friendly to the machine.’
Apple isn’t the only one playing in this area. Facebook is trying something similar with languages called Hack and D. Google is exploring this ground with Go. And Mozilla, maker of the Firefox web browser, is doing much the same with a language known as Rust. In some respects, these languages are much further along than Swift. Facebook is already using Hack to rebuild its massive online service, and Google is using Go to revamp its own internal operation.
What’s more, most of these languages are open source, meaning the code behind their designs is freely available to the world at large. They can, in theory, spread more easily to devices and services from other companies. Swift isn’t open source—at least not yet—and given Apple’s history of so tightly controlling its software and hardware, some question whether a certain corporate heavy-handedness will limit the progress of the language. “There are some worries where Apple might limit the language’s direction—being able to write cross-platform code and things that,” Ash says, referring to the ability to run the language across non-Apple devices.
Even still, Swift is likely to spread at a speed those other languages can’t. Eventually, Ash believes, Apple will open source Swift, and he’s confident the language will flourish outside of the company’s control—mainly because the project is run by Lattner, who has a long history with open source software. “With Chris running the show, I think we can trust him to make the right decisions,” he says. Before Swift, Lattner created something called Clang, a new program for compiling software. As with Swift, he started the project in secret and then took it to Apple, and the company soon embraced it in big way. The kicker is that Clang was open sourced, and now, it’s used by so many others across the industry, including Google.
But even if Swift remains an Apple-only thing, it’s impact could be greater than any other language that has sprung up in recent years, and it may achieve mass adoption faster than any language in modern history. Such is the leverage of all those iPhones, iPads, and Macs. Yes, so many other languages can do most of the same stuff that Swift can do—and some may do it better. In Light Table, there’s even an alternative to Playgrounds. But Swift is still unique.
source: wired.com By Cade Metz