From Rosetta Code
This programming language may be used to instruct a computer to perform a task.
Official website
Garbage collected: Yes
Parameter passing methods: By value
Type strength: Weak (assistive)
Type expression: Implicit
Type checking: Dynamic
See Also:

Listed below are all of the tasks on Rosetta Code which have been solved using Jsish.
Your Help Needed
If you know Jsish, please write code for some of the tasks not implemented in Jsish.

Jsish is a scripting language based on ECMAScript syntax, influenced by Tcl internals, extended for Web development, and designed for embedded use. Developed by Peter MacDonald, the creator of the first stand alone GNU/Linux distribution, SLS, Softlanding Linux System (circa 1992).

Jsish (JavaScript Interpreter SHell, Jsi for short) syntax is based on ECMAScript 5.1, but deviates in some key areas:

  • No automatic semicolon insertion.
  • Empty array/object elements are not supported.
  • The Error object is not implemented: the argument to catch() is a string.
  • The Date object is not implemented: strftime/strptime are provided to replace the functionality.
  • UTF character manipulation is not yet supported, but whole string literals are.
  • The typeof [] is "array" instead of "object".
  • Function definitions can use type specifiers and provide default values.

While Jsish can honestly be called a Javascript interpreter, the extensions and differences from standard, form what is, realistically, a different language. For instance:

   nodejs> [1,2] + [2,1]
   jsish# [1,2] + [2,1];

Typed parameters for functions also sets Jsi apart from other ECMAScript implementations.

   prompt$ jsish
   Jsish interactive: see 'help [cmd]'
   # function foo (a:number, b:string="ok"):number { puts(b); return a+1; }
   /* Demonstrate typed parameters */
   # foo('a', 1, 2);
   warn: got 3 args, expected 1-2, calling function foo(a:number, b="ok"):number    (at or near "a")
   warn: type mismatch for argument arg 1 'a': expected "number" but got "string", in call to 'foo' <a>.    (at or near "a")
   warn: type mismatch for argument arg 2 'b': expected "string" but got "number", in call to 'foo' <1>.    (at or near "a")
   warn: type mismatch returned from 'foo': expected "number" but got "string", in call to 'foo' <a1>.    (at or near "a")
   # foo(1);

The jsish executable evaluates scripts by interpreter directive, from files given as command line arguments or interactively. Influenced by Tcl, Jsi also supports sub-interpreters and certain features can be restricted for safer computing.

Unit testing is built into the interpreter, assisted by Jsi syntax allowing for argument and return type specifiers, and with special =!EXPECTSTART!=, =!EXPECTEND!= source code markers inside comment blocks (along with =!INPUTSTART/END!= pairs). These are used for validation during test run capture. Unit test mode is initiated when jsish is invoked with a -u command line option. These blocks of expected results can be entered and maintained manually, or initially created (and updated as changes are made) with jsish -u -update true <scriptname>. This ease of use is hoped to encourage full and complete testing of Jsi scripts and applications.

For example:

#!/usr/local/bin/jsish -u %s
var a = { abc: "abc", def: "123" };
{ "abc":"abc", "def":"123" }
prompt$ jsish sampler.jsi
{ "abc":"abc", "def":"123" }

prompt$ jsish -u sampler.jsi
[PASS] sampler.jsi

prompt$ chmod +x sampler.jsi
prompt$ ./sampler.jsi
[PASS] sampler.jsi

The operating system interpreter directive in sampler.jsi includes -u, so testing mode is the default run state for that script.

Modules and packaging (provide and require) is also part and parcel of Jsi development. Command option parsing, autoloading, versioning and builtin help is included in the Jsi module design along with other programmer and user friendly features.

Embedding Jsi in C or C++ applications starts out by simply including a single amalgamated C source file, jsi.c, similar to the SQLite model. The sources are crafted to support compilation by either C or C++ compilers, without relying on extern "C" blocks.

Jsish includes database and websocket modules; SQLite, MySQL, libwebsockets. The interpreter also includes Zlib compressed Virtual File System features; support modules are included in an archive appended to the executable and mounted as '/zvfs/'. Deployment of entire applications can ship as a single file, including images and other normally external resources.

Jsish first appeared in 2015. The system was considered feature stable with the December 2017 release of version 2.4. Development is still active at time of writing, version 2.8.1 released in March 2019.


This category has only the following subcategory.