hello everybody welcome back to the next jam session
for fp1 the long course
an and what we're going to do and this time
is look at functional programming and dart
darts is in your language from Google
an 8 at programming web applications
and and art as great support
for functional programming if you come from Java or from C sharp
you will feel immediately familiar with the dark syntax
and if you'd followed has collectors
you will be able to take all the things you learned there
and immediately apply them to doctor let's open up the other
and and play and around with dart
little bit and see and how we can apply
what we learnt one and interesting aspect of dart
is that dart has optional typing so it's not
an statically typed but you can
good and types and she wanted an
it's not like JavaScript where you know it's completely dynamically typed
there's no way to put
type annotations and I must say and practice
this works out very very well the nice thing about high school
is that the Haskell type inference is very powerful
and to you had never have to ride any docs yourselves in typically
the compiler will be able to infer things for you
but the price you pay for that
is that you have to know there's a couple of things in in Haskell wary eye
type names have to start with Arbor gates in Baltimore you have typed losses
user name in there it's gonna be a use for ever you cannot
have that in a different class and and art
it's a little bit more an yeah
hecker ish and and I i like that so that sack
open up and ellijay I'm using the
dart and ellijay plugin and you can download
a that plug n from the intelligent website you download
the dark SDK from the dark website
and of you go up
like most languages start also
uses a main mad at you receive the men matted we don't have to specify
weather takes any arguments and then here
we just print lol the next line here
shows a love the expression and our two nd
defining a at variable af
an and its value is a long expression love the axe
explosion wrong here you see that this thing has
a I am function type 10 let's
just tried to say after blass at three that see
an welded and us and
now you see I'm and you cannot see that
and are it's it's it's quite small I don't know how to blow up
the Taipans but I will read it for you
and it says there is no such
operator loss in function so even though
I didn't good day to die
on the half the compiler has inferred
that after has type function and that there's no
addition operator for function but yeah
it will just let me continue
and yeah if I want to do this it will let me do
because the typing is optional okay but ya
I'm not going to do this year but that's a beautiful thing showed it
the type infrastructure dives but nothing is forced to you that the
compiler will never slap you on your wrist and say
Eric you cannot execute this program Sheree ever function and we can call it
three now let's define an
another local function that's another
nice thing of dart and we show that in
and other languages like skyline got line as well is that
inside a function you can define a local functions are here
inside main I'm defining local function
G and this G can refer to dish out or variable at and show it closes over at
and what she does is it calls
have a fax and then multiply it by two and then here I print
gr4 now let's look at
a.m. a real higher I read a function
a.m. our good friend twice
so twice an takes two parameters
af an axe and I call af
of affects so easy it is looks just
like an the along the expression
and has call am and I
if I wanted you know we could and also
define it like this really good defined far too wise
equals am and now
ya it looks like the Lund expression a form
and has gone and every do it like this and
it looks like the function definition
national except that there's an arrow here if you don't like the arrow
you can an usually we
we already did here am we can with the body
up that correctly
we take the body and we say return
of the expression and then in the air and
we can do other interesting thing so for example we can do
brand an that we're executing at so it its
we can mix and match an
impaired if God wit higher-order functions
good thats
a run our program and see if everything
and works as advertised so
and let's go from the top to the bottom thats
for surrender broke
and then check while yes really quick
an that the dart
the and is really fast and the implementation
ellijay is extremely responsive so here
shaper intel also on the output we expect hello
then we define their French in every print af of three
that should return for as expected
then there's geoVax hear that and
doubles and have a fax so
that should be. every goal that with for
GO FOR and goals asked
that's five that should be done their ego
and now here we see that we're inside and twice reprint
dot dot dot and then and twice
of and incrementing three twice gives us
5 so that's a
all as expected and am there's a lot of things and art
a that I'm didn't show
one of the things is that dart has classes
an and the nice thing is starts doesn't have a separate notion of interfaces
its unified abstract art show there's a less
a syntactic baggage in languages like Java our C sharp there's
abstract base classes interfaces whatever
and art an that is
simplified and let's go here
at the other beautiful thing of darts
every and go here and the
an
here area if we go today
and dark language specification the dart language specification
is written by again not Braga a and the same person dead roads the Java language
specification
an and it's a very very terrible a description of dart
and explains everything and the beauty of dark here
is that dark now an supports an
new features a sink and and the wait
that we are and familiar red from C sharp
an it also supports an
so-called six star Matt its rich are
and iterators that we know from sharpened by Tong
an and other languages
such as PHP also support iterators an
but it real nice thing here is dead dart also has support for streams for a
synchronous data streams
an which is kind of a combination of a single wat
and the sink had iterator style
programming and with these three features I think dart
is ahead of the game
with respect to other and programming languages
an because it has full support for both
a synchronous Matt its methods that return synchronous collections
and that it's that return a sickness collection show I
I invite you to gonna go take a look a dart
there's also a darts to JavaScript compiler so
you can print art in the regular bras are you don't need
the dark the an and and if you want to write about
applications you come from a job on or C sharp background
I think darts is it fantastic choice
and thank you so much and CEO next time