38

This Programming Tool Makes It Easier for Apps to Work Anywhere

 4 years ago
source link: https://www.tuicool.com/articles/hit/fI3ya2N
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

For programmers, building a new application is never as simple as writing the code. That's because most software depends on other software, such as database management systems, to work. Just because an application works on your laptop doesn't mean it will work well on your company's data center, which might lack some of the software it depends on.

Investors have poured hundreds of millions of dollars into startups likeHashiCorp and GitLab that try to streamline the process of getting applications ready to run in data centers. One of the most prominent of these isDocker, which popularized "containers," a technology that makes it easier to bundle up software to run in the cloud.

But Docker cofounder Solomon Hykes believes the technology he built the company around will soon be eclipsed by a newer technology for building portable applications known as WebAssembly, or "WASM" for short. Hykes and others think WASM is a faster and more secure alternative to traditional containers. Had WASM been around in 2008 when Hykes and company built Docker, they "wouldn't have needed” to create Docker, Hykes tweeted in March. "That's how important it is."

Hykes, who stepped down as CTO of Docker last year but is still on the company's board, isn't exactly a neutral party. He's an investor in a WASM-focused startup called Wasmer. And he quickly followed his initial tweet to say Docker might someday support WASM applications. Docker did not respond to a request for comment.

He's not the only one who sees promise in the new technology. Mozilla, the maker of the Firefox web browser, introduced WASM in 2017 as a new way to create applications that run in browsers. It's now supported by all major browsers, including Chrome and Safari. But it’s also being used to create applications that run outside of browsers. For example, cloud computing companies Fastly and Cloudflare now let customers run WASM applications on their servers.

It's still early days for WASM. Only a few languages, including C, C++, and Mozilla's Rust are currently supported. Cloudflare only recommends using WASM on its service for narrow, computing heavy uses, such as audio processing or resizing images, not for building full-blown applications. But Wasmer founder Syrus Akbary believes it will eventually become a universal computing platform, fulfilling Java's 1990s "Write once, run anywhere" marketing tagline.

Java lived up to that promise, to an extent. But as application development has grown more complex, developers now face challenges beyond ensuring that an app runs on multiple hardware architectures and operating systems. One is the need to install and configure additional software to make an application work properly. Docker and similar tools tackle that problem. But Fastly CTO Tyler McMullen says previous technologies designed to make applications more portable tend to create a trade-off between security and performance. WASM, he says, doesn't require such compromises. "We looked at existing technologies and nothing else fit our needs," he says.

WASM's benefits stem from its origins as a browser technology. Browsers now exist for practically every computing device you can think of. Browser makers and web-standards bodies have spent years ensuring that web developers can write code that will work on practically any standards-compliant browser, regardless of the end user's hardware and operating system. Browser makers have also taken pains to keep websites’ code isolated from your device’s operating system and even from other websites you might have open.

WASM started as a way for developers to write software that runs in the browser using languages other than JavaScript, the standard language for code that runs in a browser. Over the years JavaScript has evolved into a powerful language that can create complex desktop-like applications such as Google Docs, but it still has its limitations. Performance is a big one.

Programmers write software using human-readable programming languages. But they must translate this "source code" into machine-readable code before a computer can run it. When you use a web application, your browser downloads JavaScript and translates it on the fly into machine-readable code. That continual need for translation is part of why even the fastest web applications are slower than well-written native applications.

Some source code can be translated into machine code faster than other source code. "High level" programming languages like JavaScript make life easier for programmers by allowing them to provide less specific instructions to a computer. Think of it as being able to tell someone "make a peanut butter and jelly sandwich" without having to explain where to find all the ingredients, how hard to pull the refrigerator door to open it, or how much pressure to apply to a knife when spreading the peanut butter. That makes it easier and faster for programmers to write code, but the browser then needs to do more work to translate the high-level instructions into the extremely detailed instructions a machine needs.

WASM essentially lets programmers write in a "high level" language and then translate it into a type of low-level language called "bytecode" that requires less translation. The key is that the translation into WASM bytecode happens before you visit a site, so your computer has less work to do after you download the code.

In that sense, WASM is similar to the Java platform, which enables developers to write code in the Java language or a few others, and translate it into a bytecode language that can run on many different platforms. But Fastly’s McMullen says WASM applications use fewer computing resources than Java applications. Because of Mozilla's efforts to isolate WASM code from the device it runs on, there’s less concern that applications will interfere with each other. McMullen says WASM might make multi-user applications safer by keeping different users of the same application isolated from each other.

Mozilla principal research engineer Lin Clark, who has been working on WASM, thinks there could be other security benefits as well.

Developers often rely on open source "modules" that can provide common functionality like password authentication. These components make life easier for programmers by freeing them from the need to reinvent the wheel. But it requires developers to trust a growing number of outsiders. Last year, after a developer handed control over a data processing module for the popular programming platform Node, the new owner used the module to distribute malware .

Clark says WASM could be used to isolate these modules not only from the underlying code platform, but from each other. Or different WASM systems could let developers specify permissions for each piece of code, not unlike the way you can set different permissions for smartphone apps.

More Great WIRED Stories


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK