Learn Bosque Programming - Sebastian Kaczmarek - E-Book

Learn Bosque Programming E-Book

Sebastian Kaczmarek

0,0
31,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

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.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 407

Veröffentlichungsjahr: 2021

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Learn Bosque Programming

Boost your productivity and software reliability with Microsoft’s new open-source programming language

Sebastian Kaczmarek

Joel Ibaceta

BIRMINGHAM—MUMBAI

Learn Bosque Programming

Copyright © 2021 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Group Product Manager: Aaron Lazar

Publishing Product Manager: Shweta Bairoliya

Senior Editor: Rohit Singh

Content Development Editor: Kinnari Chohan

Technical Editor: Pradeep Sahu

Copy Editor: Safis Editing

Project Coordinator: Francy Puthiry

Proofreader: Safis Editing

Indexer: Vinayak Purushotham

Production Designer: Joshua Misquitta

First published: April 2021

Production reference: 1280421

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham

B3 2PB, UK.

ISBN 978-1-83921-197-3

www.packt.com

To my fiancée, Agata, for her support and indulgence during the writing of this book – thank you for giving me as much time as I wanted!

– Sebastian Kaczmarek

To my parents, who have supported me since the first day that I discovered the computers in my life.

– Joel Ibaceta

Contributors

About the authors

Sebastian Kaczmarek is an experienced programmer who specializes in web solutions. He holds an engineer's degree in information technology and is a certified Linux administrator. In the projects he has been a part of, he has worked with many technologies such as JavaScript, Node.js, MongoDB, PHP, MySQL, Java, Hadoop, HBase, and Angular.

Sebastian is passionate about JavaScript and Node.js and loves to share his knowledge on Stack Overflow, where he has reached over 177,000 people with his helpful posts.

Currently, he's working as a backend lead at a Polish software company where he is responsible for architecture design and the development of reliable solutions. In his free time, he likes reading books about astronomy and artificial intelligence.

I want to thank the people who have been close to me and supported me, especially my fiancée, Agata, my parents, and my siblings.

Joel Ibaceta is an experienced software engineer who started writing code at an early age. Currently, he has more than 12 years of experience in the technology industry, building software and leading engineering teams throughout South America. He served as the technical leader of MercadoLibre, a Latin American unicorn, NASDAQ-100 company, and he currently works as co-founder and CTO of Kwema Inc., a US-based start-up that develops wearables for employees' safety.

He is a well-known speaker in LatAm technical communities and a hackathon enthusiast who has won some global prizes such as the Facebook Community Challenge.

I want to thank all the people who have made this book possible and my parents, who have supported me in my career development.

About the reviewers

Federico Kereki is a Uruguayan systems engineer with an MSc in education, with 30+ years of experience as a consultant, system developer, university professor, and writer. He is a subject matter expert at Globant, where he gets to use a good mixture of development frameworks, programming tools, and operating systems.

He has taught at Universidad de la República, Universidad ORT Uruguay, and Universidad de la Empresa. He has written many articles for magazines and websites, and he's written three books on programming, and is currently at work on a new one on data structures and algorithms.

He has given many talks on programming-related topics, and his interests are in software quality and software engineering – with agile methodologies being his focus.

Harris Brakmic is a software engineer from Troisdorf, Germany. He mainly works with Angular, TypeScript, C#, and the Azure cloud, and sometimes develops apps for Android and iOS. Ranging from Java to C#, he has developed software in most major programming languages.

He mainly works as a full-stack developer, that is, everything from the backend (C# and the Azure cloud) to the frontend written in JavaScript or TypeScript and based on React, Angular, or Reactive.js. He is interested in working with Bosque and Idris 2.

Table of Contents

Preface

Section 1: Introduction

Chapter 1: Exploring Bosque

Identifying the need for another language

Learning what Intermediate Representation is

Discovering regularized programming

Understanding accidental complexity

Immutability12

Loop-free14

Indeterminate behaviors15

Data invariant violations16

Aliasing16

How the experiment is going so far

What next?18

Bosque applications

Cloud-first development18

Automatic verification19

Synthesis programming19

Summary

Questions

Further reading

Chapter 2: Configuring the Bosque Environment

Technical requirements

Prerequisites for Bosque

64-bit operating system22

The LTS version of Node.js and NPM24

TypeScript26

Installing a C++ compiler

Windows28

Linux28

MacOS29

Installing Bosque

Setting up the IDE for Bosque

Windows32

Linux and MacOS32

Writing a "Hello, World!" program

Understanding the code35

ExeGen – Ahead-of-time Bosque compilation

Parameters for ExeGen37

Summary

Questions

Further reading

Chapter 3: Bosque Key Features

Technical requirements

Identifying immutable values

The let keyword45

The var keyword46

The ref keyword48

Introducing typed strings

SafeString49

StringOf50

Discovering bulk algebraic data operations

Bulk read53

Bulk update55

Projection57

Merge58

Learning iterative processing in Bosque

Identifying recursive functions in Bosque

Validating program behavior using the built-in mechanism

Summary

Questions

Further reading

Section 2: The Bosque Language Overview

Chapter 4: Entrypoint Function

Technical requirements

Why do we need an entrypoint function?

Writing our first entrypoint function

Passing arguments and returning values

Summary

Questions

Further reading

Chapter 5: Types and Operators

Technical requirements

Bosque type system

Nominal type system79

Structural type system81

Core types

Int82

Bool83

String 84

Float6485

Typed strings

SafeString<T>86

StringOf<T>88

Operators

Unary operators90

Binary operators90

Logic operators91

Order comparison operators92

Equality comparison operators92

Select operators94

Summary

Questions

Further reading

Chapter 6: Bosque Statements

Technical requirements

Writing comments

Understanding variables

Using constants

Using conditionals

Understanding switch

Understanding return and yield

Understanding blocks

Writing validations

Summary

Questions

Further reading

Chapter 7: Project: Bosque in the Cloud

Technical requirements

Defining requirements

Implementing the solution

Getting the RSSI values detected by the receiver for the three known access points114

Calculating the distance in meters using each of the measured RSSI values116

Calculating our x, y coordinates using the 2D trilateration method117

Building an API to expose our program as a web service121

Running our program in the cloud

Compiling the Bosque program125

Running the Express server125

Making an HTTP request to our exposed API125

Summary

Further reading

Section 3: Practicing Bosque

Chapter 8: Expressions in Bosque

Technical requirements

Understanding parameters handling in Bosque

Recognizing named parameters133

Using rest and spread operators135

Key-value argument notation138

Learning about scoped access and invocations

Understanding variable scoped access139

Learning about scoped invocations141

Chaining in Bosque

Introducing PCode types and constructors

Recognizing PCode types149

Discovering PCode constructors149

Identifying access operators

The tuple typed access operator151

The record typed access operator152

The nominal typed access operator154

Summary

Questions

Chapter 9: Collections

Technical requirements

Learning about List and ListOf

Reviewing standard List methods159

Discovering Bosque additions to List163

Introducing ListOf166

Getting familiar with Map and DynamicMap

Reviewing standard Map methods169

Discovering Bosque additions to Map171

Introducing DynamicMap174

Understanding Set and DynamicSet

Reviewing standard Set methods176

Discovering Bosque additions to Set177

Introducing DynamicSet180

Discovering Stack and Queue

Reviewing Stack methods181

Reviewing Queue methods181

Summary

Questions

Further reading

Chapter 10: Iterative Processing and Recursion

Technical requirements

Learning about structured loops

Practicing iterative processing without structured loops

Multiplying vectors188

Grouping list elements by key191

Discovering the NSIterate namespace and its helper functions

The reduce<T>() function198

The steps<S>() function200

The until<S>() and while<S>() functions203

Recursion and the recursive keyword

Summary

Questions

Further reading

Chapter 11: Project: AI Classifier

Technical requirements

Defining project requirements

Understanding the approach

Brief introduction to neural networks212

Designing a model214

Implementing the intelligent model

Creating the basic functionality217

Writing the training algorithm218

Wrapping the classification feature224

Defining two entrypoint functions227

Testing the program

Improving the code

Enhancing ideas and suggestions

Summary

Questions

Further reading

Section 4: Exploring Advanced Features

Chapter 12: Namespaces, Concepts, and Entities

Technical requirements

Using namespaces to organize code

Understanding concepts and entities

Concepts247

Entities248

Exploring fields and methods

Using inheritance

Using static methods

Understanding parametric polymorphism

Summary

Questions

Chapter 13: Testing in Bosque

Technical requirements

Discovering symbolic execution

Introducing SymTest – the Bosque symbolic testing tool

Creating an alias for the SymTest command260

Command line parameters and flags267

Practicing symbolic testing

Working with sanity checks in Bosque

Summary

Questions

Further reading

Chapter 14: Project: Path Optimizer

Technical requirements

Defining requirements

Implementation of the program

Storing our problem data in an orderly structure280

Implementing Dijkstra's algorithm to get the optimal route282

Processing our data using the written algorithm and returning a human-readable format286

Demo and running our program

Summary

Questions

Further reading

Appendix A: Advanced Topics

Technical requirements

Discovering the Bosque source code and the project structure

Understanding the design of a programming language290

Looking at the Bosque source code291

Summarizing the Bosque structure294

Learning how to report bugs and feature requests

Learning how to contribute

Summary

Questions

Further reading

Appendix B: What's Next in Bosque?

Exploring the Bosque language roadmap

What we should expect in the next versions

Summary

Why subscribe?

Other Books You May Enjoy

Section 1: Introduction

In this part, we introduce the Bosque project. After reading this section, you will understand its key concepts and how to start experimenting with it.

This section comprises the following chapters:

Chapter 1, Exploring BosqueChapter 2, Configuring the Bosque EnvironmentChapter 3, Bosque Key Features