Microsoft debuts Bosque - a new programming language with no loops, inspired by TypeScript

Interview Microsoft has introduced a new open source programming language called Bosque that aspires to be simple and easy to understand by embracing algebraic operations and shunning techniques that create complexity.

Bosque was inspired by the syntax and types of TypeScript and the semantics of ML and Node/JavaScript. It's the brainchild of Microsoft computer scientist Mark Marron, who describes the language as an effort to move beyond the structured programming model that became popular in the 1970s.

The structured programming paradigm, in which flow control is managed with loops, conditionals, and subroutines, became popular after a 1968 paper titled "Go To Statement Considered Harmful" by computer scientist Edsger Dijkstra.

Marron believes we can do better by getting rid of sources of complexity like loops, mutable state, and reference equality. The result is Bosque, which represents a programming paradigm that Marron, in a paper he wrote, calls "regularized programming."

"This model builds on the successes of structured programming and abstract data types by simplifying existing programming models into a regularized form that eliminates major sources of errors, simplifies code understanding and modification, and converts many automated reasoning tasks over code into trivial propositions," Marron explains in his technical paper.

Under the hood

What's Bosque look like? Here's an example that's the equivalent of an imperative for loop in JavaScript, where // denotes a single line comment.

The GitHub repo for the language contains many more examples.

In an email interview with The Register, Marron said reference equality - when two variables point to the same object in memory - represents an example of the kind of complexity that can cause problems.

"It seems very simple but once you have [reference equality] in the semantics you must constantly think about it along with the pointer aliasing relation it introduces," he said. "One of my favorite papers on aliasing is from 2001 titled 'Pointer Analysis: Haven't We Solved This Problem Yet?' and here we are in 2019 with the pointer aliasing problem is definitely still not solved."

As an example, Marron describes a method that previously always returned a new object, one that you'd like to optimize so it returns a new object, as a singleton pattern or from a cache.

"In a language where objects have identity, this could change the behavior of the program," he said. "However, in Bosque which does not allow object identity, this sort of change is always safe."

Another example, he says would be various forms of indeterminate behavior. "In JavaScript, the sort function is not required to be stable, so V8 used an unstable sort," he said.

"In theory this seems like a trivial thing, but in practice it meant that every time a developer sorted a list they had to remember that it was unstable and take into account the possible reordering of values with the same sort value. Chromium bug 90 was opened in 2008 with a sort stability problem and, before it was finally closed last year to much fanfare, this bug had over 1700 comments."

The big three

Marron's technical paper explores potential sources of programming language complexity that Bosque tries to deal with. But he says eliminating mutable state, loops, and reference equality represent the big three.

"In the academic literature the associated problems of strong-updates, loop-invariants, and alias analysis have been all been worked on extensively for 30+ years and still remain large open problems," he said. "By eliminating these features, and the need to solve the associated problems, many things like symbolic-execution reduce down to conceptually simple tasks (as first described by Floyd, Hoare, and Dijkstra)."

Marron says the initial goal for Bosque is to build automated zero-effort code validation, automated SemVer checking, and compilation to use SIMD hardware, such as AVX or SSE. "At this point we have only done this by hand on small examples but, fundamentally, there don't appear to be any insurmountable obstacles to practical implementations," he said.

At the moment, Marron sees Bosque as a way to explore language design choices and to help create automated developer tools like verifiers and compilers through collaboration with academic and online developer communities.

"The hope is to use Bosque as a proof of concept for various ideas in this space," he said. "In the future we may work to move these ideas into production in some form."

Presently, Bosque relies on an interpreter written in TypeScript, run on Node.js, as a reference implementation. Looking ahead, Marron intends to implement ahead-of-time compilation for WASM and native code. In the coming months, he said, he's going to focus on filling out the various TODO items, bug fixes, and developing features that will support writing larger programs in the language.

He said he has two interns this year, from the University of New Mexico and the University of Colorado Boulder, who will be focused on more advanced developer tooling experiences, like verifying applications are free of runtime errors without additional programmer effort and automatically setting bounds for memory usage over time.

If Bosque finds a place in the development ecosystem outside of academic experimentation, Marron believes it may be in the cloud or IoT space since Bosque code can be compiled into a small footprint, can start quickly, and can be verified for correctness through symbolic analysis. ®

Software News

Jul 18
Co-founder and chief data officer at NPM Inc, moves on
Jul 18
'Empowering' if you've got $$$
Jul 18
Redmond engineer hints at taking super-lang for a spin
Jul 18
Software testing just ain't that special, sniff immigration bod
Jul 18
'No safeguards' on QA accounts, and suddenly this guy gets a Tesla and $1.6m home, say prosecutors
Jul 17
Enterprise features including support for hated ancient browser ready to evaluate
Jul 17
A key proposal for Go 1.14 - adding a built-in try keyword - has been declined