Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Hands-On Functional Programming with TypeScript
  • Toc
  • feedback
Hands-On Functional Programming with TypeScript

Hands-On Functional Programming with TypeScript

By : Jansen
2 (2)
close
Hands-On Functional Programming with TypeScript

Hands-On Functional Programming with TypeScript

2 (2)
By: Jansen

Overview of this book

Functional programming is a powerful programming paradigm that can help you to write better code. However, learning functional programming can be complicated, and the existing literature is often too complex for beginners. This book is an approachable introduction to functional programming and reactive programming with TypeScript for readers without previous experience in functional programming with JavaScript, TypeScript , or any other programming language. The book will help you understand the pros, cons, and core principles of functional programming in TypeScript. It will explain higher order functions, referential transparency, functional composition, and monads with the help of effective code examples. Using TypeScript as a functional programming language, you’ll also be able to brush up on your knowledge of applying functional programming techniques, including currying, laziness, and immutability, to real-world scenarios. By the end of this book, you will be confident when it comes to using core functional and reactive programming techniques to help you build effective applications with TypeScript.
Table of Contents (14 chapters)
close
5
The Runtime – Closures and Prototypes

Preface

Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. The origins of the functional programming paradigm can be traced back to the 1930s when Alonzo Church introduced Lambda calculus. Lambda calculus presents a theoretical framework for describing functions and their evaluation, and is a mathematical abstraction rather than a programming language. However, Lambda calculus is the foundation of most functional programming languages.

In the late 1950s, Lisp, one of the first functional programming languages, was developed by John McCarthy. Lisp introduced many functional programming paradigm features, and it was the primary influence of other popular functional programming languages, such as Scheme and Clojure.

In 1973, Robin Milner created ML at the University of Edinburgh. ML eventually developed into several alternative languages, the most common of which are now OCaml and Standard ML. In 1977, John Backus defined functional programs in a way that allows an "algebra of programs" and follows the principle of compositionality. In 1985, Research Software Limited released Miranda, and the interest in lazy functional programming languages grew. After a couple of years, more than a dozen non-strict, purely functional programming languages existed. In 1987, at the conference on functional programming languages and computer architecture in Portland, Oregon, there was a strong consensus that a committee should be formed to define an open standard for such languages; Haskell was born.

The 1970s and 1980s were years of significant advancement for functional programming. However, during the 1990s and 2000s, functional programming lost market share against object-oriented programming languages, such as Java and C#.

In the 2010s, the adoption of JavaScript grew exponentially, and it became the most popular programming language. The Scheme programming language is one of the main influences of JavaScript and, as a result, JavaScript implements many functional programming features, such as support for higher-order functions. JavaScript became the first contact with functional programming for many young developers. However, because JavaScript is a multi-paradigm programming language, many ignored its functional programming capabilities. However, in recent times, thanks to the arrival of technologies highly influenced by functional programmings principles, such as React, RxJS, and Redux, there has been a significant increase in interest in functional programming within the JavaScript community.

As the popularity of JavaScript grew, the complexity of JavaScript applications also grew exponentially. Web user interfaces became much more sophisticated, and JavaScript started to be used in a number of alternative scenarios, such as backend applications. The TypeScript programming language was then introduced as a tool that allows us to manage the new levels of complexity.

TypeScript aims to reduce the complexity of a system by adding a static type system to JavaScript. Static type systems can be used to detect errors at compilation time as a beneficial form of in-code documentation. Static type systems can be very beneficial in functional programming. Most object-oriented programming languages, such as Java and C#, are slowly adopting functional programming features, and sophisticated static type systems are something that is many times associated with purely functional programming languages, such as Haskell.

This book is not going to encourage you to stop using object-oriented programming. Instead, we are going to try to think about both the functional programming and the object-oriented programming paradigms as two different solutions to the same problem: managing complexity:

"Object-oriented programming makes code understandable by encapsulating moving parts. Functional programming makes code understandable by minimizing moving parts."

Michael Feathers

The popularity of distributed systems is increasing as the adoption of cloud computing continues to grow and, as a result, functional programming is expected to rise in popularity over the next decade because it is particularly well suited for concurrent systems and distributed systems. Functional programming encourages the implementation of stateless components, which can be scaled with ease. Since the complexity of distributed systems is usually high, this is just another example of how functional programming can be used as a weapon against complexity.

Mastering TypeScript together with the principles and techniques of both object-oriented programming and functional programming can provide us with a richer toolset to fight against complexity in our systems. This book will provide you with knowledge about a wide range of functional programming principles, patterns, and techniques that should help you to become a more versatile software engineer and prepare you for dealing with the increasing complexity in modern web applications.

bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete