Norm Judah, Chief Technology Officer of Microsoft Services, recently talked about the future of programming:
“When someone thinks of business solutions they will be programming in models. They will still be coding but it wouldn’t be the way you and I think of it right now”.
Judah was speaking at the Future Decoded conference in Mumbai, according to PC Magazine on Feb 22, 2017. He wasn’t totally clear about what he means by “programming in models”. But he did make clear it is something quite different from current standard languages, like C++, C#, Java, or PHP.
“Programming in models” is, of course, a great description of what you do with Analytica. Analytica makes it dramatically easier to build quantitative models of all kinds, especially business models, than with conventional computer languages. Indeed, modeling in Analytica doesn’t require coding in the conventional sense. That’s because of several interesting features that make Analytica quite different from most conventional languages: In brief, it’s visual, declarative, array-based, probabilistic, and does constrained optimization. What exactly do these mean and why are they so useful? .
A visual language
Most obviously, Analytica is a visual language. You build models by drawing influence diagrams to depict the model a high conceptual level. You select nodes to represent variables, decisions, objectives, chance nodes, indexes, constraints, and so on. You draw arrows between them to depict the influence of each variable on others.
A declarative language
The common languages that Judah mentions, C++, C#, as well as Java, PHP, Python, and so on, are what computer scientists term imperative: A program is a sequence of statements or commands to the computer. The programmer controls the sequence of execution by sequencing the statements, and with gotos, iteration loops, and function calls. Analytica, in contrast, is declarative:– It expresses the logic of a computation without specifying the sequence of execution. A declarative program, for example an Analytica model, is an unsequenced set of variables, each defined by an equation or formula expressing its relationship to other variables. You can write these definitions in any sequence that seems convenient. You can understand each definition on its own without knowing the other definitions. You don’t need to worry about or “program” the sequence of execution. Analytica handles that for you. It selects an efficient sequence to evaluate the variables to make sure results are consistent. And it doesn’t have to compute the entire model. It computes only those variables needed to answer a particular user request.
Declarative languages are a popular topic among some computer scientists. Examples include Prolog (for logic programming), rule-based systems, and other simulation languages, like Stella and Vensim. But computer scientists often consider declarative languages to be a bit esoteric. They are used rarely relative to imperative languages – with one gigantic exception: You can look at spreadsheets as a kind of declarative language. You define each cell in terms of other cells, and the spreadsheet application decides what sequence to evaluate them. That, along with the familiar grid user interface, is what makes spreadsheets so appealing and easy to use compared to normal programming. (Oddly, Wikipedia, which is a fount of information on all these programming styles, does not even mention spreadsheets in its article on declarative programming — perhaps because most computer scientists don’t think of them as being a “real” computer language.)
Proponents of conventional imperative languages point out that an imperative or procedural style is easier for some algorithms. Analytica offers standard procedural features, including explicit WHILE and FOR loops, for those (rare cases) when they are essential. But, it does not allow assignments2 because they destroy referential transparency by making it impossible to be sure how a variable is calculated without reviewing the entire program. With a declarative style, you can see how each variable is computed just by looking at its definition without having to worry about any other part of the model.
An array language
Analytica also supports array programming: A value may be a scalar (a single number or text value), or an array with one or many dimensions. Expressions, operators, and functions generalize automatically to work on arrays without you having to write FOR loops to iterate over them as in conventional languages. “Intelligent Arrays” with an Index identifying each dimension make it easy to change the time horizon, resolution — e.g. from years to months — or add dimensions without having to modify all the definitions that use those variables or their results. These kinds of changes to array dimensions require painful and error-prone surgery in spreadsheets and conventional languages.
A probabilistic language
Analytica is a probabilistic language: You can specify uncertainty in any number or array using a probability distribution. Analytica propagates these distributions through the model using Monte Carlo and related efficient simulation techniques. In this way, it makes it easy to analyze risk and uncertainty.
A constraint and optimization language
Finally, Analytica does constrained optimization: That means it can solve a set of simultaneous equations — i.e. declarations of variables — without you having to use algebra to reorder them into a simple sequence the way you would with an imperative language. It can also find the best decision strategy. It finds what combination of decisions will maximize (or minimize) an objective – say expected net present value of profits subject to constraints. It automatically formulates the optimization problem for you based on which variables you specify as decisions, objectives, and constraints, and chooses the solver best suited to the problem. The Analytica Optimizer edition includes solver engines for linear, quadratic, and general nonlinear problems
An elegant combination of language styles
There are other languages that incorporate one or two of these five styles of programming language: Visual, declarative, array, probabilistic, and constrained optimization. But, Analytica is the only one (to my knowledge) that combines all five. I’ve described these five styles of programming as though they are all independent “styles” or “features”. But, it turns out that they work even better in combination: Together, they provide the basis for a language of surprising power and elegance. Some examples: Visual programming becomes unwieldy for large imperative programs, but works much better for a declarative language. Visual programming also works much better with array programming. Compare Analytica’s influence diagrams which link array-valued variables with Excel’s audit arrows that show dependencies between individual cells not arrays, and so are a mess for visualizing dependences in an entire model. Probabilistic programming builds on array programming, adding an extra dimension (Run) to represent random samples from the underlying distributions. Visual influence diagrams use node shapes to identify the role of each variable as a decision, objective, constraint, index, or chance variable. Analytica uses this role information to formulate a problem for optimization automatically. The optimizer also builds on array programming to handle problems over multiple dimensions, including uncertainty, and so naturally supports stochastic and dynamic optimization.
Initially, I expected that Norm Judah, in describing a language that lets you “program in models” was preparing the way for a new Microsoft product. But, apparently not. The article later quotes him saying:
“What language it will be I’d have no clue.”
Could we Analytica modelers be at the leading edge of the future of programming?
2. Actually, Analytica does allow assignments in limited cases where they do not threaten transparency — for example, assignments to local variables inside a Definition.