Software

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

Here's that regularized programming you wanted. Bish, bash, er, Bosque


Interview Microsoft Research 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.

//Functor (Bosque) 

var a = List[Int]@{...}; 
//Pre: true 

var b = a.map[Int](fn(x) => x*2); 
//Post: List[Int]::eq(fn(x, y) => y == x*2, a, b)

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.

Rust never sleeps: C++-alike language tops Stack Overflow survey for fourth year in a row

READ MORE

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. ®

Send us news
197 Comments

Licensing labyrinth for Power Apps and Dynamics 365 must be clarified, warns expert

Rules still unclear for Microsoft users making potentially costly decisions on enterprise applications

EU antitrust cops probe Microsoft ties between Entra ID and 365 services

Google claims rival has made an 'art and science' out of licensing

Microsoft Copilot for Security prepares for April liftoff

Automated AI helper intended to make security more manageable

Microsoft forges One Teams App To Rule Them All

Windows preview delivers one app to handle multiple accounts, boosts Copilot's capabilities

Developers beware, Microsoft's domain shakeup is coming soon

If you don't pay attention, your lovely little Teams app will stop working

GPT-4 won't run Doom but will play the game poorly

Should we worry this model is happy to grab a gun and start blasting?

Microsoft hits Inflection point, peels off top personnel to form AI division

FYI, FTC: Karén Simonyan, DeepMind co-founder Mustafa Suleyman absorbed rather than acquired

Microsoft says AI alliances are needed to compete with Google

Only the Chocolate Factory is 'vertically integrated' to win at 'every AI layer from chips to a thriving mobile app store'

Canva acquires Affinity, further wounding a regulator-bruised Adobe

Yet another reason to reconsider that overpriced Creative Cloud subscription

Microsoft sends OneDrive URL upload feature to the cloud graveyard

Preview's promise ends in digital dust

Microsoft promises Copilot will be a 'moneymaker' in the long term

Exec tells investors to 'temper' expectations as mission to convince customers of price tag continues

Intel throws chips on the table, Microsoft plays the Copilot card in wild bet on AI PCs

Does anyone actually want one?