DWScript news and sneak peek

dwsBelow is a quick summary of changes in the SVN since the last post.

There is also a mini-sneak peek of things to come!


Recent changes

Language changes

  • Arrays can now be concatenated with the ‘+’ operator (same as XE7), note that it is supported for static arrays too, but a concatenation of static arrays results in a dynamic array.
  • The ‘+=’ operator is now supported by dynamic arrays as syntax sugar for the Add() pseudo-method, so you can use it to concatenate either another array or an element.
  • “library” is supported as an alternative to “program” for the main program, the script engine exposes it but currently gives it no particular meaning.

Changes relative to SmartMS (for next version)

  • introduced support for anonymous classes
  • improved the JS codegen to minimize dependencies to TObject when only JObject or external classes are used
  • initial support for scripting the JS codegen (see sneak peek)

Fixes

  • Fixed a scoping issue for helpers across units (which in some circumstances were no longer helpful)
  • Fixed edge case issues with overloaded methods & visibility
  • Fixed an edge case issue with accessing a dynamic array element directly from a function returning a dynamic array
  • Fixed suggestions which were failing in some case

Internal changes

  • script interfaces & dynamic arrays are now handled internally distinctly from scrip instances, previously they were using a common (Delphi-side) interface

Sneak peek

Well, sneak peeks new bits actually 🙂

dws web serverYou may remember that the SmartMobileStudio command-line compiler was released for free sometime ago, in the next DWS WebServer the JavaScript CodeGen will be available as well (in pre-compiled form), allowing to use Pascal both server and client-side auto-magically!

The other tidbit is that the JS CodeGen is now becoming scriptable! this means that what the CodeGen generates can be customized by scripts, so you can perform case-specific code generation.

The first use case for this is going to be server-side compilation of static Mustache or Handlebars semantic templates. This allows to write and maintain regular templates, and have them them compiled to straight JS when they’re static, with no parsing of the template on the client-side.

4 thoughts on “DWScript news and sneak peek

  1. Yes, DMustache is good, it got me started on trying to bump up client-side mustache performance 🙂

    The custom Mustache CodeGen does not support the full syntax yet, but preliminary tests indicate the native JS it generates is already way above other frameworks compiled templates (3x faster than Handlebars, 2x faster than Hogan). Eventually, I hope to get the JS within trimming distance of DMustache 😉

Comments are closed.