reading-notes

Functional Programming

Functional Programming Concepts

What is functional programming?

Functional programming is a programming paradigm — a style of building the structure and elements of computer programs — that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. Programs are constructed by composing functions and applying them to data.

What is a pure function and how do we know if something is a pure function?

A pure function is a function that, given the same input, will always produce the same output and has no side effects. They are highly desirable in functional programming because they are easier to reason about, test, and parallelize.

What are the benefits of a pure function?

The benefits of pure functions include improved code quality, maintainability, testability, and the ability to leverage parallelism and caching techniques. By adhering to the principles of functional programming and maximizing the use of pure functions, developers can create a reliable software system.

What is immutability?

This is the property of an object or data structure that cannot be modified after it is created. Immutable objects or data structures cannot be changed in-place and instead, any operation that appears to modify them actually creates a new object or structure with the desired changes.

What is Referential transparency?

A function is referentially transparent if it consistently produces the same output for the same input and has no side effects.

Node JS Tutorial for Beginners #6 - Modules and require()

What is a module?

A self-contained unit of code that encapsulates related functionality. It is a way to organize and structure code by grouping together functions, classes, variables, and other elements that work together to achieve a specific purpose.

What does the word ‘require’ do?

In JavaScript, particularly in the Node.js environment, the ‘require’ keyword is used to import modules or files that contain reusable code.

How do we bring another module into the file the we are working in?

Use the ‘import’ keyword to bring in functionality from other modules.

What do we have to do to make a module available?

To make a module available for use in other parts of a program, you need to define the module by creating a separate file, export the desired elements, and import the module in the file where you want to use the module.

Things I want to know more about