Category:Jsish: Difference between revisions

Highlight some more of the Jsi feature set
m (comma)
(Highlight some more of the Jsi feature set)
 
(3 intermediate revisions by the same user not shown)
Line 14:
* No automatic semicolon insertion.
* Empty array/object elements are not supported.
* It is an error to use '''return''' inside of a try/catch body.
* 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]
"1,22,1"
 
jsish># [1,2] + [2,1];
0
 
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; }
variable
 
/* Demonstrate parameterizedtyped typesparameters */
# 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")
1
warn: type mismatch returned from 'foo': expected "number" but got "string", in call to 'foo' <a1>. (at or near "a")
"a1"
 
# foo(1);
ok
2
#
 
The '''jsish''' executable evaluates scripts by interpreter directive or from files given as command line arguments.
 
The '''jsish''' executable evaluates scripts by interpreter directive or, 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 type specifiers, and with '''=!EXPECTSTART!=''', '''=!EXPECTEND!=''' source code markers inside comments (along with =!INPUTSTART/END!= pairs) used for validation during test run capture. Unit test mode is initiated when '''jsish''' is invoked with a '''-u''' command line option.
 
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 commentscomment 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:
Line 82 ⟶ 87:
[PASS] sampler.jsi</pre>
 
''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 isstarts 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, notwithout relying juston '''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. JsishThe system was considered feature stable with the December 2017 release of version 2.4. Development is still active at time of writing, version 2.78.21 released in JanuaryMarch 2019.
 
* https://jsish.org
Anonymous user