funscript: why bother?

34
FunScript F# to JavaScript with type providers What is FunScript?

Upload: alfonso-garcia-caro

Post on 01-Dec-2014

772 views

Category:

Technology


1 download

DESCRIPTION

FunScript is an F# to JavaScript compiler but, why bother with yet another *** to JS compiler? Give me five minutes and I'll try to convince you.

TRANSCRIPT

Page 1: FunScript: Why bother?

FunScript F# to JavaScript with type providers

What is FunScript?

Page 2: FunScript: Why bother?

FunScript F# to JavaScript with type providers

FunScript is...

yet another JavaScript compiler

So why bother?

Page 3: FunScript: Why bother?

FunScript F# to JavaScript with type providers

It seems as if every programming languagein the world compiles now to JavaScript And many of them are functional

o Elmo LiveScripto PureScripto Fay

So, why bother with FunScript?Reason #1...

Page 4: FunScript: Why bother?

FunScript F# to JavaScript with type providers

THERE’S A F#erWITHIN YOU

AND YOU KNOW IT

Page 5: FunScript: Why bother?

FunScript F# to JavaScript with type providers

F# is a mature, open source, cross-platform,functional-first programming language. F# runs on Linux, Mac OS X, Android, iOS,Windows as well as HTML 5 and GPUs. But enough of sales pitch!

Free as in beer!

And we all know when sth wants to conquerthe whole world is always a good thing

but also multi-paradigm

Page 6: FunScript: Why bother?

FunScript F# to JavaScript with type providers

SHOW ME DA GOODIES

Page 7: FunScript: Why bother?

FunScript F# to JavaScript with type providers

Write F# client-side code in powerful IDEswith autocomplete and tooltips

Intellisense is addictive!

No plugin required!

Page 8: FunScript: Why bother?

FunScript F# to JavaScript with type providers

F# compiler is your best friendIt helps you write better code by pointing out your mistakes

If it were a human I would kill it ...but it’s not!

Page 9: FunScript: Why bother?

FunScript F# to JavaScript with type providers

Usual functional stuff• First-class and higher-order functions• Immutability• Recursion• Pattern matching• Type inference

Type safety

without the h

assle

Page 10: FunScript: Why bother?

FunScript F# to JavaScript with type providers

Functional data structures• Tuples• Records• Discriminated Unions (Option built-in)• Classes and Modules• Functional collectionso Recursive listso Mapo Seto seq

Never type

IEnumerable

again!

Page 11: FunScript: Why bother?

FunScript F# to JavaScript with type providers

.NET mutable collections• Array• ResizeArray (mutable List)• Dictionary

They’ll compile as JS arrays and POJ

Os,

so they’re compatible with browser code

Page 12: FunScript: Why bother?

FunScript F# to JavaScript with type providers

FunScript is compatible with many methodsof most used .NET classes • Regular Expressions• DateTime / TimeSpan• String Formatting• WebRequest

Am I the only one with trouble

to remember how to use Regex

and Dates in each platform?

Page 13: FunScript: Why bother?

FunScript F# to JavaScript with type providers

.NET Regular Expressions usage example

Page 14: FunScript: Why bother?

FunScript F# to JavaScript with type providers

F# unique featureso Type providers!o Units of measureo Computation expressions

Click here fora wonderful talk

Page 15: FunScript: Why bother?

FunScript F# to JavaScript with type providers

And with FunScript.HTML extensionsyou can create HTML 5 web apps

using your F#/.NET skills

Like...

Page 16: FunScript: Why bother?

FunScript F# to JavaScript with type providers

Functional Reactive Programming (1)

Every element hasan equivalent extensionproperty to generatean IObservable

Page 17: FunScript: Why bother?

FunScript F# to JavaScript with type providers

Functional Reactive Programming (2)

Internal state

Page 18: FunScript: Why bother?

FunScript F# to JavaScript with type providers

Functional Reactive Programming (and 3)

String formatting

DateTime

These extension methodscan easily be implementedfor other platforms

Page 19: FunScript: Why bother?

FunScript F# to JavaScript with type providers

Asynchronous workflows (1)Share types with LINQ to SQL, Web API and client code

LINQ, Web API and

FunScript do the tedious

marshaling work for you

Page 20: FunScript: Why bother?

FunScript F# to JavaScript with type providers

Asynchronous workflows (2)

Asynchronous workflows are also very goodto handle events as you can use them

to represent a state-machine

Forget about “Inversion of Control”Take the program flow control back!

Page 21: FunScript: Why bother?

FunScript F# to JavaScript with type providers

Asynchronous workflows (and 3)

No flags needed!

Page 22: FunScript: Why bother?

FunScript F# to JavaScript with type providers

Some people

still likeJS eventhandlingthough

Page 23: FunScript: Why bother?

FunScript F# to JavaScript with type providers

So FunScript and FunScript.HTMLextensions allow you to:

o Minimize errorso Reuse code

o Reuse your skillsAnd most importantly...

Page 24: FunScript: Why bother?

FunScript F# to JavaScript with type providers

There are wonderful JS libraries out thereDo I have to renounce to use them?

This is great. But...

Nope!FunScript offers wrappers for all definitionsin the TypeScript repository through NuGet

Page 25: FunScript: Why bother?

FunScript F# to JavaScript with type providers

Page 26: FunScript: Why bother?

FunScript F# to JavaScript with type providers

FunScript.HTML also offers deeperintegration with a great JavaScript

MVC framework:

Ractive.jsCheck its wonderful websiteto know more

Page 27: FunScript: Why bother?

FunScript F# to JavaScript with type providers

Encapsulate stateAsync f

or events

and state upd

ates

Page 28: FunScript: Why bother?

FunScript F# to JavaScript with type providers

If necessary, you can extend FunScriptyourself easily

Page 29: FunScript: Why bother?

FunScript F# to JavaScript with type providers

To be fair, there is also another F#to JavaScript compiler out there:

WebSharper, a fantastic projectby IntelliFactory

Unlike FunScript, WebSharper is afull-fledged web framework

A more detailed comparison follows.

Page 30: FunScript: Why bother?

FunScript F# to JavaScript with type providers

Oh, c’mon!

FUNSCRIPTFEATURES

Everythingyou just saw

WEBSHARPERFEATURES

Sorry, I haven’tused it. Pleasevisit their site

and judge yourself

Page 31: FunScript: Why bother?

FunScript F# to JavaScript with type providers

This is coming to an end

SAYONARABABY

That’s what he said in the Spanish version

Page 32: FunScript: Why bother?

FunScript F# to JavaScript with type providers

FunScript has been created by Zach Brayand several bright minds from theF# community have contributed to it

▪Tomas Petricek▪Robert Pickering▪James Freiwirth

...more at funscript.info

Doesn’t it sou

nd

like a Marvel

Hero name?

Page 33: FunScript: Why bother?

FunScript F# to JavaScript with type providers

And this presentation has beenassembled by yours truly,

Alfonso García-Caro

@alfonsogcnunezgithub.com/alfonsogarciacaro

So now...

I’m also acollaboratornow, but I’mmore of afreeloader

Page 34: FunScript: Why bother?

FunScript F# to JavaScript with type providers

WHAT THEHELL ARE YOUWAITING FOR