Difference between revisions of "NovaScript Introduction"

From Nova Documentation
Jump to: navigation, search
(What is NovaScript?)
(What is NovaScript?)
Line 18: Line 18:
 
As mentioned above, NovaScript is embedded in JavaScript. Precisely, this means that NovaScript is JavaScript with additional functionality and special objects. The concept of extending the JavaScript core with special objects is not new. In fact, we’ve seen that JavaScript itself does this with the Math object, used to bundle together a substantial set of mathematical functions<ref>Similarly, there is a JavaScript Date object used to contain date and day-of-week data.</ref>. In order for JavaScript to control the behavior of a Web browser, the JavaScript environment is extended with a <tt>Document</tt><ref>For this reason, the JavaScript Web browser environment is often called the document object model, or DOM.</ref> object that contains fields specifically designed for Web browser functionality. NovaScript similarly extends JavaScript with a set of object specifically engineered to express the design of Nova. Thus there are Stock, Term and Flow objects corresponding to those components in a visually.
 
As mentioned above, NovaScript is embedded in JavaScript. Precisely, this means that NovaScript is JavaScript with additional functionality and special objects. The concept of extending the JavaScript core with special objects is not new. In fact, we’ve seen that JavaScript itself does this with the Math object, used to bundle together a substantial set of mathematical functions<ref>Similarly, there is a JavaScript Date object used to contain date and day-of-week data.</ref>. In order for JavaScript to control the behavior of a Web browser, the JavaScript environment is extended with a <tt>Document</tt><ref>For this reason, the JavaScript Web browser environment is often called the document object model, or DOM.</ref> object that contains fields specifically designed for Web browser functionality. NovaScript similarly extends JavaScript with a set of object specifically engineered to express the design of Nova. Thus there are Stock, Term and Flow objects corresponding to those components in a visually.
  
 +
 +
==Notes==
 
<references/>
 
<references/>

Revision as of 22:21, 3 January 2015

All running Nova simulations are expressed in a language called NovaScript. Even in the simplest stock- flow model, you are already writing NovaScript code when you enter expressions for initial Stock values, Flows, and Terms (we’ll refer to these as component definitions). For these models, however, the code is generally restricted to simple numerical expressions. You will see that to express the relationships required of complex models your definitions will necessarily include a broader set of expressions.

NovaScript is an extension of a well-known and widely used language called JavaScript. This means that NovaScript uses JavaScript syntax for all of its code; moreover, any legal JavaScript program is also a NovaScript program. This includes the code used for initial Stock values, Flows and Terms. Fortunately, there are many good sources for learning to program in JavaScript. Please read the introduction to JavaScript contained here before continuing with this section.

A complete Nova model is expressed in NovaScript. You create the program for this model when you click the Capture button. Nova is able to construct the scaffold for your model using the structure of the visual elements placed on the canvas. As author you are expected to provide the details connecting the various components through the component expressions. In systems dynamics models component expressions generally operate solely on numerical data; i.e., they are simple arithmetic expressions.

As you extend your use of Nova into more complex applications the coding used to link components will also become more complex. This complexity manifests along the following dimensions:

  • The data structures used. Simple applications can rely on simple numerical data. For more advanced use you will need to introduce arrays and objects, and may also want to create your own functions.
  • The program structures required. Multi-line computations involving loops and conditionals generally accompany the use of data structures such as arrays and objects.
  • The use of primitive operators. Models using Nova’s aggregating components rely heavily on primops. You will need to become familiar with these primops and how they provide necessary information to the constituents of the aggregators.

What is NovaScript?

As mentioned above, NovaScript is embedded in JavaScript. Precisely, this means that NovaScript is JavaScript with additional functionality and special objects. The concept of extending the JavaScript core with special objects is not new. In fact, we’ve seen that JavaScript itself does this with the Math object, used to bundle together a substantial set of mathematical functions[1]. In order for JavaScript to control the behavior of a Web browser, the JavaScript environment is extended with a Document[2] object that contains fields specifically designed for Web browser functionality. NovaScript similarly extends JavaScript with a set of object specifically engineered to express the design of Nova. Thus there are Stock, Term and Flow objects corresponding to those components in a visually.


Notes

  1. Similarly, there is a JavaScript Date object used to contain date and day-of-week data.
  2. For this reason, the JavaScript Web browser environment is often called the document object model, or DOM.