The web programming language JS++ is looking to tackle a common problem impacting a majority of major programming languages: out-of-bounds errors. Programming language and compiler company Onux announced the release of JS++ 0.9 this week.

RELATED CONTENT: The case for JS++

Out-of-bounds errors occur when the container element you are trying to access doesn’t exist. “For example, if an array has only three elements, accessing the tenth element is a runtime error,” Roger Poon, JS++ lead designer and co-inventor of existent types, explained in a post.

“Out-of-bounds errors have plagued computer science and programming for decades. Detecting these errors at compile time has ranged from slow to impossible, depending on the language design,” Poon added. In addition, these errors can result in application termination.

New call-to-action

The latest release of JS++ aims to address this with a new compiler that analyzes out-of-bounds errors at compile time. “We achieve efficient analysis using traditional nominal typing. An existent type is no different from ‘bool’ or ‘unsigned int’ in JS++ in terms of type checking performance,” Poon explained. “It is true you need to know the size of the array. However, you do not need to know the size of the array at compile time. Existent types describe whether a value is within-bounds or out-of-bounds. The rest is compiler engineering: bounds checking is delayed to code generation and Standard Library code rather than being performed in the type checker.”

The release also addresses nullable types. “Null values” are values that exist but are empty, while “undefined values” are values that do not exist at all, such as out-of-bounds accesses. This enables differentiation between in-bounds values and out-of-bounds accesses. Nullable types can be the container element type when representing empty values are needed, but existent types are used only for representing out-of-bounds accesses and cannot be the container element type, the team explained.

“JS++ has a long history of seamless compatibility with JavaScript, and I want to emphasize that we’ve merged nullable and existent types into JS++ while maintaining that seamless compatibility and not compromising correctness,” said Anton Rapetov, lead compiler engineer for JS++ and co-inventor of existent types. “In our discussions on nullable types, I highlighted that a user might want a list of nullable values. We couldn’t return ‘null’ on an array access because the user would not be able to differentiate an in-bounds value that is ‘null’ from a failed, out-of-bounds access that is also ‘null’.”

Other features for JS++ include improvements to performance and usability. Going forward, the JS++ team plans to address engineering complexity. More information is available here.

Source: sdtimes.com