DWScript

DelphiWebScript Project See blog, the documentation, get source from BitBucket or GitHub, view code samples at Rosetta Code, ask questions on StackOverflow, report issues and suggestions.

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 Oxygene and FreePascal, as well as various language extensions. Scripts can be executed from Delphi applications (in a safe, sand-boxed fashion), you can also compile and execute them with JavaScript-capable engine using Smart Mobile Studio. An experimental JIT compiler is available for Win32 & Win64.

  • supports classes, interfaces, records
  • supports static and dynamic arrays
  • sand-boxed, automatic memory management
  • strong typing
  • type inference
  • full support for meta-classes
  • support function & methods pointers
  • contracts-programming
  • generalized helpers
  • 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
  • partial classes
  • property expressions
  • 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 automatic memory management

DWScript Programming

Much of your Pascal or Delphi knowledge will apply, for general information and news, see the blog. There is also a work in progress documentation wiki. Rosetta Code holds many DWS examples, which can be quickly compared with other languages and other Pascal dialects. If you have questions, you can ask them on StackOverflow, and you can also report more specific issues and suggestions.

DWScript Web Server

A sample DWScript Web Server is available in pre-compiled, installable form for Windows 2008R2 and above servers. It offers a high-performance server where pages and requests can be scripted.

While it can be used “as is”, users are encouraged to consider it as a starting point, and use it with their own business libraries and configurations.

 

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.