Dynamic arrays as stacks, tighter JavaScript
Here is a summary of the changes of recent happenings in the SVN.
Note that this list doesn’t include the very latest changes and features, which will get an article of their own.
Here is a summary of the changes of recent happenings in the SVN.
Note that this list doesn’t include the very latest changes and features, which will get an article of their own.
Amongst the samples included with Delphi, you can find a “Meteors” clone. With SmartMobileStudio approaching the next beta milestone, I gave it a run at compiling old Delphi code, VCL, TCanvas-based, that was never intended to run Web-side… but now does! Click here or the image below to test it!
Oxygene syntax (aka Delphi Prism) for enumerations was recently added to DWScript, with both enum and flags contextual keywords.
Enumerations scoping was already in, but optional, using these keywords make scoping explicitly required.
A new DWScript 2.3 source archive is available (417 kB) for the SVN-averse, the previous available zip was the 2.2 version, which is quite outdated. Given the continuous extension of the unit tests suite, this should hopefully be one of the most stable versions to date, in addition to being the most advanced, but it’s likely less stable and less advanced than the SVN version will be when you’ll read these lines 😉
DWS compiler and execution engine are reaching very nice maturity levels, meaning they can be used to compile & execute code interactively, for instance to edit a web page, which mixes HTML, CSS, server-side dynamic Object Pascal content generation and client-side Object-Pascal scripted content.
DWScript now supports multi-line strings, aka “heredoc”, using the same syntax as Prism/Oxygene, which involves double-quoting them, for instance:
s := "Lorem ipsum 'dolor' sit amet, consectetur adipiscing elit. Duis l'ipsum odio, pretium ""hendrerit"" varius sed, aliquet vitae elit. Sed eu libero nec nisl ""malesuada"" dignissim.";
is equivalent to
s := 'Lorem ipsum ''dolor'' sit amet, consectetur adipiscing elit.'#13#10 +'Duis l''ipsum odio, pretium "hendrerit" varius sed,'#13#10 +'aliquet vitae elit.'#13#10 +'Sed eu libero nec nisl "malesuada" dignissim.';
Which can be quite useful when you have multi-line string content, such as an SQL query, a long format string, a snippet of CSS/HTML/XML, etc.
Nate that if you’re using The SynEdit, the DWS highlighter has been updated and properly highlights those, you just need to get it from the SynEdit SVN.
It a slight cosmetic issue, shared AFAICT by other languages that implement “heredoc”, which is that if you don’t want to have spurious whitespace/tabs in the multi-line string, you basically have to break indentation.
Does any one knows a language which has a convenient “heredoc” syntax that would alleviate this issue?
Not long ago, I wrote the DWScript JavaScript Smart-Linker did not eliminate unused virtual methods, well that limitation is now gone.
A virtual method that is never called, in its base class nor any of its subclasses, will now be eliminated.
In the small game Nickel Iron which was used as illustration, that further reduces the generated output by almost 10% to just 92 kB “raw”, or 23 kB compressed. The gains come from not just the unused implementations being removed, but also a reduction in the size of the various VMTs.
Small JavaScript that is. Or how to go from 350 kB down to just… 25 kB 23 kB.
Smaller JavaScript can help in up to three ways:
And smaller also means you can have far more complex applications for a given size budget.
This summary of recent DWS changes is coming a bit late, and there is quite a bit to cover. Here is a quick, partial roundup of what changed since the last update. (more…)
Closures, also known as “anonymous methods” in Delphi, are now supported by DWScript for the JavaScript CodeGen, with the same syntax as in Delphi: