SlideShare una empresa de Scribd logo
1 de 31
Whistle-­‐stop	
  tour	
  of	
  the	
  Li#	
  web	
  framework	
  and	
  
                           demonstra:ng	
  why	
  the	
  real-­‐:me	
  web	
  	
  
                                         should	
  ma=er	
  to	
  you	
  
www.devoxx.com	
  
Agenda	
  
                     !    Overview	
  of	
  Scala	
  
                     !     Li#’s	
  Ra:onale	
  
                     !      The	
  real-­‐:me	
  web	
  
                     !       Li#’s	
  awesome	
  feature	
  set	
  
                     !        Why	
  Scala	
  makes	
  Li#	
  possible	
  
www.devoxx.com	
  
About	
  Me	
  
                     !  Project	
  commi=er	
  on	
  Li#	
  
                     !  Manufacturing	
  and	
  marke:ng	
  automa:on	
  is	
  
                       my	
  day-­‐job	
  (industrial	
  systems)	
  
                     !  Whole	
  raH	
  of	
  experience	
  with	
  both	
  dynamic	
  
                       and	
  sta:c	
  languages	
  
                     !  Desktop	
  and	
  Web	
  applica:on	
  development	
  
www.devoxx.com	
  




                     !  Coding	
  Scala	
  and	
  LiH	
  since	
  end	
  of	
  2007	
  
What	
  is	
  Scala?	
  (10,000	
  foot	
  view!)	
  
                     !    Scala	
  is	
  func:onal	
  
                     !     Scala	
  is	
  object	
  orientated	
  
                     !      Scala	
  is	
  mul:-­‐paradigm!	
  OO	
  and	
  FP	
  hybrid...	
  
                     !       Designed	
  by	
  Mar:n	
  Odersky	
  (Java	
  generics)	
  
                     !        Runs	
  as	
  fast	
  as	
  na:ve	
  Java	
  code	
  
                     !         Fully	
  interoperable	
  with	
  exis:ng	
  Java	
  libraries	
  
www.devoxx.com	
  




                     !          More	
  type-­‐safe	
  than	
  Java	
  
Scala	
  in	
  the	
  wild?	
  
www.devoxx.com	
  
Scala	
  in	
  breif….	
  
                     !  What	
  follows	
  is	
  an	
  overview	
  of	
  core	
  Scala	
  
                       language	
  features	
  
www.devoxx.com	
  
Immutability	
  
                     val example = “Devoxx”	

                     !  Immutable	
  values	
  are	
  assigned	
  with	
  the	
  	
  
                       “val”	
  keyword	
  
                     !  Immutability	
  is	
  your	
  long-­‐lost	
  friend:	
  
                         !  	
  No	
  need	
  to	
  synchronise	
  
                         !  	
  Never	
  need	
  to	
  copy	
  vars	
  “just	
  in	
  case”	
  
                         !  	
  Great	
  for	
  hash	
  keys	
  
www.devoxx.com	
  




                     !  Be=er	
  for	
  garbage	
  collector	
  
Case	
  Classes	
  
                     case class Foo(bar: String, baz: List[Int])	

                     !  Func:onality	
  you	
  get	
  for	
  free:	
  
                         !    	
  “new”	
  keyword	
  is	
  redundant	
  
                         !     	
  bar	
  and	
  baz	
  proper:es	
  (immutable	
  by	
  default)	
  
                         !      	
  toString,	
  hashCode,	
  and	
  equals	
  et	
  al	
  
                         !       	
  Pa=ern	
  matching	
  with	
  parameter	
  extrac:on	
  
www.devoxx.com	
  
Singletons	
  
                     object ChatServer extends Actor	

                     !  ChatServer	
  is	
  a	
  singleton	
  
                     !  One	
  instance	
  per	
  classloader	
  
                     !  Can	
  be	
  passed	
  as	
  parameter…	
  it’s	
  an	
  instance	
  
www.devoxx.com	
  
Composi:on	
  with	
  Traits	
  
                     !  Finely-­‐grained	
  aggrega:on	
  of	
  func:onality	
  
                     !  Mul:ple-­‐inheritance	
  without	
  diamond	
  problem[1]	
  
                     !  Extensively	
  used	
  in	
  Li#	
  
                         object sally extends Person(“Sally”) 	
                           with Female 	
                           with Runner	

                         def womansRun(who: Female with Runner) 	
www.devoxx.com	
  




                           //=> womansRun(sally)	
                         [1]	
  h=p://en.wikipedia.org/wiki/Diamond_problem	
  
Func:on	
  Passing	
  
                     !  Encapsulates	
  logic	
  concisely	
  
                     !  Wildcard	
  shorthand	
  keeps	
  things	
  simple	
  
                     !  Func:ons	
  are	
  instances	
  that	
  can	
  be	
  passed	
  
                     // make x a function that lower cases input	
                     val x: (String) => String = (str) => str.toLowerCase	
www.devoxx.com	
  




                     // alter the request encoding	
                     LiftRules.early { _.setCharacterEncoding(“UTF-8”) }
Pa=ern	
  Matching	
  
                     !  Match	
  against	
  case	
  classes	
  
                        !  	
  Parameter	
  extrac:on	
  
                        !  	
  Great	
  for	
  message	
  /	
  event	
  handling	
  
                        !  	
  Test	
  against	
  parameters:	
  case Person(name,     35) =>	

                     !  Declara:ve	
  expression	
  of	
  logic	
  
                         case Messages(m) => msgs = m	
www.devoxx.com	
  




                         case s: String if s.length > 0 => msgs ::= s
XML	
  Literals	
  	
  
                     !  XML	
  is	
  first-­‐class	
  
                     !  Ripe	
  for	
  templa:ng	
  abuse!	
  
                     !  Very	
  handy	
  for	
  development	
  but	
  Li#	
  provides	
  
                       strong	
  abstrac:ons	
  for	
  templates	
  
                       val links = (“Link A”, http://…) :: 	
                          	(“Link B”, “http://…”) :: (“Link C”, https://…) :: Nil	
www.devoxx.com	
  




                       val myLinkList = 	
                         <ul>{ links.flatMap({case (name,url) =>	
                          	<li><a href={url}>{name}</a></li>}) }	
                         </ul>
Actors	
  
                     !    Being	
  “real-­‐:me”	
  means	
  events	
  
                     !     Lightweight	
  concurrency	
  model	
  	
  
                     !      With	
  very	
  nice	
  syntax	
  
                     !       Implemented	
  as	
  a	
  library!	
  
                         object DevoxxActor extends Actor { …… }	
                         case class Talk(name: String)	
www.devoxx.com	
  




                         // asyncronusly send the talk message to the actor	
                         DevoxxActor ! Talk(“Lift web framework”)
What	
  is	
  LiH?	
  
                     !    Web	
  framework	
  wri=en	
  in	
  Scala	
  
                     !     3	
  years	
  old,	
  founded	
  by	
  David	
  Pollak	
  
                     !      Leverages	
  the	
  best	
  of	
  Scala	
  language	
  features	
  
                     !       Takes	
  the	
  best	
  ideas	
  from	
  other	
  frameworks	
  
                     !        Makes	
  real-­‐:me	
  web	
  applica:ons	
  accessible	
  
                     !         Massively	
  scalable	
  
www.devoxx.com	
  
Why	
  another	
  framework?	
  
                     !  Developers	
  needn't	
  be	
  plumbers	
  
                     !  Unifies	
  the	
  best	
  of	
  other	
  framework	
  concepts	
  
                         !  	
  Granular	
  sessions	
  and	
  security	
  a	
  la	
  Seaside	
  
                         !  	
  Flash-­‐to-­‐bang	
  produc:vity	
  a	
  la	
  Rails	
  
                         !  	
  Designer	
  friendly	
  templates	
  a	
  la	
  Wicket	
  
                     !  Advanced	
  features	
  like	
  comet	
  work	
  OOTB	
  
www.devoxx.com	
  




                     !  Tough	
  to	
  be	
  truly	
  real-­‐:me	
  with	
  exis:ng	
  tech	
  
Web	
  Beginnings	
  
                     !  Very	
  person	
  -­‐>	
  machine	
  affair	
  
                     !  Primary	
  uses:	
  	
  
                         !  	
  Shopping	
  
                         !  	
  Banking	
  
                         !  	
  CRUD	
  opera:ons	
  
                     !  56k	
  modems	
  (yikes!)	
  
www.devoxx.com	
  
Web	
  2.0	
  
                     !  Behaviour	
  shiH	
  -­‐>	
  more	
  social	
  
                     !  Different	
  usage	
  models:	
  
                         !  	
  Person	
  -­‐>	
  Machine	
  -­‐>	
  Machine	
  (mashups)	
  
                         !  	
  Person	
  -­‐>	
  Person	
  (Facebook,	
  Twi=er)	
  
                         !  	
  Machine	
  -­‐>	
  Machine	
  -­‐>	
  Person	
  (micro-­‐formats)	
  
                     !  Internet	
  becomes	
  society	
  cornerstone	
  	
  
www.devoxx.com	
  
Real	
  Time	
  Web	
  
                     !    Users	
  demand	
  instant	
  gra:fica:on	
  
                     !     Peer-­‐to-­‐peer	
  news	
  /	
  informa:on	
  streams	
  
                     !      Business	
  informa:on	
  in	
  constant	
  flux	
  
                     !       Online	
  interac:ve	
  games	
  
                     !        Real	
  Time	
  Web	
  is	
  the	
  next	
  evolu2onary	
  step...	
  
www.devoxx.com	
  
View	
  First	
  
                     !  Its	
  not	
  MVC	
  
                     !  Your	
  typical	
  page	
  has	
  more	
  than	
  a	
  single	
  piece	
  
                       of	
  dynamic	
  content	
  
                     !  Code	
  in	
  the	
  view	
  usually	
  means	
  some	
  “seep”	
  
                       of	
  business	
  logic:	
  thus,	
  NO	
  code	
  in	
  the	
  view	
  
                     !  Only	
  well-­‐formed	
  XHTML;	
  no	
  string	
  
                       replacement	
  –	
  e.g.	
  {{myvar}}	
  
www.devoxx.com	
  




                     !  Designer	
  friendly	
  dynamic	
  content	
  markup	
  
Snippets	
  
                     !  A	
  “snippet”	
  in	
  Li#	
  represents	
  a	
  collec:on	
  of	
  
                       applica:on	
  logic	
  
                     !  One	
  snippet	
  can	
  be	
  called	
  on	
  n	
  number	
  of	
  
                       pages,	
  n	
  number	
  of	
  :mes	
  
                     !  A	
  snippet	
  is	
  a	
  normal	
  Scala	
  class	
  or	
  object:	
  
                       there	
  is	
  no	
  black	
  magic	
  
www.devoxx.com	
  




                     !  Lookup	
  via	
  reflec:on	
  or	
  manual	
  wiring	
  
What	
  a	
  bind…	
  
                     class Example {	
                        def nameForm(xhtml: NodeSeq) = {	
                           var name = “”	
                           def doSubmit { println(“Submitted…”); }	
                           bind("f", xhtml, 	
                              "name" -> SHtml.text(name, name = _),	
                              "submit" -> SHtml.submit(doSubmit _)	
                           )	
                        }	
                     }	
                     <lift:example.name_form>	
                       <p><f:name /></p>	
www.devoxx.com	
  




                       <p><f:submit /></p>	
                     </lift:example.name_form>
Security	
  
                     !  Page	
  elements	
  have	
  session	
  specific	
  opaque	
  
                       GUIDs	
  to	
  reference	
  server	
  components	
  
                       (impossible	
  to	
  do	
  CSRF[1])	
  
                       <input name=“F677071620957IFD” type=“text” />	

                     !  Callback	
  func:ons	
  also	
  use	
  similar	
  GUIDs	
  so	
  
                       that	
  sensi:ve	
  IDs	
  etc	
  are	
  not	
  exposed	
  	
  
www.devoxx.com	
  




                       /somepath?F677071620979LIK=_	

                       [1]	
  h=p://en.wikipedia.org/wiki/Cross-­‐site_request_forgery	
  
Site	
  Map	
  
                     !  	
  Declara:ve	
  and	
  granular	
  defini:on	
  of	
  page	
  
                       and	
  UI	
  access	
  rules	
  
                     !  Enforced	
  long	
  before	
  the	
  page	
  content	
  is	
  
                       processed	
  or	
  rendered	
  –	
  its	
  very	
  fast.	
  
                     !  Can	
  generate	
  site	
  menus	
  even	
  with	
  complex	
  
                       rules	
  on	
  what	
  different	
  users	
  see	
  
www.devoxx.com	
  




                     !  Unified	
  access	
  control	
  model	
  
Persistence	
  
                     !  Li#	
  includes	
  “Mapper”	
  which	
  is	
  a	
  lightweight	
  
                       ORM	
  of	
  similar	
  design	
  to	
  Ac:veRecord	
  in	
  Rails	
  
                     !  Use	
  any	
  backend	
  persistence	
  system	
  you	
  
                       want	
  (Hibernate,	
  JPA	
  etc)	
  
                     !  Write	
  custom	
  back-­‐ends	
  using	
  Li#	
  Record	
  –	
  
                       provides	
  OOTB	
  valida:on	
  and	
  CRUD	
  
                       seman:cs;	
  you	
  provide	
  the	
  implementa:on	
  
www.devoxx.com	
  
REST	
  and	
  WebServices	
  
                     !  REST	
  via	
  state(full/less)	
  dispatching	
  
                     !  Declara:ve	
  rules	
  for	
  URI	
  -­‐>	
  handler	
  dispatch	
  
                     !  LiH	
  has	
  awesome	
  support	
  for	
  JSON:	
  
                         !  	
  Slick	
  DSL	
  for	
  construc:on	
  /	
  parsing	
  
                         !  	
  ~300	
  :mes	
  faster	
  than	
  Scala	
  JSON	
  parser	
  
                         !  	
  Faster	
  deseriliza:on	
  than	
  Java	
  
www.devoxx.com	
  




                     !  Na:ve,	
  first-­‐class	
  XML	
  support	
  in	
  Scala	
  
Technology	
  Support	
  
                     !    AMQP	
  
                     !     Tex:le	
  
                     !      XMPP	
  
                     !       OpenID	
  
                     !        JTA	
  
                     !         PayPal	
  
www.devoxx.com	
  




                     !          …and	
  lots	
  more!	
  
Summary	
  
                     !    Scala’s	
  object	
  model	
  is	
  a	
  superset	
  of	
  Java’s	
  
                     !     Scala	
  traits:	
  powerful	
  and	
  granular	
  composi:on	
  
                     !      Scala	
  is	
  syntac:cally	
  simpler	
  than	
  Java	
  or	
  Ruby	
  
                     !       Scala’s	
  design	
  led	
  to	
  Li#’s	
  design	
  
                     !        Li#	
  makes	
  the	
  real-­‐:me	
  web	
  simple	
  
                     !         Li#	
  is	
  the	
  culmina:on	
  of	
  many	
  great	
  ideas	
  
www.devoxx.com	
  
Devoxx 2009: The Lift Framework

Más contenido relacionado

Similar a Devoxx 2009: The Lift Framework

Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with Scala
WO Community
 
AestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaAestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in Scala
Dmitry Buzdin
 
Scala - from "Hello, World" to "Heroku Scale"
Scala - from "Hello, World" to "Heroku Scale"Scala - from "Hello, World" to "Heroku Scale"
Scala - from "Hello, World" to "Heroku Scale"
Salesforce Developers
 

Similar a Devoxx 2009: The Lift Framework (20)

Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with Scala
 
Scala : language of the future
Scala : language of the futureScala : language of the future
Scala : language of the future
 
The design, architecture, and tradeoffs of FluidDB
The design, architecture, and tradeoffs of FluidDBThe design, architecture, and tradeoffs of FluidDB
The design, architecture, and tradeoffs of FluidDB
 
Life Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby AppsLife Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby Apps
 
Post exploitation techniques on OSX and Iphone, EuSecWest 2009
Post exploitation techniques on OSX and Iphone, EuSecWest 2009Post exploitation techniques on OSX and Iphone, EuSecWest 2009
Post exploitation techniques on OSX and Iphone, EuSecWest 2009
 
Martin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMartin Odersky: What's next for Scala
Martin Odersky: What's next for Scala
 
AestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaAestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in Scala
 
DSLs in JavaScript
DSLs in JavaScriptDSLs in JavaScript
DSLs in JavaScript
 
Red Hat Nordics 2020 - Apache Camel 3 the next generation of enterprise integ...
Red Hat Nordics 2020 - Apache Camel 3 the next generation of enterprise integ...Red Hat Nordics 2020 - Apache Camel 3 the next generation of enterprise integ...
Red Hat Nordics 2020 - Apache Camel 3 the next generation of enterprise integ...
 
Devoxx
DevoxxDevoxx
Devoxx
 
No Sql
No SqlNo Sql
No Sql
 
Scala - from "Hello, World" to "Heroku Scale"
Scala - from "Hello, World" to "Heroku Scale"Scala - from "Hello, World" to "Heroku Scale"
Scala - from "Hello, World" to "Heroku Scale"
 
Presentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackPresentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStack
 
Scala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologist
 
FOXX - a Javascript application framework on top of ArangoDB
FOXX - a Javascript application framework on top of ArangoDBFOXX - a Javascript application framework on top of ArangoDB
FOXX - a Javascript application framework on top of ArangoDB
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Rust: Systems Programming for Everyone
Rust: Systems Programming for EveryoneRust: Systems Programming for Everyone
Rust: Systems Programming for Everyone
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
EnScript Workshop
EnScript WorkshopEnScript Workshop
EnScript Workshop
 
Asymmetry of phoenix contexts
Asymmetry of phoenix contextsAsymmetry of phoenix contexts
Asymmetry of phoenix contexts
 

Más de Timothy Perrett

Scalalable Language for a Scalable Web
Scalalable Language for a Scalable WebScalalable Language for a Scalable Web
Scalalable Language for a Scalable Web
Timothy Perrett
 
Javazone 2011: Goal Directed Web Applications
Javazone 2011: Goal Directed Web ApplicationsJavazone 2011: Goal Directed Web Applications
Javazone 2011: Goal Directed Web Applications
Timothy Perrett
 
Concurrency and Parallelism with Scala
Concurrency and Parallelism with ScalaConcurrency and Parallelism with Scala
Concurrency and Parallelism with Scala
Timothy Perrett
 
Scaladays 2011: Task Driven Scala Web Applications
Scaladays 2011: Task Driven Scala Web ApplicationsScaladays 2011: Task Driven Scala Web Applications
Scaladays 2011: Task Driven Scala Web Applications
Timothy Perrett
 

Más de Timothy Perrett (11)

Nelson: Rigorous Deployment for a Functional World
Nelson: Rigorous Deployment for a Functional WorldNelson: Rigorous Deployment for a Functional World
Nelson: Rigorous Deployment for a Functional World
 
Online Experimentation with Immutable Infrastructure
Online Experimentation with Immutable InfrastructureOnline Experimentation with Immutable Infrastructure
Online Experimentation with Immutable Infrastructure
 
Functional Programming at Verizon
Functional Programming at VerizonFunctional Programming at Verizon
Functional Programming at Verizon
 
Scalalable Language for a Scalable Web
Scalalable Language for a Scalable WebScalalable Language for a Scalable Web
Scalalable Language for a Scalable Web
 
BRUG - Hello, Scala
BRUG - Hello, ScalaBRUG - Hello, Scala
BRUG - Hello, Scala
 
Scala Helix
Scala HelixScala Helix
Scala Helix
 
Javazone 2011: Goal Directed Web Applications
Javazone 2011: Goal Directed Web ApplicationsJavazone 2011: Goal Directed Web Applications
Javazone 2011: Goal Directed Web Applications
 
Concurrency and Parallelism with Scala
Concurrency and Parallelism with ScalaConcurrency and Parallelism with Scala
Concurrency and Parallelism with Scala
 
Scaladays 2011: Task Driven Scala Web Applications
Scaladays 2011: Task Driven Scala Web ApplicationsScaladays 2011: Task Driven Scala Web Applications
Scaladays 2011: Task Driven Scala Web Applications
 
Bathcamp 2010-riak
Bathcamp 2010-riakBathcamp 2010-riak
Bathcamp 2010-riak
 
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-publicJavazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 

Devoxx 2009: The Lift Framework

  • 1.
  • 2. Whistle-­‐stop  tour  of  the  Li#  web  framework  and   demonstra:ng  why  the  real-­‐:me  web     should  ma=er  to  you   www.devoxx.com  
  • 3. Agenda   !  Overview  of  Scala   !  Li#’s  Ra:onale   !  The  real-­‐:me  web   !  Li#’s  awesome  feature  set   !  Why  Scala  makes  Li#  possible   www.devoxx.com  
  • 4. About  Me   !  Project  commi=er  on  Li#   !  Manufacturing  and  marke:ng  automa:on  is   my  day-­‐job  (industrial  systems)   !  Whole  raH  of  experience  with  both  dynamic   and  sta:c  languages   !  Desktop  and  Web  applica:on  development   www.devoxx.com   !  Coding  Scala  and  LiH  since  end  of  2007  
  • 5. What  is  Scala?  (10,000  foot  view!)   !  Scala  is  func:onal   !  Scala  is  object  orientated   !  Scala  is  mul:-­‐paradigm!  OO  and  FP  hybrid...   !  Designed  by  Mar:n  Odersky  (Java  generics)   !  Runs  as  fast  as  na:ve  Java  code   !  Fully  interoperable  with  exis:ng  Java  libraries   www.devoxx.com   !  More  type-­‐safe  than  Java  
  • 6. Scala  in  the  wild?   www.devoxx.com  
  • 7. Scala  in  breif….   !  What  follows  is  an  overview  of  core  Scala   language  features   www.devoxx.com  
  • 8. Immutability   val example = “Devoxx” !  Immutable  values  are  assigned  with  the     “val”  keyword   !  Immutability  is  your  long-­‐lost  friend:   !    No  need  to  synchronise   !    Never  need  to  copy  vars  “just  in  case”   !    Great  for  hash  keys   www.devoxx.com   !  Be=er  for  garbage  collector  
  • 9. Case  Classes   case class Foo(bar: String, baz: List[Int]) !  Func:onality  you  get  for  free:   !    “new”  keyword  is  redundant   !    bar  and  baz  proper:es  (immutable  by  default)   !    toString,  hashCode,  and  equals  et  al   !    Pa=ern  matching  with  parameter  extrac:on   www.devoxx.com  
  • 10. Singletons   object ChatServer extends Actor !  ChatServer  is  a  singleton   !  One  instance  per  classloader   !  Can  be  passed  as  parameter…  it’s  an  instance   www.devoxx.com  
  • 11. Composi:on  with  Traits   !  Finely-­‐grained  aggrega:on  of  func:onality   !  Mul:ple-­‐inheritance  without  diamond  problem[1]   !  Extensively  used  in  Li#   object sally extends Person(“Sally”) with Female with Runner def womansRun(who: Female with Runner) www.devoxx.com   //=> womansRun(sally) [1]  h=p://en.wikipedia.org/wiki/Diamond_problem  
  • 12. Func:on  Passing   !  Encapsulates  logic  concisely   !  Wildcard  shorthand  keeps  things  simple   !  Func:ons  are  instances  that  can  be  passed   // make x a function that lower cases input val x: (String) => String = (str) => str.toLowerCase www.devoxx.com   // alter the request encoding LiftRules.early { _.setCharacterEncoding(“UTF-8”) }
  • 13. Pa=ern  Matching   !  Match  against  case  classes   !    Parameter  extrac:on   !    Great  for  message  /  event  handling   !    Test  against  parameters:  case Person(name, 35) => !  Declara:ve  expression  of  logic   case Messages(m) => msgs = m www.devoxx.com   case s: String if s.length > 0 => msgs ::= s
  • 14. XML  Literals     !  XML  is  first-­‐class   !  Ripe  for  templa:ng  abuse!   !  Very  handy  for  development  but  Li#  provides   strong  abstrac:ons  for  templates   val links = (“Link A”, http://…) :: (“Link B”, “http://…”) :: (“Link C”, https://…) :: Nil www.devoxx.com   val myLinkList = <ul>{ links.flatMap({case (name,url) => <li><a href={url}>{name}</a></li>}) } </ul>
  • 15. Actors   !  Being  “real-­‐:me”  means  events   !  Lightweight  concurrency  model     !  With  very  nice  syntax   !  Implemented  as  a  library!   object DevoxxActor extends Actor { …… } case class Talk(name: String) www.devoxx.com   // asyncronusly send the talk message to the actor DevoxxActor ! Talk(“Lift web framework”)
  • 16. What  is  LiH?   !  Web  framework  wri=en  in  Scala   !  3  years  old,  founded  by  David  Pollak   !  Leverages  the  best  of  Scala  language  features   !  Takes  the  best  ideas  from  other  frameworks   !  Makes  real-­‐:me  web  applica:ons  accessible   !  Massively  scalable   www.devoxx.com  
  • 17. Why  another  framework?   !  Developers  needn't  be  plumbers   !  Unifies  the  best  of  other  framework  concepts   !    Granular  sessions  and  security  a  la  Seaside   !    Flash-­‐to-­‐bang  produc:vity  a  la  Rails   !    Designer  friendly  templates  a  la  Wicket   !  Advanced  features  like  comet  work  OOTB   www.devoxx.com   !  Tough  to  be  truly  real-­‐:me  with  exis:ng  tech  
  • 18. Web  Beginnings   !  Very  person  -­‐>  machine  affair   !  Primary  uses:     !    Shopping   !    Banking   !    CRUD  opera:ons   !  56k  modems  (yikes!)   www.devoxx.com  
  • 19. Web  2.0   !  Behaviour  shiH  -­‐>  more  social   !  Different  usage  models:   !    Person  -­‐>  Machine  -­‐>  Machine  (mashups)   !    Person  -­‐>  Person  (Facebook,  Twi=er)   !    Machine  -­‐>  Machine  -­‐>  Person  (micro-­‐formats)   !  Internet  becomes  society  cornerstone     www.devoxx.com  
  • 20. Real  Time  Web   !  Users  demand  instant  gra:fica:on   !  Peer-­‐to-­‐peer  news  /  informa:on  streams   !  Business  informa:on  in  constant  flux   !  Online  interac:ve  games   !  Real  Time  Web  is  the  next  evolu2onary  step...   www.devoxx.com  
  • 21.
  • 22. View  First   !  Its  not  MVC   !  Your  typical  page  has  more  than  a  single  piece   of  dynamic  content   !  Code  in  the  view  usually  means  some  “seep”   of  business  logic:  thus,  NO  code  in  the  view   !  Only  well-­‐formed  XHTML;  no  string   replacement  –  e.g.  {{myvar}}   www.devoxx.com   !  Designer  friendly  dynamic  content  markup  
  • 23. Snippets   !  A  “snippet”  in  Li#  represents  a  collec:on  of   applica:on  logic   !  One  snippet  can  be  called  on  n  number  of   pages,  n  number  of  :mes   !  A  snippet  is  a  normal  Scala  class  or  object:   there  is  no  black  magic   www.devoxx.com   !  Lookup  via  reflec:on  or  manual  wiring  
  • 24. What  a  bind…   class Example { def nameForm(xhtml: NodeSeq) = { var name = “” def doSubmit { println(“Submitted…”); } bind("f", xhtml, "name" -> SHtml.text(name, name = _), "submit" -> SHtml.submit(doSubmit _) ) } } <lift:example.name_form> <p><f:name /></p> www.devoxx.com   <p><f:submit /></p> </lift:example.name_form>
  • 25. Security   !  Page  elements  have  session  specific  opaque   GUIDs  to  reference  server  components   (impossible  to  do  CSRF[1])   <input name=“F677071620957IFD” type=“text” /> !  Callback  func:ons  also  use  similar  GUIDs  so   that  sensi:ve  IDs  etc  are  not  exposed     www.devoxx.com   /somepath?F677071620979LIK=_ [1]  h=p://en.wikipedia.org/wiki/Cross-­‐site_request_forgery  
  • 26. Site  Map   !    Declara:ve  and  granular  defini:on  of  page   and  UI  access  rules   !  Enforced  long  before  the  page  content  is   processed  or  rendered  –  its  very  fast.   !  Can  generate  site  menus  even  with  complex   rules  on  what  different  users  see   www.devoxx.com   !  Unified  access  control  model  
  • 27. Persistence   !  Li#  includes  “Mapper”  which  is  a  lightweight   ORM  of  similar  design  to  Ac:veRecord  in  Rails   !  Use  any  backend  persistence  system  you   want  (Hibernate,  JPA  etc)   !  Write  custom  back-­‐ends  using  Li#  Record  –   provides  OOTB  valida:on  and  CRUD   seman:cs;  you  provide  the  implementa:on   www.devoxx.com  
  • 28. REST  and  WebServices   !  REST  via  state(full/less)  dispatching   !  Declara:ve  rules  for  URI  -­‐>  handler  dispatch   !  LiH  has  awesome  support  for  JSON:   !    Slick  DSL  for  construc:on  /  parsing   !    ~300  :mes  faster  than  Scala  JSON  parser   !    Faster  deseriliza:on  than  Java   www.devoxx.com   !  Na:ve,  first-­‐class  XML  support  in  Scala  
  • 29. Technology  Support   !  AMQP   !  Tex:le   !  XMPP   !  OpenID   !  JTA   !  PayPal   www.devoxx.com   !  …and  lots  more!  
  • 30. Summary   !  Scala’s  object  model  is  a  superset  of  Java’s   !  Scala  traits:  powerful  and  granular  composi:on   !  Scala  is  syntac:cally  simpler  than  Java  or  Ruby   !  Scala’s  design  led  to  Li#’s  design   !  Li#  makes  the  real-­‐:me  web  simple   !  Li#  is  the  culmina:on  of  many  great  ideas   www.devoxx.com