Chapter 2 core concepts of function Programming
This chapter introduces
■ Understand concepts and basics
■ Immutable data programming
■ Inference of functional code
■ Functional values and Data Types
If you ask three function programmers what are the most basic aspects of the function paradigm, there may be three different answers. The reason is that function programming has been around for a long time, and different programming languages are widely used. Each Language emphasizes different priorities, but it may not be important for other languages; however, most of these concepts are represented in all functional languages.
The central part of this chapter focuses on these common concepts and explores the basic features and technologies of functional programmer toolsets. We will study these concepts at a macro level and you will see how to combine them to form a continuous solution to the problem.
We prefer to discuss how functional programs represent and change program states. In object-oriented programming, States are carried by objects, while in function programming, functions and data types play this key role. Next, we will see the language features that support Declarative Programming, which we have introduced in chapter 1; finally, we will discuss types to see how types help verify Program correctness. Not all function languages support this, but it is the core of many languages (including ocaml, F #, and Haskell ). This type of check is very advanced and differs in many aspects from those used in C.
We will not program too much, just to get a general idea of some major concepts, as well as a better feeling about function programs. Additional materials: "What is next in this Chapter ?" This chapter provides an overview of the structure of this chapter. We have discussed some concepts in the first chapter, but only focus on the conclusions. In this chapter, we will analyze its principles.
What is next in this chapter?
Chapter 1 focuses on two concepts: immutable and clear style. Here we will introduce some language functions that make them possible. We will also discuss the types, this is another basic concept in this book.
In section 2.1, we will first talk about the topic of function programming and discuss its mathematical background. Reading this section is not necessary, but it may make sense because it illustrates the source of many concepts. Later, we will go back to more specific function programming and discuss immutable data structures, and how to write programs (section 2.2.3). In section 2.3.2, Let's first look at the basic functions of declarative code written in function languages, such as high-order functions ); we will also see how the type prevents many common programming errors in F # (section 2.4.4 ).
This chapter focuses on the concept of function programming. First, we will explore its theoretical basis, ignore all the details, and use a simple example to explain the core concepts.