08. February 2019

Excel — a Domain Specific Language for Finance?

One of my biggest inspirations when doing background research before starting GRID was Felienne Hermans. I met Felienne first at Strata in London in 2012, and we’ve kept in touch periodically since. At the time she was studying spreadsheets for her PhD, and I immediately realized that she had a deeper understanding of what spreadsheets are and how they are used than anyone else I’d met.

One of her favorite lines was, “Spreadsheets are code.” (She has a great presentation on this: videodeck.) This quickly rang true for me, but as she so elegantly explains in her recent keynote from rstudio::conf 2019, that was not the case for everyone!

For those of you that are not there yet, I’ll say this: When you understand that spreadsheets are not only code but programs written by “non-programmers,” everything about spreadsheets and how they are used (and abused) will make sense. So give it a deep, long think!

In this keynote she also shares a story about how the research subject for her PhD evolved. It’s perfectly explained in these three cartoon frames from her talk. DSL is short for “Domain Specific (programming) Language”

I’ve heard Felienne’s story before, but when I saw it again it rang even louder this time around because I’d recently heard my friend Ziggy say exactly the same — just not quite as elegantly.

The Dilemma of Quant Freedom

Ziggy works for a company that is building out a specialized tool for quantitative analysts (quants) on Wall Street. The overall tool calculates weighted risk, running Monte Carlo simulations on thousands of scenarios over millions of assets.

As a part of the tool they had to allow the quants to define their own risk evaluations and variations. And the solution they picked was to give quants the freedom to write their own script snippets to run as a part of the simulations.

But freedom comes at a cost. They quickly realized that giving the quants this flexibility allowed them to shoot themselves in the foot. There are unintended consequences to enabling quants to write custom loops — and even embed entire libraries — in code that runs billions of times to complete a single simulation. In fact, when running a script billions of times, each millisecond in execution slows things down beyond acceptable. A change that adds 1 millisecond to the execution time, will cost almost 12 days to run 1 billion times without parallelization!

By adding functionality that was meant to give the quants more freedom, Ziggy and his colleagues created a new set of challenges for themselves. They now found themselves deep in problem solving mode, helping their clients optimize and simplify scripts.

Ziggy’s team started wondering if there was a simpler solution. Maybe it would be better to allow customers to express their “mathematical desires” in a declarative way rather than giving them the freedom to write scripts from scratch.

And they realized there is a simple solution: Spreadsheet models are perfectly declarative and allow people to describe their intentions without thinking about the exact method. Optimization can be done on the spreadsheet engine and the implementation of the individual spreadsheet functions, rather than on each and every custom model.

And as a major bonus point: Every single person in finance knows this language by heart!

Excel is indeed a Domain Specific Language for finance (and beyond), and a pretty darn good one at that.

This article is also published on Medium.

Written by Hjalmar Gislason

More blog posts

30. September 2021

Build a price quote calculator in 5 easy steps 

Embed interactive features like calculators on a website, and voilà! They become super-engaging conversion rate boosters 🚀

25. August 2021

Embedding 101: Entrepreneur Edition

As GRID grows and evolves, so do interesting new use cases and patterns of GRID-authorship. These patterns help us learn...

23. March 2021

GRID launches empowering spreadsheet-to-web software 

It’s launch time, and we couldn’t be more thrilled. Something special happens when a team this passionate unites behind a...

21. October 2017

3 things you don’t understand about spreadsheets (Part 1)

The world has a love/hate relationship with spreadsheets.

27. October 2017

3 things you don’t understand about spreadsheets (Part 2)

This is part 2 of 3 in a series of posts about the nature and history of spreadsheets.

28. August 2018

Excel vs. Google Sheets usage — nature and numbers

One of the most common questions I get is if Excel is still important, implying that “everybody” must be using...

16. October 2018

The 3 types of spreadsheets

We have been taking quite a deep dive into the world of spreadsheets lately. We have analyzed tens of thousands of...

03. November 2017

3 things you don’t understand about spreadsheets (part 3)

This is the third and final part of a series of blog posts on the origin and nature of sspreadsheets.

14. December 2018

The 20 Best Spreadsheet Quotes

In GRID’s deep dive into the world of spreadsheets, we’ve come across a lot of insightful, witty and sometimes somewhat distressing quotes....