The constructor chain
The constructor chain works as such:
- All Widget constructors takes an anonymous procedure as a parameter, allowing you to create child elements and do adjustments ad-hoc. This minimizes calls afterwards to change properties that might produce visual flicker, and as a bonus there is a speed benefit due to optimization because the entire chain (a form with all its widgets) is created in a single swoop!
- Properties like Left, Top, Width, Height (and similar) are cached by TQTXWidget until the underlying HTML element has been fully constructed. This means you can safely set these properties during construction (read: inside the anonymous procedure), and they will be applied to the element the moment the browser has finished building your elements.
We have to remember that, JavaScript was designed for anonymous procedures and re-entry callback mechanisms. This is something that JavaScript excels at optimizing. It's how JavaScript code is meant to be written. The moment you try to force JavaScript to behave like Delphi or Lazarus, we are punished for it. First and foremost by terrible performance and even unpredictable behavior.
So, by applying this knowledge and exporting the constructor (sharing is probably a better word) through an anonymous procedure, the performance goes through the roof. It is literally thousands of times faster than the alternative. It basically taps into an aspect of JavaScript that, combined with the internal mechanisms of TQTXWidget, JIT compiles exceptionally well.
To give you an example of the performance gains involved:
In 'a competing product' on the market, populating a Listbox with 3000 rows took over 4 minutes (four minutes!). That is outright absurd. Under Quartex Pascal, the exact same code but modified to our style of coding -- populated the Listbox with 30.000 (thirty thousand) rows in 2.6 seconds. That's more than a little improvement! And remember that each row in our system is a full TQTXWidget with all the benefits and properties that gives you.
To learn more about performance gains, click here to read the section on JIT compilation.