CSC/ECE 517 Fall 2014/ch1a 4 lf: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(34 intermediate revisions by 2 users not shown)
Line 2: Line 2:


== Background ==
== Background ==
=== Lift ===


Lift is an expressive framework for building web applications using Scala. It borrows concept from Grails, Ruby on Rails, Seaside, Wicket and Django<ref name = "LiftWiki">[http://en.wikipedia.org/wiki/Lift_(web_framework) Lift (web framework), Wikipedia]</ref>. Lift is designed to make powerful techniques easily accessible, while keeping the overall framework simple and flexible.<ref name = "Book"> Derek Chen-Beccker et al. The Definitive Guide to Lift </ref>
Lift is an expressive framework for building web applications using Scala. It borrows concept from Grails, Ruby on Rails, Seaside, Wicket and Django<ref name = "LiftWiki">[http://en.wikipedia.org/wiki/Lift_(web_framework) Lift (web framework), Wikipedia]</ref>. Lift is designed to make powerful techniques easily accessible, while keeping the overall framework simple and flexible.<ref name = "Book"> Derek Chen-Beccker et al. The Definitive Guide to Lift </ref>


Just like Rails, it favors convention over configuration: it decreases the number of decisions that developers need to make. But, unlike Rails, it does not follow the Model-View-Controller concept. It rather follows the "View First" approach, i.e., it focuses on what to display on the page rather than focusing on the programming of the objects and the logic that builds the page. The creators of Lift have cherry-picked the best ideas from a number of other frameworks, while adding some ideas on their own. Lift is intended to work out of the box and to make creating web pages as efficient and productive as possible<ref name="Book" />
Just like Rails, it favors convention over configuration: it decreases the number of decisions that developers need to make. The creators of Lift have cherry-picked the best ideas from a number of other frameworks, while adding some ideas on their own. Lift is intended to work out of the box and to make creating web pages as efficient and productive as possible<ref name="Book" />
 
As Lift is a framework for Scala and Scala is very compatible with Java, any and all of the java libraries and web containers can be used in running Lift applications.
 
Dynamic web content is authored into the web pages via templates using the standard HTML5 or XHTML editors. It also provides native support for advanced web development techniques such as Comet and Ajax.
 
The main characteristics of the Lift framework are:
* Resistant to common vulnerabilities
* Fast to build, concise and easy to maintain
* High performance and scale in the real world to handle big traffic levels
* Interactive like a desktop application
 
 
=== Scala ===
 
Scala stands for "Scalable Language". Scala is a relatively new language developed by Martin Odersky and his programming language research group at EPFL in Switzerland. The Scala programming language can be used for making general software application, or for web development. Scala is a pure-bred object-oriented language: Every value is an object, and every operation is a method call. The language is quite similar to Ruby.
 
The biggest difference between Ruby and Scala is that, Scala compiles to Java bytecode and runs on the Java Virtual Machine. Thus, it is possible to mix up Java and Scala. Both the languages can be used together for a single project; Scala code can refer the Java code and Java code can refer Scala code without any errors turning up. Scala introduces some very powerful features designed to make the developer more productive. Some of the features are :
* Extremely rich type system
* A powerful type inference
* Native XML processing
* Full support for closures and functions as objects
* Extensive high-level library
 
Scala is called "the statically typed dynamic language"<ref name = "Book"/>. It is possible to write code as quickly as with dynamically typed languages like Python, Ruby etc, but the language offers compile-time type safety like Java.
 
Scala is a also a hybrid functional and object-oriented language, which means one can get the power of the higher-level functional programming languages while retaining the modularity and reusability of OO components. The language uses very strong static type system and the compiler deciphers the types of the variables used.
Just like Ruby, programs written in Scala can be very concise and thus, are smaller in size than in most languages.
 


== Examples ==
== Examples ==
Line 58: Line 28:
The function body starts after the equals sign (=) and often starts on the same line
The function body starts after the equals sign (=) and often starts on the same line
The last value is returned - no explicit return is required, but since the language is strongly typed there is protection against accidentally returning meaningless values of the wrong type
The last value is returned - no explicit return is required, but since the language is strongly typed there is protection against accidentally returning meaningless values of the wrong type
Now you can read Scala.
Now you can read Scala.<ref name="Link1">http://simply.liftweb.net/</ref>


<h3> Java VS Scala </h3>
<h3> Java VS Scala </h3>
Line 85: Line 55:
         | case class Person(<br />
         | case class Person(<br />
name: String, age: Int)
name: String, age: Int)
         |}</div>
         |}</div><ref name="Book1">[http://www.manning.com/perrett/ Lift in action]</ref>


== More Information ==
== More Information ==


=== Lift ===
=== Lift ===
==== Characteristics ====
The main characteristics of the Lift framework are:
* Resistant to common vulnerabilities
* Fast to build, concise and easy to maintain
* High performance and scale in the real world to handle big traffic levels
* Interactive like a desktop application


==== Features ====
==== Features ====
===== View First Approach =====
Lift does not follow the Model-View-Controller concept. It rather follows the "View First" approach, i.e., it focuses on what to display on the page rather than focusing on the programming of the objects and the logic that builds the page. Lift takes the approach that there should be no code in the presentation layer, but it should be flexible enough to accommodate any conceivable uses. For this, Liift usess a powerful templating system, [http://wicket.apache.org Wicket], to bind user-generated data into the presentation layer.
The View-First template means that the we start with an XML template, i.e., the view, and then embed, or execute, independent components to fill in the template. The benefit of this is that the page components become more modular, which makes modifying pages and reusing page components much simpler.
[[File:View_Lift.jpg]]
===== XML Processing Capabilities =====
Lift's templating is built on the XML processing capabilities of the scala language, and allows things such as:
* Nested templates
* Simple injection of user-generated content
* Advanced data capabilities.
Lift's advanced template and XML processing allows the developer to essentially write custom tag libraries at a very less cost in terms of time and effort.
===== Support for Java =====
Lift runs on Scala. Scala runs on top of the JVM. This means that any and all of the java libraries and web containers can be used in running Lift applications. Java files can be used inside the project, such that Lift references the code used in a Java file, while Java can reference the code used in a Lift file
===== Support for Advanced Features =====
Dynamic web content is authored into the web pages via templates using the standard HTML5 or XHTML editors. Lift's powerful support for AJAX and Comet allows the developer to use Web 2.0 features with very little effort.
====== Comet ======
Lift leverages Scala's Actor library to provide a message-driven framework for Comet updates. In most cases, adding Comet support to a page just involves extending a trait to define the rendering method of the paage and adding an extra function call the links to dispatch the update message. Lift handles all of the backend and page-side coding to effect the Comet polling
====== AJAX ======
AJAX support includes special handlers for doing AJAX form submission via JSON, and almost any link function can easily be turned into an AJAX version with a few keystrokes. Lift has a class hierarchy for encapsulating JavaScript calls via direct JavaScript, jQuery or Yahoo User Interface library. The code can be generated automatically, reducing or eliminating the need to put JavaScript logic into the templates.


=== Scala ===
=== Scala ===


==== Introduction ====
==== Introduction ====
[http://www.scala-lang.org/ Scala] stands for "Scalable Language". Scala is a relatively new language developed by Martin Odersky and his programming language research group at EPFL in Switzerland. The Scala programming language can be used for making general software application, or for web development.
==== Features ====
Scala introduces some very powerful features designed to make the developer more productive. Some of the features are<ref name="Book" /> :
* Extremely rich type system
* A powerful type inference
* Native XML processing
* Full support for closures and functions as objects
* Extensive high-level library
Scala is a pure-bred object-oriented language: Every value is an object, and every operation is a method call. The language is quite similar to Ruby.
===== Compatibility with Java<ref name = "ScalaSite">http://www.scala-lang.org/what-is-scala.html</ref> =====
Scala runs on the JVM. Java and Scala classes can be freely mixed, no matter whether they reside in different projects or in the same. They can even mutually refer to each other, the Scala compiler contains a subset of a Java compiler to make sense of such recursive dependencies. Java libraries, frameworks and tools are all available. Build tools like ant or maven, IDEs like Eclipse, IntelliJ, or Netbeans, frameworks like Spring or Hibernate all work seamlessly with Scala. Scala runs on all common JVMs and also on Android. The Scala community is an important part of the Java ecosystem. Popular Scala frameworks, including Akka, Finagle, and the Play web framework include dual APIs for Java and Scala.
===== Nature of the language =====
Scala is called "the statically typed dynamic language"<ref name = "Book"/>. It is possible to write code as quickly as with dynamically typed languages like Python, Ruby etc, but the language offers compile-time type safety like Java.
Scala is a also a hybrid functional and object-oriented language, which means one can get the power of the higher-level functional programming languages while retaining the modularity and reusability of OO components. The language uses very strong static type system and the compiler deciphers the types of the variables used. Programs written in Scala can be very concise and thus, are smaller in size than in most languages.
===== Future-Proof<ref name = "ScalaSite" /> =====
Scala particularly shines when it comes to scalable server software that makes use of concurrent and synchronous processing, parallel utilization of multiple cores, and distributed processing in the cloud.


==== Features ====
Its functional nature makes it easier to write safe and performant multi-threaded code. There’s typically less reliance on mutable state and Scala’s futures and actors provide powerful tools for organizing concurrent system at a high-level of abstraction.


== Helpful Links ==
== Helpful Links ==
<h3>Lift Download Links</h3>
1. http://liftweb.net/download.html <br />
2. https://github.com/lift/framework <br />
3. http://scala-ide.org/docs/tutorials/lift24scalaide20/index.html <br />


<h3>Lift Tutorials links</h3>
<h3>Lift Tutorials links</h3>
1. http://simply.liftweb.net/
1. http://simply.liftweb.net/ <br />
2. http://www.liftweb.net/
2. http://www.liftweb.net/ <br />
3.  
3. https://www.assembla.com/wiki/show/liftweb/Getting_Started <br />
4. http://hedleyproctor.com/2011/10/tutorial-building-your-first-lift-app-with-sbt/ <br />


<h3>Helpful Links for Lift resources</h3>
<h3>Helpful Links for Lift resources</h3>
Line 139: Line 180:


== References ==
== References ==


<references />
<references />

Latest revision as of 01:06, 28 September 2014

Lift is a web application framework designed for Scala Programming Language. It was designed by David Polka who was dissatisfied with Ruby on Rails. It was launched on February 26, in 2007 as an Open Source framework under the Apache 2.0 License.

Background

Lift is an expressive framework for building web applications using Scala. It borrows concept from Grails, Ruby on Rails, Seaside, Wicket and Django<ref name = "LiftWiki">Lift (web framework), Wikipedia</ref>. Lift is designed to make powerful techniques easily accessible, while keeping the overall framework simple and flexible.<ref name = "Book"> Derek Chen-Beccker et al. The Definitive Guide to Lift </ref>

Just like Rails, it favors convention over configuration: it decreases the number of decisions that developers need to make. The creators of Lift have cherry-picked the best ideas from a number of other frameworks, while adding some ideas on their own. Lift is intended to work out of the box and to make creating web pages as efficient and productive as possible<ref name="Book" />

Examples

Basic Scala

Skip this if you know Scala and how to use Lift.

Scala is an extremely flexible and feature-ful language, but you don't need to know much about it to get started with Lift. Read more about Scala some time, but here is all I think you need to know to get started if you already know Java or a similar language.

A Scala function definition looks like this:

def [function-name] ([parameter-name]: [parameter-type]) : [return-type] = [function-body]

so

def taste (food: Consumable) : Opinion = evaluate(food)

defines a function called taste that takes a Consumable as a parameter (food) and returns an Opinion calls evaluate and returns the result, which must be an Opinion
The function body starts after the equals sign (=) and often starts on the same line The last value is returned - no explicit return is required, but since the language is strongly typed there is protection against accidentally returning meaningless values of the wrong type Now you can read Scala.<ref name="Link1">http://simply.liftweb.net/</ref>

Java VS Scala

When building class definitions, it’s common to have to build so-called getter and setter methods in order to set the values of that instance. This typically creates a lot of noise in the implementation (as seen in the Java example that follows). Scala combats this by using the case modifier to automatically provision standard functionality into the class definition. Given an instance of the Person case class, calling person.name would return the name value.

JAVA SCALA
public class Person {

private int _age;
private String _name;
public Person(String n, int a){
_age = a;
_name = n;
}
String name(){ return _name; }
int age(){ return _age; }
}

case class Person(

name: String, age: Int)

<ref name="Book1">Lift in action</ref>

More Information

Lift

Characteristics

The main characteristics of the Lift framework are:

  • Resistant to common vulnerabilities
  • Fast to build, concise and easy to maintain
  • High performance and scale in the real world to handle big traffic levels
  • Interactive like a desktop application

Features

View First Approach

Lift does not follow the Model-View-Controller concept. It rather follows the "View First" approach, i.e., it focuses on what to display on the page rather than focusing on the programming of the objects and the logic that builds the page. Lift takes the approach that there should be no code in the presentation layer, but it should be flexible enough to accommodate any conceivable uses. For this, Liift usess a powerful templating system, Wicket, to bind user-generated data into the presentation layer.

The View-First template means that the we start with an XML template, i.e., the view, and then embed, or execute, independent components to fill in the template. The benefit of this is that the page components become more modular, which makes modifying pages and reusing page components much simpler.


XML Processing Capabilities

Lift's templating is built on the XML processing capabilities of the scala language, and allows things such as:

  • Nested templates
  • Simple injection of user-generated content
  • Advanced data capabilities.

Lift's advanced template and XML processing allows the developer to essentially write custom tag libraries at a very less cost in terms of time and effort.


Support for Java

Lift runs on Scala. Scala runs on top of the JVM. This means that any and all of the java libraries and web containers can be used in running Lift applications. Java files can be used inside the project, such that Lift references the code used in a Java file, while Java can reference the code used in a Lift file

Support for Advanced Features

Dynamic web content is authored into the web pages via templates using the standard HTML5 or XHTML editors. Lift's powerful support for AJAX and Comet allows the developer to use Web 2.0 features with very little effort.

Comet

Lift leverages Scala's Actor library to provide a message-driven framework for Comet updates. In most cases, adding Comet support to a page just involves extending a trait to define the rendering method of the paage and adding an extra function call the links to dispatch the update message. Lift handles all of the backend and page-side coding to effect the Comet polling

AJAX

AJAX support includes special handlers for doing AJAX form submission via JSON, and almost any link function can easily be turned into an AJAX version with a few keystrokes. Lift has a class hierarchy for encapsulating JavaScript calls via direct JavaScript, jQuery or Yahoo User Interface library. The code can be generated automatically, reducing or eliminating the need to put JavaScript logic into the templates.

Scala

Introduction

Scala stands for "Scalable Language". Scala is a relatively new language developed by Martin Odersky and his programming language research group at EPFL in Switzerland. The Scala programming language can be used for making general software application, or for web development.

Features

Scala introduces some very powerful features designed to make the developer more productive. Some of the features are<ref name="Book" /> :

  • Extremely rich type system
  • A powerful type inference
  • Native XML processing
  • Full support for closures and functions as objects
  • Extensive high-level library

Scala is a pure-bred object-oriented language: Every value is an object, and every operation is a method call. The language is quite similar to Ruby.


Compatibility with Java<ref name = "ScalaSite">http://www.scala-lang.org/what-is-scala.html</ref>

Scala runs on the JVM. Java and Scala classes can be freely mixed, no matter whether they reside in different projects or in the same. They can even mutually refer to each other, the Scala compiler contains a subset of a Java compiler to make sense of such recursive dependencies. Java libraries, frameworks and tools are all available. Build tools like ant or maven, IDEs like Eclipse, IntelliJ, or Netbeans, frameworks like Spring or Hibernate all work seamlessly with Scala. Scala runs on all common JVMs and also on Android. The Scala community is an important part of the Java ecosystem. Popular Scala frameworks, including Akka, Finagle, and the Play web framework include dual APIs for Java and Scala.

Nature of the language

Scala is called "the statically typed dynamic language"<ref name = "Book"/>. It is possible to write code as quickly as with dynamically typed languages like Python, Ruby etc, but the language offers compile-time type safety like Java.

Scala is a also a hybrid functional and object-oriented language, which means one can get the power of the higher-level functional programming languages while retaining the modularity and reusability of OO components. The language uses very strong static type system and the compiler deciphers the types of the variables used. Programs written in Scala can be very concise and thus, are smaller in size than in most languages.


Future-Proof<ref name = "ScalaSite" />

Scala particularly shines when it comes to scalable server software that makes use of concurrent and synchronous processing, parallel utilization of multiple cores, and distributed processing in the cloud.

Its functional nature makes it easier to write safe and performant multi-threaded code. There’s typically less reliance on mutable state and Scala’s futures and actors provide powerful tools for organizing concurrent system at a high-level of abstraction.

Helpful Links

Lift Download Links

1. http://liftweb.net/download.html
2. https://github.com/lift/framework
3. http://scala-ide.org/docs/tutorials/lift24scalaide20/index.html

Lift Tutorials links

1. http://simply.liftweb.net/
2. http://www.liftweb.net/
3. https://www.assembla.com/wiki/show/liftweb/Getting_Started
4. http://hedleyproctor.com/2011/10/tutorial-building-your-first-lift-app-with-sbt/

Helpful Links for Lift resources

Resource Description Link
Main Lift site First and foremost is the main Lift homepage. Here you’ll find the latest

news about Lift, regularly updated as time goes by. This page also has links to the source code, the issue tracker, and the wiki.

http://liftweb.net
Assembla Lift moved to the Assembla platform for its wiki and bug-tracking requirements

some time ago, and since then it has accumulated a fair amount of community-created articles.

https://www.assembla.com/wiki/show/liftweb
Mailing list The Google group is the official support channel for Lift. If you have a

question, you can come to the mailing list and find a friendly, responsive community that will be more than happy to answer your questions.

http://groups.google.com/group/liftweb
IRC channel IRC isn’t as popular as it once was, but you’ll still find some of the Lift

team hanging out in IRC from time to time.

https://www.freenode.net

References

<references />