DWScript

March 16th, 2012

DelphiWebScript Project

See blog, the documentation, get source at GoogleCode, and view code samples at Rosetta Code.

DWScript is an object-oriented Delphi scripting language for Delphi, despite its name, it is general purpose and not limited to websites.
An extensive unit tests suite ensures high quality and robustness.

DWS allows to use as well as define whole classes (with polymorphism, meta-class and interfaces support, etc.). The scripting language is based on Delphi, but also supports syntax and features similar to Prism and FreePascal, as well as various language extensions.

Scripts can be executed from Delphi applications (in a safe, sandboxed fashion), or compiled into JavaScript that can be run client-side in a browser or any Javascript-capable engine.

  • supports classes, interfaces, records
  • supports static and dynamic arrays
  • sandboxed, automatic memory management
  • strong typing
  • type inference
  • full support for meta-classes
  • support function & methods pointers
  • contracts-programming
  • generalized “case of” and “in [...]” syntax
  • scoped, inline variable declaration
  • operator overloading
  • compound assignment operators
  • extensive exposure, declaration, inspection & debugging features
  • inline implementations of class methods
  • Automated exposure of Delphi types via RTTI
  • Optional COM/OLE capability (via COM Connector)
  • Optional RTTI direct connectivity (via RTTI Connector)
  • Optional asm capability (32 bits, via NASM)
  • Optional JavaScript code generation (compile to JavaScript)
  • etc.
type
   THelloWorld = class
      procedure Put;  // you can also implement out of line
      begin
         PrintLn('Hello, World!');
      end
   end;

var HelloWorld := new THelloWorld; // strong typing, inferred

HelloWorld.Put;

// no need to release objects thanks to GC

Licensing:

DWScript is released under Mozilla Public License 1.1 which, in short, means that it’s free to use in open or closed source projects, free or commercial, provided you honor the following requirements:

  • any application that makes use of DWScript, or is compiled by DWScript should “conspicuously” include a reference to DWScript in its credits, and include or link to the DWScript source files.
  • modification to the source have to be made public under MPL.

If you can’t or don’t want to satisfy the above requirements, contact me for use under other license schemes.

Comments are closed.