Tài liệu Functional Programming for Java Developers pptx

88 578 1
Tài liệu Functional Programming for Java Developers pptx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... today than before While Agile Software Development has greatly improved our quality and our ability to respond to change, we need to rethink ways to keep our code “minimally sufficient” for the requirements today, yet flexible for change Functional programming helps us do just that Functional Programming Is a Return to Simplicity Finally, building on the previous points, I see functional programming. .. 1 Why Functional Programming? A few years ago, when many developers started talking about functional programming (FP) as the best way to approach concurrency, I decided it was time to learn more and judge for myself I expected to learn some new ideas, but I assumed I would still use object-oriented programming (OOP) as my primary approach to software development I was wrong As I learned about functional. .. enthusiasm for the art and science of software development I hope this short introduction will show you why my thinking changed Maybe your thinking will change, too Let’s begin! † I don’t mean that functional programming is simple Becoming an expert in functional programming requires mastery of many advanced, yet powerful concepts Functional Programming Is a Return to Simplicity | 5 CHAPTER 2 What Is Functional. .. the literature on functional programming reflects its mathematical roots, which can be overwhelming if you don’t have a strong math background In contrast, objectoriented programming seems more intuitive and approachable Fortunately, you can learn and use the principles of functional programming without a thorough grounding in mathematics 7 The first language to incorporate functional programming ideas... JVM but are being ported to the NET environment Today, many other languages are incorporating ideas from functional programming The Basic Principles of Functional Programming Don’t all programming languages have functions? If so, why aren’t all programming languages considered functional languages? Functional languages share a few basic principles Avoiding Mutable State The first principle is the use... types for anonymous functions: 12 | Chapter 2: What Is Functional Programming? package functions; public interface Function2 { R apply(A1 a1, A2 a2); } Unfortunately, you would need a separate interface for every function “arity” you want (arity is the number of arguments) Actually, it’s that number times two; one for the void return case and one for the non-void return case However, the effort... 1950s and is the second-oldest high-level programming language, after Fortran The ML family of programming languages started in the 1970s, including Caml, OCaml (a hybrid object -functional language), and Microsoft’s F# Perhaps the best known functional language that comes closest to functional “purity” is Haskell, which was started in the early 1990s Other recent functional languages include Clojure and... Functional Programming Is a Return to Simplicity | 5 CHAPTER 2 What Is Functional Programming? Functional programming, in its “purest” sense, is rooted in how functions, variables, and values actually work in mathematics, which is different from how they typically work in most programming languages Functional programming got its start before digital computers even existed Many of the theoretical underpinnings... about functional programming, I found good ideas for implementing concurrency, as I expected, but I also found that it brought new clarity to my thinking about the design of types* and functions It also allowed me to write more concise code Functional programming made me rethink where module boundaries should go and how to make those modules better for reuse I found that the functional programming community... good type design First, all functional languages emphasize the use of core container types, like lists, maps, trees, and sets for capturing and transforming data, which we’ll explore in Chapter 3 Here, I want to discuss two other benefits of functional thinking about types, enforcing valid values for variables and applying rigor to type design What About Nulls? In a pure functional language where values .

Ngày đăng: 17/02/2014, 11:20

Từ khóa liên quan

Mục lục

  • Copyright

  • Table of Contents

  • Preface

    • Welcome to Functional Programming for Java Developers

    • Conventions Used in This Book

    • Using the Code Examples

      • Getting the Code Examples

      • Safari® Books Online

      • How to Contact Us

      • Acknowledgments

      • Chapter 1. Why Functional Programming?

        • I Have to Be Good at Writing Concurrent Programs

        • Most Programs Are Just Data Management Problems

        • Functional Programming Is More Modular

        • I Have to Work Faster and Faster

        • Functional Programming Is a Return to Simplicity

        • Chapter 2. What Is Functional Programming?

          • The Basic Principles of Functional Programming

            • Avoiding Mutable State

            • Functions as First-Class Values

            • Lambdas and Closures

            • Higher-Order Functions

            • Side-Effect-Free Functions

            • Recursion

            • Lazy vs. Eager Evaluation

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan