1 00:00:00,690 --> 00:00:03,705 In order to answer, why is functional programming so 2 00:00:03,705 --> 00:00:06,320 hot right now, let's take a quick jog through history. 3 00:00:07,780 --> 00:00:10,680 Let's start our journey way back in the 1930s and 4 00:00:10,680 --> 00:00:13,880 take a look at some work that was going on that would lay the ground work 5 00:00:13,880 --> 00:00:17,185 to help define programming as we know it today. 6 00:00:17,185 --> 00:00:21,000 An investigation into the foundation of mathematics was going on. 7 00:00:21,000 --> 00:00:25,980 This study led to the creation of a formal system named lambda calculus. 8 00:00:25,980 --> 00:00:29,710 Here's where the functions I was talking about come into play pretty heavily. 9 00:00:29,710 --> 00:00:30,360 You've probably seen them. 10 00:00:30,360 --> 00:00:32,600 They're written like this, that swervy f. 11 00:00:33,610 --> 00:00:38,020 This study made for some formal rules that were manually tested for decades. 12 00:00:38,020 --> 00:00:43,110 And eventually it was decided to attempt to prove them using a computer. 13 00:00:43,110 --> 00:00:44,760 Now we're talking about the 50s. 14 00:00:44,760 --> 00:00:48,530 If you'll remember, this is a time when computers were ginormous, and 15 00:00:48,530 --> 00:00:53,190 the amount of memory and processing power available was minuscule. 16 00:00:53,190 --> 00:00:54,980 The technology just wasn't there. 17 00:00:54,980 --> 00:00:57,621 Several languages spawned from these early days. 18 00:00:57,621 --> 00:01:01,876 And these languages were not only used for mathematical proofing, but also for 19 00:01:01,876 --> 00:01:05,100 early attempts at artificial intelligence. 20 00:01:05,100 --> 00:01:10,610 These proven mathematical rules made it possible to express very complex ideas. 21 00:01:10,610 --> 00:01:14,810 However, the rules were not always easy to implement in an efficient way. 22 00:01:15,830 --> 00:01:18,570 Especially with the limited resources available. 23 00:01:18,570 --> 00:01:21,350 Let's take a peek at one of these rules that we'll cover in great 24 00:01:21,350 --> 00:01:23,070 detail throughout the course. 25 00:01:23,070 --> 00:01:27,390 One of the main tenants of functional programming is that a function is pure. 26 00:01:27,390 --> 00:01:31,260 That means that a function when called with the same arguments must 27 00:01:31,260 --> 00:01:34,650 always return the same result, no matter what. 28 00:01:34,650 --> 00:01:38,670 Enforcing the pure function rule arguably made things difficult to 29 00:01:38,670 --> 00:01:40,630 make efficient with the computers at that time. 30 00:01:41,750 --> 00:01:46,230 So, to deal with the efficiency challenge, a programming paradigm 31 00:01:46,230 --> 00:01:50,740 based on how to efficiently communicate with the computer at a low level respond. 32 00:01:51,770 --> 00:01:54,480 This style of programming is called Imperative. 33 00:01:54,480 --> 00:01:58,990 It focuses specifically on the how to perform the operations. 34 00:01:58,990 --> 00:02:01,890 Efficiency is controlled by storing State, 35 00:02:01,890 --> 00:02:04,400 it deals with conditional branching and looping. 36 00:02:04,400 --> 00:02:06,500 The order of execution matters. 37 00:02:06,500 --> 00:02:08,930 Over time, sub processes for 38 00:02:08,930 --> 00:02:13,620 grouping statements together began to appear to make things more readable. 39 00:02:13,620 --> 00:02:16,940 These are the starts of what we will eventually know as methods. 40 00:02:16,940 --> 00:02:20,330 And they are not pure, since state is stored and manipulated. 41 00:02:21,378 --> 00:02:26,478 In the 80s and onward we saw a huge growth in imperative programming, 42 00:02:26,478 --> 00:02:30,993 object oriented programming was born and very much embraced. 43 00:02:30,993 --> 00:02:35,760 OOP allows us to make our code more understandable through encapsulation. 44 00:02:35,760 --> 00:02:38,810 It minimizes the moving parts of the application. 45 00:02:38,810 --> 00:02:42,390 As programming languages evolved, so did our hardware. 46 00:02:42,390 --> 00:02:45,490 And you can now buy a USB key chain that 47 00:02:45,490 --> 00:02:50,340 has more space then the most expensive machinery in the early days. 48 00:02:50,340 --> 00:02:54,310 And not only do we have more memory, we have more computers. 49 00:02:54,310 --> 00:02:59,890 The cloud has given us seemingly boundless access to the computer power that we need. 50 00:02:59,890 --> 00:03:03,340 Our problems are more complex and our data is bigger and 51 00:03:03,340 --> 00:03:06,990 more readily available and critical to our applications. 52 00:03:06,990 --> 00:03:10,430 As we've shifted focus on dealing with these larger problems, 53 00:03:10,430 --> 00:03:15,660 we've discovered that if we share the work across our many computers on the cloud, 54 00:03:15,660 --> 00:03:21,230 or even across multiple processors cores, that we can take on just about any task. 55 00:03:21,230 --> 00:03:25,950 The problem, though, now, almost ironically, is state. 56 00:03:25,950 --> 00:03:27,560 Whomp whomp. 57 00:03:27,560 --> 00:03:32,390 Once a program requires state to make it work correctly, the synchronization 58 00:03:32,390 --> 00:03:36,100 amongst running programs is quite difficult to do efficiently, 59 00:03:36,100 --> 00:03:37,800 if not impossible. 60 00:03:37,800 --> 00:03:40,817 So things are starting to come full circle. 61 00:03:40,817 --> 00:03:45,721 [SOUND] Functional programming is rearing its head because it can be easily ran in 62 00:03:45,721 --> 00:03:48,866 our new environment as the functions are pure, and 63 00:03:48,866 --> 00:03:53,425 you can split your program across many environments almost seamlessly. 64 00:03:53,425 --> 00:03:58,028 All imperative languages that I can think of have started to have more functional 65 00:03:58,028 --> 00:04:00,882 capabilities and Java [SOUND] has joined the game. 66 00:04:00,882 --> 00:04:05,026 The simple explanation, and the one that you'll hear is that functional programming 67 00:04:05,026 --> 00:04:09,340 deals with functions, and object oriented programming deals objects. 68 00:04:09,340 --> 00:04:11,030 Java is now a hybrid. 69 00:04:12,290 --> 00:04:15,425 So now that Java has the ability to perform many 70 00:04:15,425 --> 00:04:18,795 functional programming concepts, it is really catching on. 71 00:04:18,795 --> 00:04:20,925 It's slick, and I think you're gonna love it. 72 00:04:20,925 --> 00:04:23,855 It's important to learn because technology is heading that way. 73 00:04:23,855 --> 00:04:27,385 And more and more functional code is starting to show up on the scene. 74 00:04:28,530 --> 00:04:33,160 Functional programming is starting beat the fact away to solve large problems. 75 00:04:33,160 --> 00:04:36,720 Its acceptance is growing at a rapid pace in all languages. 76 00:04:36,720 --> 00:04:40,580 Which brings me to the great news, the concepts that you learn here will 77 00:04:40,580 --> 00:04:44,330 definitely translate to other languages that provide functional equivalence. 78 00:04:46,110 --> 00:04:49,740 That reminds me, I am going to add pure here to the parking lot. 79 00:04:51,050 --> 00:04:53,470 We'll explore that concept more here in a bit. 80 00:04:53,470 --> 00:04:55,010 Are you ready to get started? 81 00:04:55,010 --> 00:04:55,510 I know I am.