Skip to content

Programming model

Chris Pearson edited this page Jun 20, 2018 · 6 revisions

Excel's programming model uses a flat pool of cells. The UI for those cells is a 2D grid (in display, in user interaction and in absolute/relation position references). Cells can refer to other cells but must output a single value (number, string, etc). Formula results may also be named. No form of data structure is assumed beyond individual cells, which means the 'meaning' of data can change easily (much like Assembly) and self-referential 'data structures' may be built. Functions may assume some cell layout structure (eg VLOOKUP); if so, this structure must be maintained by the user. Only cells that have been modified by the user may maintain data, which means data structures that are of unknown length cannot be displayed on the grid (although they may appear in intermediary calculations).

Mesh's programming model uses a pool of cells^ with optional nesting. The UI is a 2D grid in display and in user interaction. Cell references in a formula are not to other grid positions, but to names that happen to be displayed in those grid positions. Formulas may output data of arbitrary length - the user interface will expand the cells 'occupied' as needed. Some data structure is allowed, which means it can be harder to change the layout of data within the program than in a traditional spreadsheet (note this could be made easier if needed); on the other hand, it means:

  • calculations can be done on aggregates without needing to resort to range references (eg A1:B2)
  • text diffs of the spreadsheet source code are more meaningful
  • the program will maintain some invariants which prevent errors such as formulas not always referencing all data that is intended
  • it may also facilitate some speedups for repeated functions that could be made faster if they could share some computation (eg hash tables).

In the specific case of Mesh's JavaScript implementation, the traditional data structures such as arrays and objects do not allow for self-references without the use of special 'getters'. This makes expressing some ideas harder than in Excel (eg a table that refers to prior or current rows and columns), but not impossible.

^ 'Cells' in the sense of data that is memoised on calculation and refers to other cells, not in the sense of having a grid position.

Spreadsheet users

  • Comparison to Excel

Clone this wiki locally