All posts by Richard Herz

Initial impressions – HTML5 vs. LiveCode

The Reactor Lab desktop app is built with LiveCode, a cross-platform rapid application development tool. In the Resources, Web app experiments section of this site, we are experimenting with HTML5 technologies – Javascript and CSS – to make interactive web apps. Here are some initial impressions.

HTML5 web apps have the advantage of cross-platform deployment – of a single set of files – on all platforms (operating systems) via web browsers. Web apps don’t have all the functionality of desktop apps and smart phone apps but they do have the main functionality we are looking for. LiveCode has cross-platform deployment on the desktop and as smart phone apps but you have to build and deploy a separate distribution for each platform. Web deployment is under development in LiveCode version 8 but our initial experiments show that loading the first app is slow: about 40 s currently in my browser in California fetching the page from the server in France, where load times increase with distance from the server. But this is a development version of LC 8 and speeds may improve in the future. In contrast, HTML5 web apps are small and load fast.

Layout of LiveCode screens (“cards”) is easy and fast. Just drag and drop both active (e.g., buttons and widgets) and graphical elements. You can easily change the appearance and locations of elements with script when the app is running – so far it seems more easily than in HTML5. For HTML5 apps, we are using the desktop tool MACAW. In that tool, you can also drag and drop elements onto a page, then generate HTML and CSS files but not nearly as easily as LiveCode.

LiveCode is programmed with a very high level, English-like language that is easy to learn. Code (scripts) can be embedded in objects on the screen (e.g., buttons) or placed at a top level (card, stack). Proprietary code can be encrypted in the paid version. HTML5 web apps are programmed with Javascript. We have found Javascript easy to learn, although we have been programming for 50 years in a dozen languages, so we can’t say how easy it will be for a novice. The site w3schools.com is a great resource for learning Javascript, as well as HTML and CSS. Javascript is not attached to individual screen elements but placed at a top level, either in a script tag in the HTML file or, better, in a separate JS file. We haven’t tried text handling in Javascript but text handling in LiveCode is super easy.

Bottom line of initial impressions? LiveCode wins in ease of development and power. HTML5 wins in deployment – one set of files across all platforms – and speed of loading. We are leaning to devoting our efforts for future development to HTML5, although we are going to keep an eye on LiveCode to see if the speed of loading web apps improves significantly.

Progress on web apps

We are making progress in learning HTML5 technologies – Javascript and CSS – to make interactive web apps. Web app experiment 1, in the Resources section of this site, has been updated to feedback control of water level in a tank. We used the desktop app MACAW to graphically layout the main components of the web page and generate the HTML and CSS files.  Then we did some editing of the files generated by MACAW and added a link to our Javascript file.

We wrote the Javascript code ourselves. The Javascript code makes the web page interactive by getting user input, doing the computations, then updating the display. One thing we have discovered is that Javascript runs very fast in today’s browsers. Many years ago we compared the speed of computation of Javascript to some other languages and found it very slow. That situation has changed dramatically.

We are pretty happy with MACAW. It definitely speeds up the process of learning CSS and laying out a web page.  One very nice thing is that it generates standalone HTML and CSS files – you do NOT have to link your site to a proprietary library.

Livecode app on the web

We have added web app experiment 2 to the Resources, Web App Experiments page. This is a LiveCode 8 stack deployed in a web page. LiveCode 8 uses the open-source software Emscripten to compile the LiveCode engine to Javascript, which can then run LiveCode apps in a web page.

The advantage of this approach is that we can develop new apps quickly using LiveCode, which is a rapid app development tool.

One drawback is that a large Javascript file must be downloaded before a LiveCode web app can run. Once downloaded in a browser session, however, multiple stacks can be run without having to download the large file again.

This is very new technology for LiveCode and we expect much improvement in the near future. Get the free, open-source “Community” edition of LiveCode here (link).

Web app experiments

Web app experiments have been added to the Resources page. These are experiments using HTML5 and Javascript to do interactive simulations in a web page. We are just getting started with these experiments.

Reactor Lab is a desktop app with Internet connectivity. Is that the best way to do things, or should we move to web apps?

A nice set of web apps has been written by Professor Anthony Butterfield at the University of Utah. Anthony did his MS in Chemical Engineering at UCSD with our faculty. Here is a LINK to his web site with web apps.

LiveCode speed of execution

Reactor Lab was built using LiveCode. Get the free Community version at  LiveCode.org. LiveCode is great because it is cross-platform: write once and deploy on many platforms. Another advantage is that the stack model and scripting language are very stable in the sense of supporting past versions: some of the script dates from 1993 and HyperCard.

In most cases in Reactor Lab, the speed of LiveCode is sufficiently fast. The most demanding lab using math computations in LiveCode script is Division 7 Biological Reactions, Lab 3 Immobilized Enzyme Profiles. In that lab, as the user moves a slider to change an input parameter, LiveCode solves a second-order, ordinary differential equation using the iterative shooting method, and then updates the graphics.

Calculations in the dynamic Catalyst Pellet are too demanding to run in LiveCode script. That lab has a detailed, elementary-step simulation of carbon monoxide oxidation over a porous solid catalyst. A function was written in C++ to do finite-difference integration of a set of partial differential equations. The external is then compiled separately on Mac and Windows to make an “external” (.bundle on Mac, .dll on Windows). The LiveCode stack calls this external to do the calculations. The advantage of an external is that it is fast. The disadvantage is that you must compile a separate executable for each platform.

When the Catalyst Pellet external was written in 2008, we used Revolution 4, where Revolution was the earlier name for LiveCode. The Catalyst Pellet and its external ran great when we finished it but it is not compatible with later versions of LiveCode. Therefore we pulled the dynamic Catalyst Pellet out into its own standalone app. The problem presumably is that the interface specification between externals and LiveCode changed. The stack and its external initially appear to run in LiveCode 7, but there appears to be a memory leak and a crash ensues. We haven’t had the time to keep the external up to date. The original version posted in the Download section works well.

The speed at which LiveCode 7 updates the card graphics appears to have slowed from previous versions. This may be related to the addition of resolution independence and higher resolution target displays. To speed things up, we lock the screen before changing many separate elements in the display, then unlock the screen when everything on the card has been updated.

SimzLab added to Download page

An archival copy of SimzLab was added to the Download page. Reactor Lab was removed and the “on line” functions do not work in this copy of SimzLab. This copy does contain working copies of PureWaterLab, the Control Lab, and a heat exchanger simulation.

Looking for SimzLab?

We closed the SimzLab project in order to concentrate our efforts here with Reactor Lab. An archival copy of SimzLab is posted at the Download page here at the Reactor Lab site. As we get time, we will incorporate some of the PureWaterLab and Control Lab modules from SimzLab into Reactor Lab.

Looking for PureWaterLab?

We closed the PureWaterLab project in order to concentrate our efforts here with Reactor Lab. PureWaterLab modules are incorporated in the archival copy of SimzLab, which can be downloaded from the Download page here at the Reactor Lab site. As we get time, we will incorporate some of the PureWaterLab modules into Reactor Lab.