Upload
andy-petrella
View
165
Download
1
Embed Size (px)
DESCRIPTION
Given by Xavier Tordoir and my self for the students of University of Liège. This slide is a poor export of this one: http://slides.com/xa_ndy/fp-and-entrepreneurship
Citation preview
THEIMPROBABLESTORYOF:
FPANDENTREPRENEURSHIP
WHOAREWE?
XAVIERTORDOIR
ANDYPETRELLA
Findyourways
Picksomeanddig
Mémoire:polishingphase
STUDYING=:=FUTURE[OPTION[JOB]]
Grabthebasis
JOB=:=(WORK=>OPTION[EXPERIENCE])=>OPTION[MONEY]
Workingwillprobablyraiseyourexperience
Basedonthisexperience,youmightgetsomemoney
Experiencemightnotbeenough
Itwilldependonthekindofexperience
IT'SNOTTHATEASYProposal:
Job=:=((Work,Explore,Learn)=>Option[Expertize])=>Option[(Money,()=>Future[Option[Job]])]
Stillsomework*sight* Butneverstoplearning,norexploring
Expertizeislikeexperience,yetrarer
Money,theunfortunateobligation
Createyoursecretsauce,alazycalltoJob
WORKINGINIT
Everythingisdistributed
Cluesforanswersareindata
Answerquestions
MOREANDMOREDATA
Industrialdata
energygridproductionlinesfinancetransport...
MOREANDMOREDATA
Peopledata
web1.0:fewcontrolcontentweb2.0:lotsofend-usersmanualfeedwebx.y:lotsofcaptorsperuser
MOREANDMOREDATA
Whydowecollectdata?
Wealwaysmisssomeatsomepointsomethingofvalueisencodedcollaborativeconsiousness
MOBILE?REALLY?
Providingcontent=aggregatedistributedsources
BUTinsmallquantity(networkisthebottleneck)
Yesdataisavailablefromanywhere
ITISACOMMODITY
...evendevelopment
Everythingdoneisdistributed
Software(SaaS):usermanagement,social
loginproductsupportonlinebilling/paymentaccesstodatasources
Infrastructure(IaaS):storage,servers...
ATECHSTARTUP
Managingdistributedresourcesiskey!
GathersdistributeddatasourcesCallsdistributedservicescollectsrawdatadoessomeaggregationMustbeabletoscaleresourcesandcosts
FP?
Failuremanagement
Asynchronouscalls
FPdescribetheresultyouwant,nothowyougetit
Threads,cores,servers,datacenters
IfFPgetsaglobaladoptionitwillbebecauseitsolvesissuesrelatedtothedistributedenvironment.
Complexityofdistribution
FPINTHEINDUSTRY?ExamplesofpopularlanguageswithOOand
FPjavascriptrubyJava8scala
AWAIT[_]
EVAL[EXPRESSION]SCALA
valgetQueryParameter[T]=(request:Request)=>(name:String)=>request.query.parameters.get(name).as[T]
abstractclassRequest[T](valbody:Body[T])extendsQuerywithHeader{defparser:BodyParser[T]
valcontent:Option[T]=parser(body)
defsend(to:Service)=???}
caseclassHttpRequest[T](method:Method,body:Body)(implicitparser:BodyParser[T])extendsRequest(body){//...}
PLAY!FRAMEWORK2
AsyncHTTP
Eventdriven/ConcurrencyusingActor
Non-blockingIO(reactive:Iteratee/CPS)
Stateless
objectDummyextendsController{//returnasync'lythe#ofusersw/namestart'gw/q"char"defcountAs=Action.async{request=>valchar=request.queryString("char")valall:Future[Seq[User]]=users.all//orWS.urlOk(all.map(_.count(_.namestartsWith"a")))}
}
AKKA
Messagepassingstyle
Messagesareimmutable
Actorsaremutable(stateful) Threadsafetyby
confinement
Locationtransparency
classUserRepoextendsActor{varusers=Set.empty
defreceive={caseAdd(user:User)=>users=users+usercaseAll=>sender!userscaseGet(id:String)=>user=users.find(_.id==id)sender!user}}
objectAkkaAppextendsApp{//...
valrepo=system.actorOf(Props[UserRepo])
//addrepo!Add(User(1L,"")
//getvaluser=repo?Get(1L)}
SPARK
TendstoresolveBigDatasolutionflawsProvidesanabstractionondistributeddata
Usinganextendedfunctionalstyle(notonlyMR)Representsadistributedcomputationasa
GraphIn-Memory!
valsc=newSparkContext(/*...*/)lines=sc.textFile("hdfs://...")errors=lines.filter(_.startsWith("ERROR"))errors.filter(_.contains("HDFS")).map(_.split('\t')(3)).collect()