Book Image

Learn Bosque Programming

By : Sebastian Kaczmarek, Joel Ibaceta
Book Image

Learn Bosque Programming

By: Sebastian Kaczmarek, Joel Ibaceta

Overview of this book

Bosque is a new high-level programming language inspired by the impact of structured programming in the 1970s. It adopts the TypeScript syntax and ML semantics and is designed for writing code that is easy to reason about for humans and machines. With this book, you'll understand how Bosque supports high productivity and cloud-first development by removing sources of accidental complexity and introducing novel features. This short book covers all the language features that you need to know to work with Bosque programming. You'll learn about basic data types, variables, functions, operators, statements, and expressions in Bosque and become familiar with advanced features such as typed strings, bulk algebraic data operations, namespace declarations, and concept and entity declarations. This Bosque book provides a complete language reference for learning to program with Bosque and understanding the regularized programming paradigm. You'll also explore real-world examples that will help you to reinforce the knowledge you've acquired. Additionally, you'll discover more advanced topics such as the Bosque project structure and contributing to the project. By the end of this book, you'll have learned how to configure the Bosque environment and build better and reliable software with this exciting new open-source language.
Table of Contents (22 chapters)
1
Section 1: Introduction
5
Section 2: The Bosque Language Overview
10
Section 3: Practicing Bosque
15
Section 4: Exploring Advanced Features

What this book covers

Chapter 1, Exploring Bosque, provides some basic information about what the Bosque project is all about. Here, we will go through some of the theory and motivations behind this project. We will also learn the basics of code intermediate representations. We will learn what they are, why we need them, and what the Bosque approach is. Then, we will review the problem of accidental complexity and present the concept of regularized programming. Eventually, we will mention where Bosque can possibly be applied.

Chapter 2, Configuring the Bosque Environment, explains how to configure a development environment to start learning Bosque and become familiar with some of the tools for compiling scripts and testing our code. First, we will mention all the prerequisites and how they can be fulfilled. Next, we will go through the process of installing Bosque. Eventually, we will write our first Bosque "Hello, world" program.

Chapter 3, Bosque Key Features, provides a brief introduction to the most important features of the Bosque language. There are many features that Bosque offers, but we will focus just on the most interesting and innovative ones here. A detailed description of the remainder of the language syntax, operations, and semantics can be found in the chapters that follow.

Chapter 4, Entrypoint Function, explains the purpose of an entrypoint function in a Bosque script. We will also guide you in the process of writing your first function and later expand your knowledge by teaching you how to pass and receive arguments.

Chapter 5, Types and Operators, takes a tour of the Bosque type system, the primitive values, and the nominal and structural types. We will also review the operations we can apply to them. You will cover a number of useful examples designed to strengthen the knowledge acquired.

Chapter 6, Statements and Syntax, covers Bosque's set of statements and explains the various syntax elements. We will cover practical usage examples and comparisons with other languages. You will learn the language syntax and see how Bosque simplifies various use cases compared to other popular languages.

Chapter 7, Project: Bosque in the Cloud, shows how you can use the features learned and deploy your program in the cloud. We will demonstrate how to create an API using Bosque. Following this chapter, you will be able to create applications in Bosque and deploy them in the cloud.

Chapter 8, Expressions in Bosque, reviews a set of expressions in Bosque, starting with the most frequent expressions in other languages as arguments or scoped access until we reach the most specific Bosque expressions as typed projection or PCode constructors.

Chapter 9, Collections, covers the core collections that Bosque provides. We will go through concepts such as lists, maps, and sets and their useful methods. We will also cover the lesser-known concepts available in Bosque that are undocumented. Finally, we will also mention collections that are currently not fully implemented, such as DynamicMaps, DynamicSets, Stacks, and Queues.

Chapter 10, Iterative Processing and Recursion, explains what iterative processing and recursion looks like in Bosque. First, we will explain why there are no loops available and how we can solve various problems related to iteration without them. Next, we will take a closer look at recursion and restrictions that Bosque sets to simplify recursive calls in our programs. Also, we will cover the NSIterate namespace and its implemented methods.

Chapter 11, Project: AI Classifier, utilizes the features that we have learned so far, allowing you to build a simple AI project. The idea is to create a basic classifier that predicts an output based on two input values. In this example, we will try to train our intelligent model so that it will be able to guess which quadrant of the Cartesian coordinate system a point belongs to. Following this chapter, you will know how Bosque can be applied to simple AI solutions.

Chapter 12, Namespaces, Concepts, and Entities, reviews the definitions of the structural types of Bosque, with a focus on concepts and entities. We will also explore how Bosque implements some concepts known in object-oriented languages, such as inheritance, polymorphism, and static methods, and finally review the concept of namespaces to identify our code scripts.

Chapter 13, Testing in Bosque, covers the concept of symbolic testing to improve the quality of the code we write and prevent bugs without increasing the associated complexity. At the end, we will review some applied testing cases to have a better idea regarding asserts and good practices.

Chapter 14, Project: Path Optimizer, explains how to build an application that finds the shortest path between two points. We will make use of the features we have learned about so far and see how they can be applied to such a project. We will utilize common algorithms in order to perform this task. After reading this chapter, you will know how to apply Bosque in applications that use advanced algorithms.

Appendix A, Advanced Topics, shows what the project structure looks like, describes its internals, and how you can contribute to the Bosque project. Since the project is still under heavy development and lacks implementations, and also contains bugs and feature requests, everyone is welcome to improve the language by means of their own contributions.

Appendix B, What's Next in Bosque, reviews some useful features that are currently in the pipeline but have not yet been implemented, because this is still a language in development and an alpha version.