What is Bosque
Bosque was designed by Microsoft Research computer scientist Mark Marron on April 15 of 2019.
The Bosque project was born from Mark Marron's work, where he questioned the accidental complexity that exists in programming languages nowadays. He proposed a new programming language design that eliminated the factors of this complexity in terms of loops, recursion, mutable state, and reference equality, among others, thus resulting in a new paradigm called Regularized Programming.
Bosque is a free and open-source programming language.
A programming language without loops!
Bosque has a syntax inspired by TypeScript and adopts semantics from ML and JavaScript, giving rise to a programming language that is easy to write and read.
Purpose of Bosque
Bosque aims to remove unnecessary complexity that often arises in software development. By minimizing the number of ways to express the same idea and reducing the language's syntactic and semantic complexity, Bosque makes it easier for both humans and machines.
The design was driven heavily by the identification and elimination of various sources of accidental complexity and insights on how they can be alleviated via the thoughtful language design.
Benefits of Bosque

- Reduced Accidental Complexity
Bosque is designed to minimize accidental complexity in programming. This means fewer language constructs and simpler syntax, making the code easier to read, write and maintain. - Enhanced Code Reliability and Safety
Bosque emphasizes a side-effect-free functional programming model and immutable data structures. This leads to more predictable and reliable code, as functions do not alter shared state or produce unexpected side effects. - Improved Developer Productivity
The language's concise syntax and powerful abstractions streamline common programming tasks, reducing boilerplate code and allowing developers to focus on the core logic of their applications. This can lead to faster development cycles and quicker time-to-market for new features. - Better Performance and Optimization
By eliminating side effects and promoting immutability, Bosque allows for more aggressive compiler optimizations. This can result in more efficient execution of programs, especially in concurrent and parallel computing scenarios. - Facilitates Concurrent Programming
Bosque’s emphasis on immutability and pure functions simplifies concurrent and parallel programming. Without mutable shared state, developers can more easily reason about the behavior of concurrent programs, leading to fewer synchronization issues and deadlocks.
Bosque Applications
The Bosque programming language is designed with specific goals and features that make it suitable for certain types of applications and use cases. Here are some areas where Bosque can be particularly beneficial:

Cloud-First Development
One of the main challenges of new, trending technologies such as serverless applications, microservices architecture, and IoT is reaching interoperability with a minimum computational cost. Nowadays, we must deal with serializing and deserializing messages or the slow response times of cold services starting up.
Bosque includes features such as API types to simplify the development of APIs. Its initialization design allows a zero-cost load for cold startups, in addition to characteristics such as immutability and its deterministic nature, which will enable us to build high-performance and resilient applications for cloud environments.
Automatic Verification
One of the advantages of a programming language that allows you to implement models based on formal reasoning is that this can be analyzed by tools that allow us to identify and eliminate errors through verification and validation processes. This improves the reliability of the execution's results. Some of the application settings could be as follows:
- Cryptographical protocols
- Implementation of finite state machines
- A network's mathematical models
Synthesis Programming
The deterministic nature of Bosque makes it an ideal candidate for the application of AI for code synthesis from formal specifications. This has been an existing challenge since the first days of AI as a study branch, so this synergy could be fascinating.
Most Notable Features and Design Choices in the Bosque
Bosque offers a range of notable features that streamline development and improve code quality.
Immutable Values
All values in the Bosque language are immutable!
Reasoning about and understanding the effect of a statement or block of code is greatly simplified when it is side-effect free. Functional languages have long benefited from the simplifications to program development, sophisticated tooling, and aggressive compiler optimizations that this model allows. From this perspective the natural choice for the Bosque language is to adopt a pure functional model with immutable data only.
Block Scoping
Local variables with block structured code is a very appealing model for structuring code. The Bosque language fuses functional programming with block scopes and {…} braces by allowing multiple assignments to updatable variables “var!”. This supports functional style programming in a block-scoped language and allows developers to write code such as:
function abs(x: Int): Int {
var! sign = 1; //declare updatable variable with initial value
if(x < 0) {
sign = -1; //update the variable
}
return x * sign;
}
Reference Parameter Threading
Bosque language also allows developers to thread parameters via ref argument passing. This alternative to multi-return values simplifies scenarios where a variable (often some sort of environment) is passed to a method which may use and update it. Allowing the update in the parameter eliminates the extra return value management that would otherwise be needed:
function internString(ref env: Map<String, Int>, str: String): Int {
if(env.has(str)) { //use the ref parameter
return env.get(str);
}
env = env.add(str, env.size()); //update the ref parameter
return env.size();
}
...
var nameid = internString(ref env, "hello");
Typed Strings
Typed strings provide a novel mechanism for lifting known structure about the contents of a string into the type in a way that is meaningful to humans and that can be used by the type checker. This allows for code such as the following:
function foo(zip: String<Zipcode>, name: String) {...}
var zc: String<Zipcode> = Zipcode'98052';
var user: String = "Mark";
var zcbad: String<Zipcode> = "9"; //error not a typed string on right side
var zcbad: String<Zipcode> = "98052"; //error still not a typed string on right side
var zcbad: String<Zipcode> = Zipcode'9'; //error bad format in typed string literal
foo(user, zc) //Type error String not convertible to String<Zipcode>
foo(zc, user) //ok
Validating Program Behaviour
A central goal of the Bosque language is to simplify the process of building high reliability software. As part of this, the language provides first-class support for expressing a full range of invariants, sanity-checks, and diagnostic assertions.
entity Foo {
field x: Int;
invariant x > 0; //check whenever a Foo is constructed
method m(y: Int): Int
requires y >= 0; //precondition
ensures _return_ > 0; //postcondition
{
check this.x - y > 0; //sanity check - enabled on optimized builds
assert this.x * y != 0; //diagnostic assert - only for test/debug
return x * y;
}
}
Recursion
As for recursion, things aren't too different in Bosque. The only new thing is the
recursive keyword, which informs us that a function is meant to be called recursively. This keyword is required both at the function definition and at the call. This may seem a little too problematic and frustrating, but there is a good reason to do this.
recursive function fibonacciNumber(n: Int): Int {
return if (n == 0) 0
elif (n < 3) 1
else fibonacciNumber[recursive](n - 1) + fibonacciNumber[recursive](n - 2);
}
entrypoint function main(): Int {
return fibonacciNumber[recursive](10);
}
Iterative Processing
A fundamental concept in a programming language is the iteration construct and a critical question is should this construct be provided as high-level functors, such as filter/map/reduce, or do programmers benefit from the flexibility available with iterative, while or for, looping constructs. To answer this question in a definitive manner the authors of Mining Semantic Loop Idioms engaged in a study of all the loops "idioms" found in real-world code. The categorization and coverage results showed that almost every loop a developer would want to write falls into a small number of idiomatic patterns which correspond to higher level concepts developers are using in the code, e.g., filter, find, group, map, etc. With this result in mind the Bosque language trades structured loops for a set of high-level iterative processing constructs.
var v: List<Int?> = List<Int?>{1, 2, none, 4};
//Chained - List<Int>{1, 4, 16}
v->filter(fn(x) => x != none)->map<Int>(fn(x) => x*x)
Multiply All Array Elements by 2
C Language
int a[5] = {1, 2, 3, 4, 5};
int b[5];
for (int i = 0; i < 5; i++) {
b[i] = a[i]*2;
}
Bosque Language
var a = List[Int]@{1, 2, 3, 4, 5};
var b = a.map[Int](fn(x) => x*2);
None Processing
Handling none values is a relatively common task that can obscure the fundamental intent of a section of code with nests of cases and conditional handling for the special case. To simplify this type of code, Bosque includes various forms of coalescing or short-circuit operators to enable code like:
function foo(val?: {tag: Int, value?: String}): String {
return val?.value ?| "[No Value]";
}
Bulk Algebraic Data Operations
Bulk algebraic operations in Bosque start with support for bulk reads and updates to data values. Consider the common case of having a struct with 3 fields where 2 of them need to be updated. In most languages this would need to be done on a field-by-field basis. However with the bulk data operations it is possible to perform the update as an atomic operation (unlike in an imperative style) and without manually extracting and copying fields (like in a functional style).
var x = {f=1, g=2, h=3};
x->update(f=-1, g=-2); //{f=-1, @g=-2, h=3}
Bosque Statements
Some of the specific statements.
Writing Comments
Bosque provides two types of comments that we can use interchangeably:
- Line comments, declared by the characters // at the beginning of a line
- Comment blocks, which will be framed between the characters /* at the beginning of the block and */ at the end
// This is an inline comment
/* This is
a multiline
comment */
Variable Declaration
Variable declarations in Bosque can be declared as constant in the scope using the “var” declaration form:
var x: Int = 3; //Int variable introduced and initialized
var y = 3; //variable introduced and inferred to be of type Int
Alternatively variables can be declared as updatable in the scope using the “var!” declaration form. In the “var!” form an initializer expression can be used to set the initial value for the variable or it can be omitted to leave the variable uninitialized.
var! x: Int = 3; //mutable variable of type Int introduced
var! x = 3; //mutable variable of inferred type Int introduced
Using Conditionals
Bosque provides if, elif, and else reserved words for writing a conditional block.
Additionally, due to Bosque being a curly-bracket language, we have to use curly brackets instead of a reserved word for closing blocks.
if ( x > 10 ) {
return "error, greater than 10";
}
elif ( x < 0 ) {
return "error, the number must not be negative";
}
else {
return "it's ok, thanks";
}
Understanding Switch
Switch block allows us to execute different instructions according to the value of the variable. The wildcard _ will enable us to establish a flow for the values that do not correspond to any defined cases.
switch(x) {
case 1 => { return "option one"; }
case 2 => { return "option two"; }
case _ => { return "any other option"; }
}
Writing Hello World
namespace NSMain;
entrypoint function main(): String {
return "Hello World!";
}
For more detailed information, you can visit the official Bosque website
and the Github Page

