JS++
JS++ is a programming language for web development that extends JavaScript with a sound type system. It includes imperative, object-oriented, functional, and generic programming features. It is free and open-source software released under a BSD license.
JS++ is a programming language for web development that extends JavaScript with a sound type system. It includes imperative, object-oriented, functional, and generic programming features. It is free and open-source software released under a BSD license. int x = 1; var y = 2; bool z = true; Notably, this differs from TypeScript and ActionScript, which use a more verbose style: let x: number = 1; let y: any = 2; let z: boolean = true; The type system in JS++ is sound for ECMAScript and DOM API corner cases, including host objects, dynamic key-value pairs, Comet, JScript conditional compilation, dynamic return types, ActiveX, ECMAScript for XML, web browser garbage collector and cyclic reference counting bugs, conditional logic, and other edge and corner cases. This differs from other JavaScript supersets where types are optional and discarded at runtime via type erasure, such as in TypeScript. JS++ can use JavaScript libraries using the one-line external statement as in the following example from the homepage of JS++: import System; // Import JavaScript libraries in one line of code external jQuery, $; class Example { public Example() { // Nearly NO learning curve // You can keep writing regular JavaScript var a = 0, random = Math.random(); // Integer types and other primitives // ... enable fast (optimized) and clear code byte[] rgbColors = [0xFF, 0xFA, 0xFF]; } public void showMessage(int id, string text) { // 100% compatible with regular JavaScript jQuery("#msgbox").show(); $("#msgbox").text(id.toString() + text); } } import System; class Employee : IComparable { private string firstName; private string lastName; public Employee(string firstName, string lastName) { this.firstName = firstName; this.lastName = lastName; } public override Comparison compare(Employee that) { // Sort by employee surname return this.lastName.compare(that.lastName); } public override string toString() { return `${this.firstName} ${this.lastName}`; } } Employee zig = new Employee("Zig", "Ziglar"); Employee john = new Employee("John", "Smith"); Employee abe = new Employee("Abe", "Lincoln"); Employee[] employees = [zig, john, abe]; employees.sort(); Console.log(employees.join(", ")); Abe Lincoln, John Smith, Zig Ziglar Thus, in the code above, the custom sorting logic provided is: return this.lastName.compare(that.lastName); Likewise, to call the sort: employees.sort(); For printing the sorted results: Console.log(employees.join(", ")); JS++ provides encapsulation by default. In the following example, the fields x and y are private by default, even if no access modifier is specified. The methods getX() and getY() are public by default. This enables a more concise class definition syntax, as illustrated in the Point class below: class Point { int x; int y; Point(int x, int y) { this.x = x; this.y = y; } int getX() { return this.x; } int getY() { return this.y; } } int[] arr = [1, 2, 3]; Console.log(arr[100]); // out-of-bounds access, 'arr' does not have an element at index 100 In Java and C#, this can result in an exception and program termination. In C, this can result in buffer overflows or segmentation faults. C++ has varying semantics, such as default initialization, exceptions, segmentation faults, or buffer overflows. JS++ can efficiently analyze and prevent out-of-bounds errors at compile time. JavaScript has the notion of null and undefined values, where null means a value is present but it is an empty value, and undefined means there isn't a value there at all. JS++ extends this intuition further to differentiate between empty values and out-of-bounds accesses. Consider the following code, with a nullable int type represented with int? : int[] a = [1, 2]; int? value1 = a[2]; if (value1 == null) { Console.log("Definitely out of bounds"); } int?[] b = [1, null]; int? value2 = b[2]; if (value2 == null) { Console.log("Might be out of bounds, might just be an access of a null element"); } While nullable types can represent an out-of-bounds access, it falls apart when the array might contain nullable values as illustrated above. Instead, JS++ introduces an additional concept in addition to null values: undefined values. Recall that JS++ extends the JavaScript notion that null means a value is present but is an empty value, while an undefined value means a value does not exist at all. JS++ uses the concept of "a value does not exist at all" to mean an out-of-bounds access has occurred, and this concept is known in JS++ as "existent types." Therefore, the previous example can be amended. The existent type int+ means " int or out of bounds" and int?+ means " int , null , or out of bounds": int[] a = [1, 2]; int? value1 = a[2]; if (value1 == undefined) { Console.log("Definitely out of bounds"); } int?[] b = [1, null]; int?+ value2 = b[2]; if (value2 == undefined) { Console.log("Definitely out of bounds"); } Intuitively, this means existent types cannot be used as the underlying type for array elements. JS++ enforces this at compile time: int+[] arr = []; // ERROR [ ERROR ] JSPPE5204: Existent type `int+' cannot be used as the element type for arrays Instead of following every conditional branch or virtual method call path, which would result in path explosion and exponential compile times, existent types have essentially the same compile-time analysis cost as int , bool , and other primitive types. Consequently, compile times have been shown to be unaffected (±1-2ms) by the introduction of existent types. Since existent types are used for all array and container types in JS++ (such as hash maps, System.Stack , and System.Queue ), JS++ containers are thus guaranteed to not have out-of-bounds errors. In JS++, undefined is a value that cannot be changed. In JavaScript (ECMAScript 3), undefined is a mutable property of the global object, resulting in circumstances where "undefined" can be "defined." Thus, existent types would not have been possible in pure JavaScript, as arrays can contain elements with the undefined value, undefined can be defined, or other edge and corner cases that are prevented in JS++. Also, in comparison to Java and early object-oriented languages such as Eiffel, JS++ does not default initialize objects to null . Instead, the compiler enforces initialization by the programmer: class Car {} Car car; [ ERROR ] JSPPE6000: Variable `car' is not initialized at line 3 char 4 Therefore, since existent types are deeply embedded into the language, JS++ can guarantee that out-of-bounds errors never occur. The concept of existent types can be extended outside of containers. For example, in MySQL, columns can be nullable. If the row does not exist for a specified condition (e.g. WHERE clause), the undefined value can be returned. However, if the row does exist but the value at the column is empty, a null value can be returned instead. This can simplify the code and interfaces to the data access layer. byte b1 = 0xFF; // unsigned 8-bit signed byte b2 = -1; // signed 8-bit short s1 = 1; // signed 16-bit unsigned short s2 = 1; // unsigned 16-bit int x1 = 0; // signed 32-bit unsigned int x2 = 0; // unsigned 32-bit long z1 = 1; // signed 64-bit unsigned long z2 = 1; // unsigned 64-bit float f = 0.5; // single-precision floating point double d = 0.5; // double-precision floating point From the project homepage: // You're not required to declare the type for a variable and you can just // keep writing regular JavaScript (again, NO learning curve): var offset = 0; // But, if you do, this next variable will always remain an 'unsigned int' - even at runtime. // You'll never see NaN ("Not a Number") runtime errors again. // This variable is 'unsigned' so it's also guaranteed to never be negative. unsigned int pageHeight = $(document).height(); All variables in JS++ are block-scoped, including the JavaScript var statement. Thus, there is no need for two different variable declaration keywords with different scoping rules, such as var and let co-existing simultaneously in JavaScript (ECMAScript 6).
References
- ^ "JavaScript++: New, Powerful Language for Better Web Development" . 17 October 2011. Archived from the original on 17 October 2011. Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ Bridgwater, Adrian (June 13, 2016). "Onux JS++, an answer to JavaScript 'brittle' type safety?" . Computer Weekly . Archived from the original on 2016-07-22. Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "The JS++ Type System" . Onux.com . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "Classes" . MDN Web Docs . Retrieved 2025-06-20 . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1750374000.0
- ^ Meyer, Bertrand (1988). Object-Oriented Software Construction . pp. 94, 100. Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ Poon, Roger (May 28, 2019). "Tips & Tricks: Object-oriented Sorting in JS++ with IComparable<T>" . Retrieved June 20, 2025 . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ Poon, Roger (June 10, 2018). "Tips & Tricks: Only Fields are 'private' by Default" . Retrieved June 20, 2025 . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "std::unordered_map<Key,T,Hash,KeyEqual,Allocator>::operator[] - cppreference.com" . en.cppreference.com . Retrieved June 20, 2025 . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "std::unordered_map<Key,T,Hash,KeyEqual,Allocator>::at - cppreference.com" . en.cppreference.com . Retrieved June 20, 2025 . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ Díaz, Fabio (January 23, 2019). "JS++, the JavaScript superset, is getting rid of out-of-bounds errors" . Akuaroworld . Archived from the original on February 1, 2019 . Retrieved February 1, 2019 . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "C++ et Javascript = Javascript++" . La ferme du web . 12 October 2011. Archived from the original on 12 October 2011. Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ Cardoza, Christina (January 16, 2019). "JS++ programming language looks to solve out-of-bounds errors" . SD Times . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "ECMAScript Language Specification" (Document). Ecma International . March 24, 2000. p. 86. Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "Void-safety: Background, definition, and tools" . Eiffel . Retrieved June 24, 2025 . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ US patent 11023214 , Roger Poon & Anton Rapetov, "Preventing runtime out-of-bounds errors and exceptions with nominal types", published 2021-06-01 Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "MySQL :: MySQL 8.4 Reference Manual :: 13.6 Data Type Default Values" . MySQL . Retrieved June 20, 2025 . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "MySQL :: MySQL 8.4 Reference Manual :: 5.3.4.6 Working with NULL Values" . MySQL . Retrieved June 20, 2025 . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "Scoping - JS++ & JavaScript Documentation" . Retrieved June 24, 2025 . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "Index of /downloads" . 18 October 2011. Archived from the original on 18 October 2011. Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "Compatibility with JavaScript - JS++ & JavaScript Documentation" . Retrieved June 24, 2025 . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ Poon, Roger (October 9, 2019). "Compiler Software Engineering Methods" . Retrieved June 24, 2025 . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "JavaScript superset JS++ adds dead code elimination and more" . Computerworld . October 19, 2016. Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ Cardoza, Christina (October 19, 2016). "JS++ 0.4.2 released with code editor integrations, modules and dead code elimination" . SD Times . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ Clark, Geneva (October 20, 2016). "JS++ 0.4.2 Release - Upgraded With Modular Design, Dead Code Elimination, and Multiple Code Editors" . Zeomag . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ Phoenix, Ingwie (7 December 2018). "Proof of Concept: Using JS++ with WebPack" . GitHub . Ingwie Phoenix. Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "JavaScript Conference - DeveloperWeek 2016 - February 12–18" . 13 February 2016. Archived from the original on 13 February 2016. Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ Poon, Roger (May 31, 2016). "JS++ Goes Into Public Beta" . Onux.com . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ Handy, Alex (June 1, 2016). "Onux seeks to fix JavaScript's lack of type safety" . SD Times . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ Krill, Paul (June 6, 2016). "New compiler tackles JavaScript's weak typing" . InfoWorld . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ Cimpanu, Catalin (June 9, 2016). "jQuery 3.0 Released and Other JavaScript News" . Softpedia . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "The JS++ Type System, Appendix B: Problems (Why was this hard to solve?)" . Retrieved 10 February 2020 . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ "Compatibility with JavaScript - JS++ & JavaScript Documentation" . Retrieved June 20, 2025 . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ a b c d e f Poon, Roger (January 11, 2019). "JS++ 0.9.0: Efficient Compile Time Analysis of Out-of-Bounds Errors" . Onux.com . Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ Meyer, Bertrand (1988). Object-Oriented Software Construction . pp. 70– 77. Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ a b US patent 10296313 , Roger Poon, "Safely consuming dynamically-typed code from a statically-typed programming language", published 2019-05-21 Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
- ^ a b "JS++ 0.9.1: Bug Fixes" . July 2019. Wikipedia revision 1368554015, retrieved 2026-11-18 · 1794956400.0
Cite this
"JS++". 1786296786. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1368554015