maxresdefault100660276orig

New compiler tackles JavaScript's weak typing

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 system. 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."

IDG Insider

PREVIOUS ARTICLE

« Lawsuit seeks to replace H-1B lottery with a filing-date-based system

NEXT ARTICLE

Why legal departments begrudge the cloud »
author_image
IDG News Service

The IDG News Service is the world's leading daily source of global IT news, commentary and editorial resources. The News Service distributes content to IDG's more than 300 IT publications in more than 60 countries.

  • Mail

Recommended for You

International Women's Day: We've come a long way, but there's still an awfully long way to go

Charlotte Trueman takes a diverse look at today’s tech landscape.

Trump's trade war and the FANG bubble: Good news for Latin America?

Lewis Page gets down to business across global tech

20 Red-Hot, Pre-IPO companies to watch in 2019 B2B tech - Part 1

Martin Veitch's inside track on today’s tech trends

Poll

Do you think your smartphone is making you a workaholic?