Your SlideShare is downloading. ×
0
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Javazone 2010-lift-framework-public

2,817

Published on

My talk from JavaZone 2010 covering the Lift framework and some of its cutting edge features.

My talk from JavaZone 2010 covering the Lift framework and some of its cutting edge features.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,817
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Getting Real<br />Lift, the web framework for Scala<br />Timothy PerrettJavaZone 2010<br />
  • 2. About Me<br /><ul><li>Committer on Lift core
  • 3. Author of Lift in Action</li></ul>Coding Scala since 2007<br /><ul><li>Background in both dynamic and statically typed languages
  • 4. Manufacturing and marketing automation is my day job</li></ul>http://manning.com/perrett/<br />
  • 5. Agenda<br />Overview of Lift<br />Differentiators and rationale<br />Lift’s architecture<br />Some awesome features<br />A few words from our users<br />
  • 6. What is Lift?<br />Framework for building highly interactiveweb applications<br />4 years old, founded by David Pollak<br />Heavily leverages Scala language features<br />Takes the best ideas from other frameworks<br />Makes real-time web applications accessible<br />
  • 7. Yet another framework?<br />Developers needn&apos;t be plumbers<br />Unifies the best of other framework concepts<br /> Granular sessions and security a la Seaside<br /> Convention over configuration a la Rails<br /> Designer friendly templates a la Wicket<br />Advanced features like comet work OOTB<br />Tough to be truly real-time with existing tech<br />
  • 8. Why Scala for Lift?<br />New breed of JVM language<br />Real-time means events; synergy with Actors<br />Promotes better coding<br />Great libraries<br />Yields more maintainable applications<br />Fewer defects because of immutability &amp; type system<br />Better distribution and parallelism<br />
  • 9. Enterprise Ready<br />
  • 10. Enterprise Ready<br />~75m users at the end of 2009<br />~6m new users month on month<br />50m+ tweets daily<br />Services 3x as much traffic with Scala<br />
  • 11. Enterprise Ready<br />~3m users<br />~150m “check-ins”<br />All “S.LI.M” stack<br />14k LOC rewritten in 90 days<br />Service 3x as much traffic compared to LAMP<br />
  • 12. Key Differentiators<br />Unparalleled out of the box security<br />No single vulnerability from the OWASP Top Ten <br />Unique “view first” architecture<br />The best comet support available today<br />All contributions are “rights assigned”<br />Safe for enterprise<br />Assured open source<br />HTTP provider agnostic<br />
  • 13. View First<br />What’s the matter with my controllers?!<br />
  • 14. Controller dispatched style<br />
  • 15. Controller dispatched style<br />
  • 16. Lift’s “View First” style<br />
  • 17. Lift’s “View First” Model<br />It’s not MVC<br />Your typical page has more than a single piece of dynamic content<br />Code in the view usually means some “seep” of business logic: thus, NO code in the view<br />Designer friendly dynamic content markup<br />Only well-formed XHTML; no string replacement – e.g. {{myvar}}<br />
  • 18. Lift’s “View First” Model<br />
  • 19. Snippets<br />A “snippet” in Lift represents a collection of rendering logic<br />One snippet can be called on nnumber of pages, n number of times<br />A snippet is a normal Scala class or object<br />Its not magic, its just well designed<br />Essentially NodeSeq =&gt; NodeSeq function<br />
  • 20. Snippets<br />class Example {<br />def nameForm(xhtml: NodeSeq) = {<br />varname = “”<br />def doSubmit { println(“Submitted…”) }<br />bind(&quot;f&quot;, xhtml, <br />&quot;name&quot; -&gt; SHtml.text(name, name = _),<br />&quot;submit&quot; -&gt; SHtml.submit(doSubmit _)<br /> )<br /> }<br />}<br />&lt;lift:example.name_form&gt;<br /> &lt;p&gt;&lt;f:name /&gt;&lt;/p&gt;<br /> &lt;p&gt;&lt;f:submit /&gt;&lt;/p&gt;<br />&lt;/lift:example.name_form&gt;<br />
  • 21. Statefulvs Stateless<br />So called “share nothing” architecture is flawed. <br />The state is just pushed elsewhere (RDBMS, Cookie)<br />Twitter “fail whale” part of pop culture because “share nothing” didn’t scale<br />Session affinity IS workable for large scale production applications (e.g. foursquare)<br />
  • 22. Security<br />Developers must to work hard to introduce vulnerabilities in their applications<br />Page elements have session-specific opaque GUIDs to reference server components (impossible to do CSRF)<br />AJAX and Comet functions also use similar GUIDs so that sensitive IDs etc are not exposed<br />Persistence is safe from SQL injection <br />
  • 23. Security<br />“Four stars to @foursquare - 1st site in a while I have taken a good look at that didn&apos;t have a single security issue (that I could find)”<br />RasmusLerdorf, Inventor of PHP<br />
  • 24. AJAX<br />It’s super simple<br />Just define the desired () =&gt; JsCmd callback<br />It’s super secure<br />Randomly maps opaque GUIDs to AJAX urls<br />It abstracts underlying Javascript libraries<br />Currently supports JQuery, YUI and ExtJS<br />Calling JS just becomes a Scala function<br />
  • 25. AJAX<br />// snippet<br />class JavaZone {<br /> def example(xhtml: NodeSeq) = bind(&quot;x&quot;, xhtml, <br />&quot;button&quot; -&gt; SHtml.ajaxButton(Text(&quot;Press me&quot;), <br /> () =&gt; SetHtml(&quot;sampleDiv&quot;, Text(&quot;That&apos;s it&quot;))))<br />}<br />&lt;!-- markup --&gt;<br />&lt;lift:java_zone.example&gt;<br /> &lt;div id=&quot;sampleDiv&quot;&gt;&lt;x:button /&gt;&lt;/div&gt;<br />&lt;/lift:java_zone.example&gt;<br />POST - /ajax_request/F12814029028330FO/<br />
  • 26. Comet<br />SpecilizedLiftActor sub-type: CometActor<br />Its just an actor… thing ! Message(whatever)<br />Receiving messages pushes to the browser<br />No magic beans<br />Utilizes long-polling<br />Soon to be auto-detecting web sockets!<br />Multiple comet actors delta updates over a managed browser connections. <br />
  • 27. Demo<br />No, its not the obligatory chat app!<br />
  • 28. More Awesome Features<br />
  • 29. SiteMap<br />Declarative rules for page access <br />Enforced long before the page content is processed or rendered – it’s very fast.<br />Can generate site menus complete with complex rules based on application state<br />Unified access control model<br />Allows highly componentized functionality <br />
  • 30. Persistence: Mapper<br />ActiveRecord style ORM<br />Good for average size projects<br />Supports most common RDBMS<br />MySQL, PostGRE, MSSQL, Oracle etc<br />OOTB support with other Lift components<br />Generate CRUD interfaces via CRUDify<br />
  • 31. Persistence: Record<br />Completely store agnostic<br />Mongo DB<br />Couch DB<br />Squeryl<br />Keeps the meaning with the bytes<br />Integrates seamlessly with other Lift components such as Wizard<br />Automatic REST <br />
  • 32. Persistence: Record<br />valuser = from(users)(u =&gt; <br />where(u.email === email) select(u))<br />class User extends Record[User] with KeyedRecord[User]{<br /> def meta = User <br />valcountry = new CountryField(this)<br /> // rest of definition <br />}<br />object User extends User with MetaRecord[User]<br />
  • 33. Wizard<br />Single and multi-screen page flows<br />Declarative logic<br />Inclusive of validation<br />Automatic persistence via Mapper or Record <br />Fully customizable throughout<br />Making CRUD screens is only one line of code<br />Fully testable divorced from HTTP<br />
  • 34. Wizard<br />object AskAboutIceCreamextends LiftScreen {<br />valflavor = field(&quot;What&apos;s your favorite Ice cream flavor&quot;,&quot;&quot;, <br /> trim, <br /> valMinLen(2, &quot;Name too short&quot;),<br /> valMaxLen(40, &quot;That&apos;s a long name&quot;))<br />def finish(){<br />S.notice(&quot;I like &quot;+flavor.is+&quot; too!&quot;)<br /> }<br />}<br />
  • 35. REST Services <br />Can be completely stateless<br />Uses a simple DSL<br />…or get close to the metal with full dispatching<br />Lift has awesome support for JSON:<br /> Slick DSL for construction / parsing<br /> ~300 times faster than Scala JSON parser<br /> Faster deserilization than Java<br />Native, first-class XML support in Scala<br />
  • 36. REST Services <br />serve { <br />case &quot;api&quot; :: &quot;sample&quot; :: _ XmlGet _ =&gt; &lt;p&gt;Static&lt;/p&gt; <br />case &quot;api&quot; :: &quot;sample&quot; :: _ JsonGet _ =&gt; JString(&quot;Static&quot;) <br />}<br />http://localhost:8080/api/sample/thing.xml<br />//=&gt; &lt;p&gt;Static&lt;/p&gt;<br />http://localhost:8080/api/sample/sample.json<br />//=&gt; { “Static” }<br />
  • 37. Modules<br />AMQP<br />Textile<br />XMPP<br />OpenID<br />JTA<br />PayPal<br />…and lots more!<br />
  • 38. Thoughts from our users<br />
  • 39. “Lift is the only new framework in the last four years to offer fresh and innovative approaches to web development. It&apos;s not just some incremental improvement over the status quo, it redefines the state of the art.”<br /> Michael Galpin, eBay<br />
  • 40. “Lift is the kind of web framework that enables you as a developer to concentrate on the big picture. Strong, expressive typing and higher-level features like the built-in Comet support allow you to focus on innovating instead of doing the plumbing.”<br /> David LaPalomento, Novell<br />
  • 41. “Foursquare switched over to Scala &amp; Lift last year and we&apos;ve been thrilled with the results. The ease of developing complex interactive AJAX web pages enabled a very rapid port from our previous platform”<br /> Harry Heymann, FourSquare<br />
  • 42. Summary<br />Lift makes the real-time web simple<br />Lift is the culmination of many great ideas and proven methodologies<br />Lift has a new take on web development<br />Lift is effortlessly secure <br />Lift has awesome comet support<br />Lift is already proven in the field <br />
  • 43. Questions?<br />liftweb.net<br />github.com/lift/lift<br />twitter.com/timperrett<br />github.com/timperrett<br />blog.getintheloop.eu<br />Lift in Action<br />manning.com/perrett/<br />40% discount:<br />lift40au<br />

×