1 00:00:00,299 --> 00:00:04,140 hello everybody welcome back to the next jam session 2 00:00:04,140 --> 00:00:07,279 for fp1 the long course 3 00:00:07,279 --> 00:00:11,230 an and what we're going to do and this time 4 00:00:11,230 --> 00:00:14,799 is look at functional programming and dart 5 00:00:14,799 --> 00:00:18,000 darts is in your language from Google 6 00:00:18,000 --> 00:00:21,810 an 8 at programming web applications 7 00:00:21,810 --> 00:00:25,350 and and art as great support 8 00:00:25,350 --> 00:00:29,820 for functional programming if you come from Java or from C sharp 9 00:00:29,820 --> 00:00:33,440 you will feel immediately familiar with the dark syntax 10 00:00:33,440 --> 00:00:36,940 and if you'd followed has collectors 11 00:00:36,940 --> 00:00:40,110 you will be able to take all the things you learned there 12 00:00:40,110 --> 00:00:44,280 and immediately apply them to doctor let's open up the other 13 00:00:44,280 --> 00:00:47,700 and and play and around with dart 14 00:00:47,700 --> 00:00:51,270 little bit and see and how we can apply 15 00:00:51,270 --> 00:00:55,969 what we learnt one and interesting aspect of dart 16 00:00:55,969 --> 00:01:00,020 is that dart has optional typing so it's not 17 00:01:00,020 --> 00:01:03,170 an statically typed but you can 18 00:01:03,170 --> 00:01:06,710 good and types and she wanted an 19 00:01:06,710 --> 00:01:10,619 it's not like JavaScript where you know it's completely dynamically typed 20 00:01:10,619 --> 00:01:12,030 there's no way to put 21 00:01:12,030 --> 00:01:16,729 type annotations and I must say and practice 22 00:01:16,729 --> 00:01:23,729 this works out very very well the nice thing about high school 23 00:01:25,110 --> 00:01:29,770 is that the Haskell type inference is very powerful 24 00:01:29,770 --> 00:01:35,140 and to you had never have to ride any docs yourselves in typically 25 00:01:35,140 --> 00:01:38,310 the compiler will be able to infer things for you 26 00:01:38,310 --> 00:01:41,810 but the price you pay for that 27 00:01:41,810 --> 00:01:45,610 is that you have to know there's a couple of things in in Haskell wary eye 28 00:01:45,610 --> 00:01:50,070 type names have to start with Arbor gates in Baltimore you have typed losses 29 00:01:50,070 --> 00:01:54,350 user name in there it's gonna be a use for ever you cannot 30 00:01:54,350 --> 00:01:58,840 have that in a different class and and art 31 00:01:58,840 --> 00:02:02,820 it's a little bit more an yeah 32 00:02:02,820 --> 00:02:06,210 hecker ish and and I i like that so that sack 33 00:02:06,210 --> 00:02:09,429 open up and ellijay I'm using the 34 00:02:09,429 --> 00:02:13,230 dart and ellijay plugin and you can download 35 00:02:13,230 --> 00:02:17,560 a that plug n from the intelligent website you download 36 00:02:17,560 --> 00:02:20,900 the dark SDK from the dark website 37 00:02:20,900 --> 00:02:24,280 and of you go up 38 00:02:24,280 --> 00:02:27,880 like most languages start also 39 00:02:27,880 --> 00:02:32,430 uses a main mad at you receive the men matted we don't have to specify 40 00:02:32,430 --> 00:02:36,090 weather takes any arguments and then here 41 00:02:36,090 --> 00:02:40,880 we just print lol the next line here 42 00:02:40,880 --> 00:02:45,010 shows a love the expression and our two nd 43 00:02:45,010 --> 00:02:49,090 defining a at variable af 44 00:02:49,090 --> 00:02:53,150 an and its value is a long expression love the axe 45 00:02:53,150 --> 00:02:56,940 explosion wrong here you see that this thing has 46 00:02:56,940 --> 00:03:00,239 a I am function type 10 let's 47 00:03:00,239 --> 00:03:04,170 just tried to say after blass at three that see 48 00:03:04,170 --> 00:03:07,470 an welded and us and 49 00:03:07,470 --> 00:03:11,560 now you see I'm and you cannot see that 50 00:03:11,560 --> 00:03:15,890 and are it's it's it's quite small I don't know how to blow up 51 00:03:15,890 --> 00:03:19,350 the Taipans but I will read it for you 52 00:03:19,350 --> 00:03:22,730 and it says there is no such 53 00:03:22,730 --> 00:03:26,630 operator loss in function so even though 54 00:03:26,630 --> 00:03:29,940 I didn't good day to die 55 00:03:29,940 --> 00:03:33,310 on the half the compiler has inferred 56 00:03:33,310 --> 00:03:36,850 that after has type function and that there's no 57 00:03:36,850 --> 00:03:40,239 addition operator for function but yeah 58 00:03:40,239 --> 00:03:43,680 it will just let me continue 59 00:03:43,680 --> 00:03:47,720 and yeah if I want to do this it will let me do 60 00:03:47,720 --> 00:03:51,110 because the typing is optional okay but ya 61 00:03:51,110 --> 00:03:55,489 I'm not going to do this year but that's a beautiful thing showed it 62 00:03:55,489 --> 00:04:00,160 the type infrastructure dives but nothing is forced to you that the 63 00:04:00,160 --> 00:04:03,030 compiler will never slap you on your wrist and say 64 00:04:03,030 --> 00:04:09,410 Eric you cannot execute this program Sheree ever function and we can call it 65 00:04:09,410 --> 00:04:12,570 three now let's define an 66 00:04:12,570 --> 00:04:16,109 another local function that's another 67 00:04:16,109 --> 00:04:19,269 nice thing of dart and we show that in 68 00:04:19,269 --> 00:04:22,530 and other languages like skyline got line as well is that 69 00:04:22,530 --> 00:04:26,710 inside a function you can define a local functions are here 70 00:04:26,710 --> 00:04:30,289 inside main I'm defining local function 71 00:04:30,289 --> 00:04:37,240 G and this G can refer to dish out or variable at and show it closes over at 72 00:04:37,240 --> 00:04:39,319 and what she does is it calls 73 00:04:39,319 --> 00:04:43,340 have a fax and then multiply it by two and then here I print 74 00:04:43,340 --> 00:04:46,759 gr4 now let's look at 75 00:04:46,759 --> 00:04:50,210 a.m. a real higher I read a function 76 00:04:50,210 --> 00:04:53,210 a.m. our good friend twice 77 00:04:53,210 --> 00:04:57,319 so twice an takes two parameters 78 00:04:57,319 --> 00:05:00,340 af an axe and I call af 79 00:05:00,340 --> 00:05:04,279 of affects so easy it is looks just 80 00:05:04,279 --> 00:05:07,490 like an the along the expression 81 00:05:07,490 --> 00:05:10,960 and has call am and I 82 00:05:10,960 --> 00:05:14,659 if I wanted you know we could and also 83 00:05:14,659 --> 00:05:18,599 define it like this really good defined far too wise 84 00:05:18,599 --> 00:05:22,099 equals am and now 85 00:05:22,099 --> 00:05:25,719 ya it looks like the Lund expression a form 86 00:05:25,719 --> 00:05:29,719 and has gone and every do it like this and 87 00:05:29,719 --> 00:05:33,529 it looks like the function definition 88 00:05:33,529 --> 00:05:37,199 national except that there's an arrow here if you don't like the arrow 89 00:05:37,199 --> 00:05:40,479 you can an usually we 90 00:05:40,479 --> 00:05:44,440 we already did here am we can with the body 91 00:05:44,440 --> 00:05:48,089 up that correctly 92 00:05:48,089 --> 00:05:51,599 we take the body and we say return 93 00:05:51,599 --> 00:05:54,830 of the expression and then in the air and 94 00:05:54,830 --> 00:05:59,319 we can do other interesting thing so for example we can do 95 00:05:59,319 --> 00:06:06,319 brand an that we're executing at so it its 96 00:06:06,759 --> 00:06:09,909 we can mix and match an 97 00:06:09,909 --> 00:06:13,310 impaired if God wit higher-order functions 98 00:06:13,310 --> 00:06:16,750 good thats 99 00:06:16,750 --> 00:06:20,180 a run our program and see if everything 100 00:06:20,180 --> 00:06:23,819 and works as advertised so 101 00:06:23,819 --> 00:06:27,339 and let's go from the top to the bottom thats 102 00:06:27,339 --> 00:06:29,450 for surrender broke 103 00:06:29,450 --> 00:06:33,090 and then check while yes really quick 104 00:06:33,090 --> 00:06:36,280 an that the dart 105 00:06:36,280 --> 00:06:39,960 the and is really fast and the implementation 106 00:06:39,960 --> 00:06:43,350 ellijay is extremely responsive so here 107 00:06:43,350 --> 00:06:48,300 shaper intel also on the output we expect hello 108 00:06:48,300 --> 00:06:52,140 then we define their French in every print af of three 109 00:06:52,140 --> 00:06:55,420 that should return for as expected 110 00:06:55,420 --> 00:06:58,650 then there's geoVax hear that and 111 00:06:58,650 --> 00:07:01,990 doubles and have a fax so 112 00:07:01,990 --> 00:07:05,260 that should be. every goal that with for 113 00:07:05,260 --> 00:07:08,590 GO FOR and goals asked 114 00:07:08,590 --> 00:07:11,620 that's five that should be done their ego 115 00:07:11,620 --> 00:07:15,890 and now here we see that we're inside and twice reprint 116 00:07:15,890 --> 00:07:18,940 dot dot dot and then and twice 117 00:07:18,940 --> 00:07:22,910 of and incrementing three twice gives us 118 00:07:22,910 --> 00:07:26,000 5 so that's a 119 00:07:26,000 --> 00:07:30,840 all as expected and am there's a lot of things and art 120 00:07:30,840 --> 00:07:34,860 a that I'm didn't show 121 00:07:34,860 --> 00:07:39,350 one of the things is that dart has classes 122 00:07:39,350 --> 00:07:44,240 an and the nice thing is starts doesn't have a separate notion of interfaces 123 00:07:44,240 --> 00:07:47,700 its unified abstract art show there's a less 124 00:07:47,700 --> 00:07:52,150 a syntactic baggage in languages like Java our C sharp there's 125 00:07:52,150 --> 00:07:55,190 abstract base classes interfaces whatever 126 00:07:55,190 --> 00:07:59,250 and art an that is 127 00:07:59,250 --> 00:08:02,560 simplified and let's go here 128 00:08:02,560 --> 00:08:05,750 at the other beautiful thing of darts 129 00:08:05,750 --> 00:08:08,800 every and go here and the 130 00:08:08,800 --> 00:08:15,800 an 131 00:08:23,270 --> 00:08:26,990 here area if we go today 132 00:08:26,990 --> 00:08:31,470 and dark language specification the dart language specification 133 00:08:31,470 --> 00:08:36,960 is written by again not Braga a and the same person dead roads the Java language 134 00:08:36,960 --> 00:08:38,300 specification 135 00:08:38,300 --> 00:08:42,640 an and it's a very very terrible a description of dart 136 00:08:42,640 --> 00:08:46,930 and explains everything and the beauty of dark here 137 00:08:46,930 --> 00:08:51,180 is that dark now an supports an 138 00:08:51,180 --> 00:08:54,770 new features a sink and and the wait 139 00:08:54,770 --> 00:08:57,830 that we are and familiar red from C sharp 140 00:08:57,830 --> 00:09:01,600 an it also supports an 141 00:09:01,600 --> 00:09:04,770 so-called six star Matt its rich are 142 00:09:04,770 --> 00:09:07,980 and iterators that we know from sharpened by Tong 143 00:09:07,980 --> 00:09:11,440 an and other languages 144 00:09:11,440 --> 00:09:15,160 such as PHP also support iterators an 145 00:09:15,160 --> 00:09:20,380 but it real nice thing here is dead dart also has support for streams for a 146 00:09:20,380 --> 00:09:22,000 synchronous data streams 147 00:09:22,000 --> 00:09:25,870 an which is kind of a combination of a single wat 148 00:09:25,870 --> 00:09:29,980 and the sink had iterator style 149 00:09:29,980 --> 00:09:34,260 programming and with these three features I think dart 150 00:09:34,260 --> 00:09:37,740 is ahead of the game 151 00:09:37,740 --> 00:09:40,980 with respect to other and programming languages 152 00:09:40,980 --> 00:09:44,660 an because it has full support for both 153 00:09:44,660 --> 00:09:48,800 a synchronous Matt its methods that return synchronous collections 154 00:09:48,800 --> 00:09:52,150 and that it's that return a sickness collection show I 155 00:09:52,150 --> 00:09:55,850 I invite you to gonna go take a look a dart 156 00:09:55,850 --> 00:09:59,310 there's also a darts to JavaScript compiler so 157 00:09:59,310 --> 00:10:02,570 you can print art in the regular bras are you don't need 158 00:10:02,570 --> 00:10:06,960 the dark the an and and if you want to write about 159 00:10:06,960 --> 00:10:11,390 applications you come from a job on or C sharp background 160 00:10:11,390 --> 00:10:14,850 I think darts is it fantastic choice 161 00:10:14,850 --> 00:10:18,290 and thank you so much and CEO next time