Paul Krill
Editor at Large

New compiler tackles JavaScript’s weak typing

news
Jun 6, 20162 mins

With its patent-pending technology, JS++ focuses on compile-time type-checking but is not open source

Software vendor Onux tackles the issue of type safety in JavaScript with a language called JS++, or JavaScript++, which checks types at compile time as opposed to runtime.

The Onux JS++ compiler unifies types into a single type known as the unified external type. By providing a sound type system, declared types (such as a string) will never be incorrect, enabling development of more-reliable applications, said Roger Poon, CEO at Onux and the creator of JS++.

JS++, now available as an early-access preview, compiles to JavaScript and is supported wherever JavaScript is supported, according to Poon. Error-checking at compile time makes JS++ similar to languages like Java.

The technology is not open source, and Poon says the company is seeking to patent it, primarily as a defensive mechanism because companies like Facebook (with Flow) and Google (with AtScript and SoundScript) are working on the same problem. Developers will not have to pay any royalties to use JS++, he said. Onux’s business model, however, includes selling support services and add-on libraries for purposes like charting and graphing. The standard library will be available for free.

Poon doesn’t believe the closed-source nature of JS++ will scare off developers. In fact, he says enterprise developers are pleased with JS++ because it solves a major pain point for them. “They’ve got millions of lines of JavaScript code, mostly legacy code,” he said. “One of the major problems is type-checking.”

JS++ is positioned as a rival to Microsoft’s TypeScript, which Poon said has an “unsound” type system. JS++ is compliant with ECMAScript 3, an older version of the specification underlying JavaScript. Poon said most developers are either using ES3 or ES5.

JavaScript developer and educator Eric Elliott took issue with Onux’s claims, saying he  has not seen empirical evidence that sound type systems lead to lower bug density. “In fact, there is some evidence that the additional overhead of a complex type system may lead to higher bug density,” he said, pointing to a recent essay. “In other words, type correctness does not guarantee program correctness.” Elliott instead advocates for test-driven development.

“I have not used JS++ but I have no reason to believe that the broader JavaScript community will embrace it,” Elliott said. “Many projects before have promised better type safety for the Web platform, including Google’s SoundScript, Google’s Dart language, Google’s Google Web Toolkit, Microsoft’s TypeScript, Facebook’s Flow, and my own rtype project.”

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author