D


Andrei Alexandrescu didn’t stand much of a chance. And neither did Walter Bright.


When the two met for beers at a Seattle bar in 2005, each was in the midst of building a new programming language, trying to remake the way the world creates and runs its computer software. That’s something pretty close to a hopeless task, as Bright knew all too well. “Most languages never go anywhere,” he told Alexandrescu over beers that night. “Your language may have interesting ideas. But it’s never going to succeed.”


Alexandrescu, a graduate student at the time, could’ve said the same thing to Bright, an engineer who had retired from Symantec, the venerable software company, a few years earlier. People are constantly creating new programming languages, but because the software world is already saturated by so many of them, the new ones rarely get used by more than a handful of coders—especially if they’re built by a retired engineer working without the backing of a big-name tech company. But Bright’s new language, known as D, was a bit further along than the one Alexandrescu was working on, dubbed Enki. Bright said they’d both be better off if Alexandrescu dumped Enki and rolled his ideas into D. Alexandrescu didn’t much like D, but he agreed. “I think it was the beer,” he says.


The result is a programming language that just might defy the odds. Eight years after he shook hands with Bright at that Seattle bar, at least one startup has used D to build its entire online operation, and thanks to Alexandrescu, one of the giants of the net is exploring the new language. Alexandrescu is now a research scientist at Facebook, where he and small team of other coders are using D to refashion tiny parts of the company’s massive operation. Bright too has collaborated with Facebook on this experimental D software, as an outsider contractor. As Alexandrescu is quick to tell you, the company isn’t an official sponsor of the language. But Facebook believes in D enough to keep Alexandrescu working on the language full-time, and it’s at least considering the possibility of using D in lieu of C++, the venerable language that runs the systems at the heart of so many leading web services.


C++ is an extremely fast language—meaning that software built in the language runs at high speed—and it gives you great control over your code. But it’s not as easy to use as more modern languages like Python, Ruby, and PHP. It doesn’t let coders build software as quickly. D seeks to bridge that gap, offering the performance of C++ while also making things more convenient for programmers. “TK,” says Alexandrescu, a Roumanian who immigrated to the States in the late ’90s. “TK.”


Among the giants of tech, that’s an increasingly common goal. Google’s Go programming language aims for a similar balance of power and simplicity, and so does the brand new Swift programming language unveiled by Apple. In the past, the programming world was split in two: the fast languages and the simpler modern languages. But now, these two worlds are coming together. “D is similar to C++, but better,” says Brad Anderson, a longtime C++ programmer from Utah who has been using D as well. “It’s high performance, but it’s expressive. You can get a lot done without very much code.”


In fact, Facebook is working to bridge this gap with not one but two languages. As it tinkers with D, the company has already revamped so much of its online empire with a n ew language called Hack, which, in its own way, combines speed with simplicity. While using Hack to build the front-end of its service—the webpages you see when you open the service in your web browser—Facebook is experimenting with D on the back-end, the systems that serve as the engine of its social network.


But Alexandrescu says you can use D to build anything, including the front-end of a web service—the “high-level logic.” The language is so simple, he says, you can even use it for quick-and-dirty programming scripts. “You want to write a 50-line script?” he says. “Sure, go for it.” This is what Bright was originally striving for—a language you could use in all situations. Today, he says, people so often write software applications in multiple languages—a simpler language for the front and a more powerful language for the back. But the ultimate aim should be a single language that does it all.


The Caped Superhero Thing


Alexandrescu refers to his years of work on D as his “caped superhero thing”—a swashbuckling effort to change things for the better. That’s not said with arrogance. Alexandrescu, whose conversation is sprinkled with a wonderfully self-deprecating sense of humor, will also tell you he “wasn’t a very good” programming language researcher at the University Washington—so bad he switched his graduate studies to machine learning. The superhero bit is just a product of his rather contagious enthusiasm for the language.


For years, he worked on the language only in his spare time. “It was sort of a free-time activity, in however much free-time a person in grad school can have, which is like negative,” he says. Bright says the two of them would meet up of coffee shops in Seattle to argue the ins and outs of the language. The collaboration was fruitful, he said, because they were so different. Alexandrescu was an academic. Bright was an engineer. “TK,” Bright says.


When he first joined Facebook, D remained a side project.


—and it became his primary project only after Facebook had hired him as machine learning engineer. “It was better,” he says, “to do the cape-super-hero-at-night thing during the daytime.”


For Facebook, this is still a research project. But the company has hosted the past two D conferences—the last one in May—and together with various Facebook colleagues, Alexandrescu rebuilt two pieces of core Facebook software in D. They rebuilt the Facebook “linker,” an essential part of piecing together the software that runs the company’s web services, and they fashioned as new “preprocessor,” another means of generating the company’s core code.


In both cases, D is used in place of C++. It’s fast enough to stand-in for the venerable language. And yet it streamlines the coding process, having completely overhauled the look and feel of the C family of languages. When Bright first started the language, he called it Mars. But the community that sprung up around the language called it D, because they saw it as the successor to C++. “D became the nickname,” Bright says. “And the nickname stuck.”


D is not an interpreted language like PHP or Ruby. You can’t instantly run code after you write it. Like C++., it’s a compiled language, meaning that you have take time to transform it into executable software before you run it. But, according to Alexandrescu and Bright, it compiles much faster than C++. Bright—who worked on C++, Java, and Javascript compilers at Symantec—says this was one of his primary aims. “When your compiler runs fast,” he says, “it transform the way your write code.” It lets you see the results of your work much quicker.


TK


Facebook is certainly the most high-profile D user. But it’s not the only one. Sociomantic–a German online advertising outfit recently purchase by British grocery giant Tesco—has built its entire operation in D. About 10,000 people download the D platform each month. “I’m assuming it’s not the same 10,000 every month,” says Alexandrescu. And it now ranks above Google Go on the Tiobe index, a widely-cited (but less than comprehensive) ranking of the world’s most popular languages.


For coder Brad Anderson, the main appeal is that D, even though its a compiled language like C++, it feels like an interpreted language, a language that doesn’t require a compile. “It results in code that’s more compact,” he says. “You’re not writing boilerplate as much. You’re not writing as much stuff you’re obligated to write in other language.” It’s less “verbose” that C++ and Java.


What’s more, he says, D code has this unusual ability to generate more D code and weave this into itself at compile time. That may sound odd, but the end result is that build a program that more finely tuned to the task at hand. Essentially, a program can optimize itself as it compiled. “It makes for some amazing code generation capabilities,” Anderson says.


The trouble with the language, Alexandrescu and Bright say, is that it still needs a big-name backer. “Corporate support would be vital right now,” Alexandrescu says. This shows you that Facebook’s involvement only goes so far, and it provides so insight into why new language have so much trouble succeeding. In addition to backing Hack, Facebook employs some of the world’s leading experts in Haskell, another powerful but relatively underused language. What D needs, Alexandrescu explains, is someone willing to pump an awful lot of money into promoting the language. The Java programming language succeeded, he says, because Sun Microsystems put so much money behind it in the ’90s.


The truth is that D still faces a long road to success. But, thanks to that chat in a Seattle bar, it has already come further than most.



No comments:

Post a Comment