A programming language for all
If you want to create a language simpler than Basic and Julia, the solution is in reactive programming, and even ... the spreadsheet!
In an article in 2009 entitled Spreadsheet Programming, three authors working for Microsoft and the University of Oregon have explained that using a spreadsheet, it is actually to program...
- Cells in which values are entered are the inputs.
- Cells that display a result without being referenced by any other are the outputs.
- Those that contain formulas that refer to other cells and are themselves referenced in other formulas are the instructions of the program.
- There are iterations even if a formula refers to a row or a column, it is applied to each cell thereof repeatedly.
The authors then draw surprising conclusions ...
Spreadsheets are the most used programming systems in the world...
Programming in a spreadsheet, there are 11 million Americans who do it, while there are only 2.75 million programmers using a procedural or functional language (stats of the time).
The first idea that comes to mind is that it is good, but a spreadsheet is used to make financial calculations, and programming is much more general, this applies to all areas of life...
But in reality this is not the case. With a spreadsheet, you can make quantities of interactive applications, and in any area.
There are free versions of spreadsheet in JavaScript, and even that takes thirty lines of code (used to produce the image above, with a custom style sheet).
The Wijmo website that offers one of this widgets presents a list of applications.
- A dashboard to analyze geographic data.
- A shop with stock and purchases management.
- A palette to choose a color.
- A dashboard to manage a stock portfolio.
- An agenda coupled to a schedule.
- A collection of recipes (picture on the right). The number of calories is provided by the formula and is a function of ingredients and their amounts. The preparation is placed in a single cell and is both an input and an output.
- Various forms.
- Etc ...
These applications are made by combining the spreadsheet with other widgets, such as inserting a text editor in a cell, or displaying a graph in a cell with a plotting framework.
Such mashups are possible thanks to the fact that the spreadsheet is using JavaScript and HTML for the interface.
We see that by choosing an HTML 5 interface, we have an additional programming tool: the spreadsheet. We can reduce the effort required for the users by allowing them the task of filling the cell entries, all formulas being predefined in the application (this is actually the case for most of the predefined sheets offered to the public).
The way a spreadsheet works translates into a programming language through the paradigm of reactive programming. This requires the programmer to describe the problem in formulas and leaves the computational work to the interpreter. In contrast, conventional imperative programming requires the programmer to describe step by step the processing to be done to solve the problem.
Reactive programming is often used on databases: in fact, a database table consists of rows and columns like a spreadsheet, and you can make global operations on a row.
The conclusion is that if we want to increase the number of programmers, and create a programming language as accessible as possible, the solution is to create a spreadsheet.
You can build your own JavaScript spreadsheet by following the instructions in this tutorial. Another site offers all Excel functions in JS. But instead of including all mathematical functions, replace them with graphic widgets. There are few mathematicians or financiers among users. You can also use reactive programming in JavaScript.
By Denis Sureau, February 28, 2014 - Updated on 3 feb 2015.