Differences between NX and XOTcl
In general, the Next Scripting Language (NX) differs from XOTcl in the following respects:
-
Stronger Encapsulation: The Next Scripting Language favors a stronger form of module encapsulation than XOTcl. While the encapsulation scheme of NX is still weaker than in languages such as Java and C++ (e.g., a developer can still access objects' variables via backdoor idioms), NX renders variable accesses between objects explicit. The requirement to state variable accesses explicitly encourages developers to implement well-defined interfaces which regulate the access to instance variables. Along the way, calling methods and accessing the instance variables from within the owning object became packed into a more compact syntactic form and got computationally faster than operations performed between objects. This advantageous behavior is achieved via Tcl's command and variable resolvers. The use of resolvers made some helper needed in XOTcl obsolete (e.g., helpers for importing instance variables).
- Additional Forms of Method Definition and Reuse: The Next Scripting Language (NX) provides much more orthogonal means to define, reuse and introspect scripted and C-implemented methods.
- Method aliasing: It is possible to use in NX the alias helper to register methods under arbitrary names with arbitrary objects or classes. This functionality is, for example, the basis of the a traits package shipped with NX.
- Method protection: NX provides means for protecting methods being called from certain contexts (method modifiers public, protected and private). As a consequence, developers must define explicitly public interfaces in order to use methods from other objects.
- By invoking methods with their fully qualified names, one can reuse behavior outside the precedence path of a given object.
- In NX, one can define hierarchical method names called method ensembles. The provide a convenient way to provide extensible, hierarchical method collections, similar to subcommands and namespace ensembles.
- One can use in NX the same interface to query (introspect) C-implemented and scripted methods/commands, for example, to retrieve their parameter specifications.
- Method aliasing: It is possible to use in NX the alias helper to register methods under arbitrary names with arbitrary objects or classes. This functionality is, for example, the basis of the a traits package shipped with NX.
- Orthogonal Parametrization: The Next Scripting Language (NX) introduces an orthogonal framework for parametrizing methods and objects. In NX, the same argument parser is used for
-
Scripted methods
-
C-implemented methods and Tcl commands
-
Object Parametrization (configure parameters)
-
-
While XOTcl 1 provided only value-checkers for non-positional arguments for methods, the Next Scripting Framework provides the same value checkers for positional and non-positional arguments of methods, as well as for positional and non-positional object parameters (-parameter in XOTcl 1).
-
While XOTcl 1 supported only non-positional arguments at the begin of the argument list, these can be used now at arbitrary positions.
-
Value Checking:
-
The Next Scripting Language supports checking the input parameters and the return values of scripted and C-implemented methods and commands.
- NX provides a set of predefined checkers (like e.g. integer, boolean, object, ?) which can be extended by the applications.
- Value checking can be used for single and multi-valued parameters. One can e.g. define a list of integers requiring only a single entry in the parameter specification: integer,1..n.
- Value checking can be turned on/off globally, or at the method/command level.
-
-
Scripted Init Blocks: The Next Scripting Language (NX) provides scripted initialization blocks for objects and classes. Scripted init blocks help construct an object and replace the dangerous dash "-" mechanism in XOTcl. The dash-based method invocation could contribute to constructor anomalies as it allowed to set variables and invoke methods upon object creation.
-
More Conventional Naming for Predefined Methods: The naming of the methods in the Next Scripting Language is much more in line with the mainstream naming conventions in OO languages. While, for example, XOTcl uses proc and instproc for object-specific and inherited methods, NX adopts the keyword method.
-
Profiling Support: The Next Scripting Language (NX) provides now two forms of profiling.
-
Profiling via a DTrace provider (examples are, e.g., in the dtrace subdirectory of the source tree)
-
Significantly improved built-in profiling (results can be processed in Tcl).
-
-
Compressed Interface: The Next Scripting Language has a much smaller interface (i.e. provides less predefined methods) than XOTcl, although the expressiveness has increased with NX.
- Significantly Extended Test Suite: The regression test suite of Next Scripting Scripting framework runs more than 5.000 tests, and order of magnitude more than in XOTcl 1.6