5. Scala = SCAlable LAnguage
wächst mit den Bedürfnissen der User
kleine Skripte bis hin zu großen und komplexen
Systemen
Multiparadigmensprache
verbindet objektorientierte (imperative) und funktionale
Programmierung
pragmatisch, typsicher, strikt objektorientiert
interoperabel mit Standard Plattformen (Java, .NET) 4
6. Wurzeln reichen zurück in das Jahr 1995
Philip Wadler und Martin Odersky
Funktionale Programmiersprachen für die JVM
Pizza
GJ (Generic Language Extension für Java)
javac
Java Generics
1999 verfolgte Martin Odersky das Ziel funktionale mit
OO Programmierung zu kombinieren
Funnel
Scala
*2001, 2003 erstes Public Release, 2006 Version 2.0,
aktuell 2.7.4 RC1 5
7. Ziel von Scala:
Das Beste aus beiden Welten (OO und FP)
Statisch typisiert + Typinferenz
Funktionen höherer Ordnung
Traits, Mixin-Komposition
Option-Klasse (None und Some vs. null)
Pattern Matching
Algebraische Typen
Native XML-Unterstützung inkl. XPath Unterstützung (Bibliothek)
Actor Model
Currying
Anonyme Funktionen
Parametrische Polymorphie 6
8. Einige reservierte Schlüsselwörter in Scala
class, case class, object
new
with
extends
abstract
sealed
trait
def, var, val
override
match, case
7
13. Imperative vs. funktionale Programmierung (I)
public class Example1 {
public static void main(String[] args) {
for (String arg : args) {
System.out.println(arg);
}
}
}
10
14. Imperative vs. funktionale Programmierung (I)
public class Example1 {
public static void main(String[] args) {
for (String arg : args) {
System.out.println(arg);
}
}
}
object Example1 {
def main(args: Array[String]) {
args.foreach(println)
}
}
10
15. Imperative vs. funktionale Programmierung (II)
public class Example2 {
public static void main(String[] args) {
for (String arg : args) {
if (arg.startsWith("JAX09")) {
System.out.println(arg);
}
}
}
}
11
16. Imperative vs. funktionale Programmierung (II)
public class Example2 {
public static void main(String[] args) {
for (String arg : args) {
if (arg.startsWith("JAX09")) {
System.out.println(arg);
}
}
}
}
object Example2 {
def main(args: Array[String]) {
args.filter(_.startsWith("JAX09")).foreach(println)
}
} 11
17. Imperative vs. funktionale Programmierung (III)
public class Example3 {
public static void main(String[] args) {
boolean exists = false;
for (String arg : args) {
if (arg.startsWith("JAX09")) {
exists = true;
break;
}
}
System.out.print(exists);
}
}
12
18. Imperative vs. funktionale Programmierung (III)
public class Example3 {
public static void main(String[] args) {
boolean exists = false;
for (String arg : args) {
if (arg.startsWith("JAX09")) {
exists = true;
break;
}
}
System.out.print(exists);
}
}
object Example3 {
def main(args: Array[String]) {
print(args.exists(_.startsWith("JAX09")))
}
} 12
20. David Pollak
Gründer von Lift
Kommerzielle Softwareentwicklung seit 1977
Web-Applikationen seit 1996
15. Februar 2007:
Initial Import (GitHub) in der Version 0.1.0
Gründung von Lift als OS Projekt in 2007
26. Februar 2009:
Lift 1.0
Aktuelles Lift-Team besteht aus 13 Comitter
Aktive Community
http://groups.google.com/group/liftweb 14
21. „Best of all“
Scala als zugrundeliegende Sprache
nativer XML-Support (XHTML nativ innerhalb von Snippets!)
Scala Actors für mächtige Comet-Anwendungen
fein granulare Sessions und Security (Seaside)
schnelles Projektsetup durch „convention over
configuration“ + geringe Turnaround-Zeiten (Rails)
Django's "more than just CRUD is included"
Designer freundliche Templates (Wicket / Lift View First)
Offen für die Nutzung von zahlreichen OSS-Bibliotheken
(Java)
Etablierte Deployment-Prozesse (JEE / Java) 15
22. Weitere Eigenschaften / Ziele von Lift
Sicherheit
XSS, replay Attacken, Parameter tampering
Wartbarkeit
Skalierbarkeit
Performance
Hohe Produktivität
Einfach
Convention over configuration
DRY
16
23. „View First“ Design-Prinzip
Templates enthalten keinen Code
Pures XHTML
Können mit Standard Design-Werkzeugen bearbeitet
werden
Frontend ist ohne Scala-Kenntnisse von einem Designer
realisierbar
<lift:surround with="default" at="content">
<h2>Welcome to your project!</h2>
<p><lift:helloWorld.howdy /></p>
</lift:surround>
17
50. Template
Template Verarbeitung
Request Mapping nach folgendem Schema
<path>[_<language, optional>][.<suffix>]
Lift wählt die passende Sprache und Endung
22
51. Template
Template Verarbeitung
Request Mapping nach folgendem Schema
<path>[_<language, optional>][.<suffix>]
Lift wählt die passende Sprache und Endung
Links ohne Sprache und Endung angeben
22
52. Template
Template Verarbeitung
Request Mapping nach folgendem Schema
<path>[_<language, optional>][.<suffix>]
Lift wählt die passende Sprache und Endung
Links ohne Sprache und Endung angeben
Lift versteckt Templates und
Ressourcen in Verzeichnissen
welche als Endung -hidden im
Namen tragen
22
53. Template
Template Verarbeitung
Request Mapping nach folgendem Schema
<path>[_<language, optional>][.<suffix>]
Lift wählt die passende Sprache und Endung
Links ohne Sprache und Endung angeben
Lift versteckt Templates und
Ressourcen in Verzeichnissen
welche als Endung -hidden im
Namen tragen
22
58. ›
Template
Template Verarbeitung von Außen nach Innen
24
59. ›
Template
Template Verarbeitung von Außen nach Innen
/index.html
<lift:surround with="default" at="content">
<h2>Welcome to your project!</h2>
<p><lift:HelloWorld.howdy /></p>
</lift:surround>
24
60. ›
Template
Template Verarbeitung von Außen nach Innen
/index.html
<lift:surround with="default" at="content">
<h2>Welcome to your project!</h2>
<p><lift:HelloWorld.howdy /></p>
</lift:surround>
/templates-hidden/default.html
<html xmlns="..." xmlns:lift="http://liftweb.net/">
<head>...</head>
<body>
...
<lift:bind name="content" />
</body>
</html>
24
61. ›
Template
Template Verarbeitung von Außen nach Innen
/index.html
<lift:surround with="default" at="content">
<h2>Welcome to your project!</h2>
<p><lift:HelloWorld.howdy /></p>
</lift:surround>
/templates-hidden/default.html
<html xmlns="..." xmlns:lift="http://liftweb.net/">
<head>...</head>
<body>
...
<lift:bind name="content" />
</body>
</html>
Ausführung von HelloWorld#howdy 24
99. Boot.scala
def boot {
if (!DB.jndiJdbcConnAvailable_?)
DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor)
// where to search snippet
LiftRules.addToPackages("de.inovex.jax2009.lift")
// create or update the database schema
Schemifier.schemify(true, Log.infoF _, User)
// build site map
val entries = Menu(Loc("Home", List("index"), "Home")) :: User.sitemap
LiftRules.setSiteMap(SiteMap(entries:_*))
// Show the spinny image when an Ajax call starts
LiftRules.ajaxStart = Full(() => LiftRules.jsArtifacts.show("ajax-loader").cmd)
// Make the spinny image go away when it ends
LiftRules.ajaxEnd = Full(() => LiftRules.jsArtifacts.hide("ajax-loader").cmd)
// force the request to be UTF-8
LiftRules.early.append(makeUtf8)
S.addAround(DB.buildLoanWrapper)
} 37
121. Pro
Sehr schicke Sprachfeatures
„Best of all“ Prinzip
Junge und dynamische Community
Sehr gut für interaktive Webbapplikationen („Real time web“)
Native, volle JVM Geschwindigkeit
100% kompatibel mit Java
Läuft auf Standard Servlet-Container (Jetty, Tomcat, ...)
44
122. Pro
Sehr schicke Sprachfeatures
„Best of all“ Prinzip
Junge und dynamische Community
Sehr gut für interaktive Webbapplikationen („Real time web“)
Native, volle JVM Geschwindigkeit
100% kompatibel mit Java
Läuft auf Standard Servlet-Container (Jetty, Tomcat, ...)
Cons
Steile Lernkurve
Wenig Scala Ressourcen am Markt verfügbar (XING: 164)
Noch weniger Lift Ressourcen verfügbar (XING: 3)
Keine mir bekannten große Installationen aktuell vorzeigbar 44
123. Aktuell Roadmap 1.1 (Auszug der Lift Newsgroup)
Improved documentation: better VScalaDoc coverage as well as better tutorial and
cook-book documentation.
Improved J2EE support including JTA and Portlets.
Finish Record/Field code with backing store including JDBC, JPA and Goat Rodeo
(what's Goat Rodeo? http://goatrodeo.org)
Improved client-side JavaScript support and better JavaScript abstractions.
Client/Server data synchronization (integrated with Record/Field)
Improved support for REST.
Improved performance including caching templates when running in production
mode.
OSGi support.
Improved testing framework and better testing support when running in "test" mode.
Implement Servlet 3.0 support.
HTML 5 and Web Sockets support and integration with Kaazing's Web Sockets
server. Also, sensing which browser is making the request and performing
optimizations based on that browser's characteristics (specifically, Chrome and
Firefox 3.1 support) 45
125. Exploring Lift
Mail 2009, oder LyX Version!
Derek Chen-Becker,
Tyler Weir, Marius Danciu
Beginning Scala
Mail 2009
David Pollak
Programming in Scala
Martin Odersky,
Lex Spoon, and Bill Venners
...
47
126. Fragen & Antworten
Tobias Joch
System Architecture
Project Management
inovex GmbH
Karlsruher Straße 71
75179 Pforzheim
0173.3181 004
tobias.joch@inovex.de
www.inovex.de
Wir nutzen Technologien, um unsere Kunden glücklich zu machen. Und uns selbst.
127. Vielen Dank! ;)
Tobias Joch
System Architecture
Project Management
inovex GmbH
Karlsruher Straße 71
75179 Pforzheim
0173.3181 004
tobias.joch@inovex.de
www.inovex.de
Wir nutzen Technologien, um unsere Kunden glücklich zu machen. Und uns selbst.