Small is Beautiful

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:

  • faster download: faster application installation or startup.
  • faster parsing for the browser: faster startup.
  • smaller identifiers: faster execution for non-JITting JavaScript engines.

And smaller also means you can have far more complex applications for a given size budget.

(more…)

DWS news + OP4JS aka SmartMobileStudio

A quick news roundup before Christmas.
 

OP4JS Alpha aka SmartMobileStudio is in the wild

We’ve now sent “Smart Mobile Studio” Alpha version to 50 testers.

Did you miss the beta invite?

Visit www.SmartMobileStudio.com to participate.

SmartMobileStudio leverages DWScript’s JavaScript CodeGen.

My first test app with the alpha was a clock, check it in your iOS or Android Browser or in the Android market. Source is included in the alpha. Will be beautified it later on 🙂

I’ve been playing on another one, head over to YouTube to see a small video, you can also get the apk (47 kB), but beware it’s basic, ugly, and definitely early alpha, but it’s coded in Pascal!

Below is a snippet of the source code (using DWS inline implementations for illustration and compactness purposes, most of OP4JS is written in the more classic interface/implementation style), it’s a snip of the root class of the mini-engine of the game (yes, virtual methods are supported):

type
   TEntity = class
      X, Y : Float;

      function Progress : Boolean; virtual;
      begin
         // does nothing by default
      end;

      constructor Create(aX, aY : Float);
      begin
         X := aX;
         Y := aY;
      end;

      function Dist2(entity : TEntity) : Float;
      begin
         Result := Sqr(X-entity.X)+Sqr(Y-entity.Y);
      end;
   end;
 

Other recent changes to the DWScript SVN

  • Added sample/simple IndyWebServer demo, implements basic “pascal server pages” and demonstrates how to use DWS in a multi-threaded environment. Makes use of RTTI Environment class to expose WebRequest & WebResponse. Expect more details in a future post.
  • TTerminatorThread has been replaced by TGuardianThread, which can “guard” multiple executions
  • Dotted unit names are now supported
  • Random no longer uses the Delphi RTL but XorShift
  • unit name symbols are now included in the Symbol Dictionary
  • include references are now included in the Symbol Dictionary
  • TdwsSuggestions can now optionally suggest reserved words (begin, procedure, etc.)
  • fixes for Inc() & Dec() when operating on references with side-effects.
  • improved several error messages related to parameter passing.
  • other misc. fixes and optimizations, more unit tests.