User:Soubok~enwiki

My home page
Try my web site

My project
I am working on the jslibs project that is a standalone JavaScript development environment for using JavaScript as a general-purpose scripting language.

jslibs provides a set of native modules that contains various general-purpose classes and functions. Some of these modules are simple wrappers to familiar libraries such as : zlib, SQLite, FastCGI, NSPR (Netscape Portable Runtime), ODE (Open Dynamics Engine), libpng, libjpeg, OpenGL, OpenAL, LibTomCrypt, libffi (Foreign function interface), ... Other modules provide tools to enhance JavaScript programming : Print, Load, Exec, Seal, Expand, Buffer class, ... The jslibs distribution comes with a small standalone command-line access program (jshost) that can be used to run JavaScript files.

jslibs is based on Spidermonkey, the Mozilla JavaScript engine.

JavaScript has always been considered as a second-rate language in spite of its powerful features (see Douglas Crockford's article: "The World's Most Misunderstood Programming Language"). These features like closure (computer science), garbage collection (computer science), generator (computer science), ..., can make JavaScript an efficient and modern general-purpose scripting language like Python and Ruby. The main issue is that there are no or only few ways to execute JavaScript code outside the web browser. Usually SpiderMonkey is used to enable scripting capabilities of existing projects but not for a standalone development environment. jslibs is composed of a set of general-purpose libraries and a host to execute JavaScript source files. The aim of jslibs is to be simple to use, fast and lightweight.

In jslibs a module is the name given to a set of related classes an functions. A module can be a simple wrapper to an existing library. Modules are loaded using the LoadModule function witch is the only function that is provided by the script host.


 * jsstd : provide basic development tools ( Print, Exec, Buffer class, ... )
 * jsprotex : provides tools to create procedural textures.
 * jswinshell : basic support of Windows shell API ( CreateProcess, Console, Systray, clipboard, MessageBox, ... )
 * jsobjex : extended JavaScript object that support add, del, get, set listener of a property.


 * jsz : support of zlib deflate and inflate.
 * jssqlite : support of SQLite database access.
 * jsfastcgi : support server-side applications using FastCGI communication with the web-server.
 * jsnspr : support of Files and non-blocking TCP/UDP Sockets using the Netscape Portable Runtime (NSPR) library.
 * jsode : support of dynamics 3D calculation using the ode the Open Dynamics Engine.
 * jsimage : support of png and jpeg image format using libpng and libjpeg.
 * jsgraphics : support of fast 3D transformations (using SSE instructions) and 3D drawing using the OpenGL library. See Vision Factory in links section.
 * jsaudio : support of 3D audio using OpenAL library.
 * jscrypt : support of RSA, AES, blowfish, twofish, ... ciphers using Tom St. Denis' LibTomCrypt and LibTomMath.
 * jsffi : support Foreign function interface with libffi.

By default, modules are loaded in the global namespace, however, it is possible to load a module in a custom namespace:

SpiderMonkey is only a language library, and, for example, it does not provide any standard input or output access. To display something on the screen, at least a Print function is needed. jsstd module provide a minimal set of basic programing functions like Print, Expand, Seal, ... . Another important basic function is Exec that allows to load (compile and execute) other scripts. The Exec function saves to the disk the compiled version of the script (using the External Data Representation XDR IETF standard) to speeds up following loads of the same script.

Using these libraries is quite simple and the modules can be load at run-time, this allows a good modularity of the code.

Deflate a string using zlib:

Query the version of a sqlite database file:

One interesting feature of jslibs is its server-side scripting capability. Using jshost as a FastCGI program allow server-side applications development. Because jshost is a generic script host, it needs a FastCGI support script to run FastCGI programs:

Then, server-side programs looks like: Note that like in the previous example, the use of E4X can make HTML page easy to generate.

Internaly, jslibs supports two execution modes: safemode and unsafemode. This mode is transmitted to other modules using a global object (_configuration). Each module can use this information to make more tests and assertions in its code. the safe mode is like a run-time debug mode.

Currently, the supported platforms are Windows and Linux, and MacOSX soon.

jslibs is an open-source project under the GNU GPL2 license.


 * Official jslibs website
 * Vision Factory poject is using jslibs for drawing and scripting.
 * An IRC robot made with jslibs.