coJS Reference

Introduction coJS is an SDK for implementing command-line applications, JSGI-based web applications, and SCA services, and consists of

  • a practical ahead-of-time compiler for translating a subset of the ECMAScript 3 language (Compact Profile) to C (which can then be compiled to native application binaries on select compilers and platforms, and can link to native static or shared libaries on those platform)
  • a node.js/CommonJS-compatible preprocessor for modules (require())

  • a node.js- and CommonJS-compatible synchronous runtime library for file I/O, HTTP, JSGI, and related utitilies such as for parsing and encoding URLs
  • an integration library for SCA for implementing web services and clients using JavaScript.

Note the coJS compiler only implements parts of the JavaScript language. Moreover, because coJS is designed for AOT compilation, it has many restrictions beyond those already in force for ECMAScript 3 (Compact Profile) (for example, with respect to the use of the new keyword). Moreover, the runtime library, unlike node.js', isn't designed for asynchronous operation.

Note coJS isn't designed and cannot be used as an alternative execution environment for existing node.js applications or for node.js modules. Rather, to create applications that can run on both node.js and be compiled on coJS, applications must be specifically designed for this purpose.

As an implementation environment for server-side JSGI web applications and SCA services, coJS is primarily used to execute in a traditional process-per-request environment with full POSIX process isolation. As such, it is designed for rebustness and security, but isn't designed to match node.js' performance and capabilities with respect to highly asynchronous workloads.

Being statically compiled, coJS applications can be deployed on hosts where JIT compilation is undesired and where address space protection mechanisms such as NX, ASLR, and others are desired.

Description todo