jsish
Language
Not logged in

Language Comparisons

Following is a feature comparison of various languages with Jsi.

Feature Jsi NodeJs Tcl Lua Perl Python
Standard ES 5.2+ ES 6+
Implemention C/C++ C++ C C C C
C++ Compatible
Embeddable
C API
Non-Script API
Standalone
Type Checking
Sub-Interps
Introspection
Error Navigation
Logging
Builtin Debugger
Debugger GUI
Web Ready
Modular Apps
Shrink Wrap
Applications
Self Configure

Note, these compare software out-of-the-box.

Definitions

Standard

Jsi and Node-JS are javascript implementations, and so use the Ecmascript standard (at least as a starting point).

The other languages, seem to have just sort of evolved.

The advantage of using a standard are:

Jsi has a further advantage in that it's internal design is based on Tcl. This means that there was just far less design involved, and more building on the shoulders of giants.

Embeddable

All the compared languages can be embedded in a C application, except for Node-Js: it is C++, and is limited loading extensions.

There is a difference in the degree of difficulty involved in embedding each. Perl, and perhaps Python Most require linking against an external libraries, and often involve dealing with dependancies.

By contrast, Jsi was written from the ground-up to be C embeddable. It provides a single amalgamated source file for quick and easy embedding.

Standalone

To be standalone, a language should be easy to statically link.

The jsish binary can be built within libmusl, sqlite and libwebsockets to provide a completely self contained executable. Applications can also include jsi.c directly to build in Jsi support atomically.

See Standalone.

Modular Apps

Jsi supports modules. But it can also execute applications directly from a .zip file.

See Zvfs.

Shrink Wrap

But there's more. Script files used by Jsi are appended to a zip at the end of the executable. This is mounted as a Zip filesystem at runtime. In addition, user scripts can be merged with these to convert jsish into a shrink-wrapped application.

Type Checking

The Javascript language does not provide type checking. Jsi however, supports typechecking function arguments.

See Functions.

Sub-Interps

A sub-interpreter can be used to run scripts in seperate environment and/or threads. Uses include sandboxing, debugging and multi-tasking.

See Interps.

Error Navigation

Error navigation refers to the error message format being compatible with gcc. This allows scripts to be run from editors such as geany and vi, and seamlessly navigate through errors and warnings.

See Errors.

Logging

The logging facilitity in Jsi allows output messages, often including the file, line and function of the current line. More importantly, these inclue logDebug and logTrace that output such messages only when debugging is enabled.

See Logging.

Debug Console

Jsi provides a builtin console debugger. This is invoked with jsish -d SCRIPT.

See debugger.

Debugger GUI

Jsi also provides a web based interface debugger, which is a lot easier to navigate around in that the console.

This is invoked with jsish -D SCRIPT.

Web Ready

Jsi comes with builtin support for:

Example Applications

Aside from the builtin applications for the debugger and sqlite, Jsi comes with the external app Ledger.

See Examples.

Self Configure

Most unix software relies on '''autoconf''' for configuring the application prior to building. In Jsi, a minimial version Jsi is built first so it can self-configure.

C++ Compatible

C++ Compatible refers to the ability to compile source using the GNU C++ compiler, natively. That is, there is no use of extern C.

This means that Jsi code can directly access and employ and access C++ classes and other constructs.

C-API

All code written in C has by definition some form of C API.

But Jsi was modelled internally after Tcl, which has a very mature and well developed C API.

Non-C API

A Jsi-Lite, a subset of the Jsi C-API that is available for use by C programs that require no scripting.

This includes string processing, Hash, Tree and an Sqlite C-API.

See Jsi-Lite.

Implementation

Implementation refers the language the source code is written in. Jsi is unique in that although it is written in C99, it will compile with

make CC=g++.

Using C++ provides a higher level of checking than provided by C, but requires a more rigourous coding style.


Syntax

The following syntax is implemented by Jsi (see Reference for commands):
continue [IDENT] ;
break [IDENT] ;
debugger ;
delete IDENT ;
do { STMTS; } while( EXPR ) ;
for ([var] IDENT = EXPR; EXPR; EXPR) { STMTS; }
for ([var] IDENT in EXPR) { STMTS; }
for ([var] IDENT of EXPR) { STMTS; }
function [IDENT] ([IDENT, IDENT, ...]) { STMTS; }
function [IDENT] ([IDENT:TYPE[=PRIMATIVE], IDENT:TYPE[=PRIMATIVE], ...]):TYPE { STMTS; }
if (EXPR) { STMTS; } [ else { STMTS; } ]
IDENT instanceof IDENT ;
[new] FUNC( ARGS ) ;
return [EXPR] ;
switch (EXPR) { case EXPR: STMTS; [break;] case EXPR: STMTS; [break;]  ... [default EXPR;] }
throw EXPR ;
try { EXPR; } catch(IDENT) { STMTS; } [finally { STMTS; }]
typeof EXPR ;
var IDENT [ = EXPR ] [, ...] ;
with ( EXPR ) { STMTS; }

Expressions

Expressions take the usual form:
IDENT.IDENT
IDENT[EXPR]
IDENT(ARGS)
(EXPR)
EXPR ? STMTS :  STMTS
STMTS , STMTS [, ...]
EXPR OP EXPR 

where OP is one of the binary operators +, -, *, /, etc.


Terminals

NameDescription
ARGSZero or more comma-seperated arguments
EXPR An expression (see below)
FUNCA function value
IDENT Is an valid identifier
PRIMITIVE A primitive value acceptable as an argument type.
STMTS Is zero or more statements
TYPEA type value acceptable as defaults

Keywords

Keywords can be displayed using Info.keywords():
[
  "...", "any", "arguments", "array", "boolean", "break", "case", "catch", 
  "continue", "debugger", "default", "delete", "do", "else", "false", 
  "finally", "for", "function", "if", "in", "instanceof", "new", "null", 
  "number", "object", "of", "regexp", "return", "string", "switch", 
  "this", "throw", "true", "try", "typeof", "undefined", "userobj", "var", 
  "void", "while", "with"
]