28
Scala and its Ecosystem Petr Hošek D 3 S Seminar, September 2010

Lessons Learned: Scala and its Ecosystem

Embed Size (px)

DESCRIPTION

This presentation is motivated by the continuous growth of Scala language popularity thanks to many new concepts it offers. Therefore, it makes a perfect sense to take a further insight on this language. Beside the language itself, its ecosystem is also very important. That is why I will focus on the Scala ecosystem in this presentation.

Citation preview

Page 1: Lessons Learned: Scala and its Ecosystem

Scala and its Ecosystem

Petr HošekD3S Seminar, September 2010

Page 2: Lessons Learned: Scala and its Ecosystem

Language is useless without its ecosystem.

Tools, libraries, frameworks, etc.

Growing usage demands the need of ecosystem.

Java ecosystem is not enough for Scala.

Page 3: Lessons Learned: Scala and its Ecosystem

01 Scala compiler

02 Scala tools & libraries

03 Scala frameworks

04 Collaborative Scaladoc

05 Lessons learned

06 Questions & Answers

Page 4: Lessons Learned: Scala and its Ecosystem

01 Scala compiler

Page 5: Lessons Learned: Scala and its Ecosystem

Second generation of Scala compiler.Oficially named NSC (New Scala Compiler).

Entirely developed in Scala itself (self-hosted).Compiles Scala directly into Java bytecode.

Page 6: Lessons Learned: Scala and its Ecosystem

Allows to be used in several ways.Standalone, interactive, embedded.

Designed to be completely re-entrant.Can be instantiated as any other class.

Compilation consists of several phases.Each phases transforms the syntax tree.

Page 7: Lessons Learned: Scala and its Ecosystem

Developed in entirely modular way.Compiler is composed of several component.

Represented by traits.

Compiler can be easily extended via plugins.

They can be inserted in all phases of compilation.

Page 8: Lessons Learned: Scala and its Ecosystem

02 Scala tools & libraries

Page 9: Lessons Learned: Scala and its Ecosystem

They form the basis of Scala ecosystem.Many new tools appeared in the last few months.

Most of them replaces Java equivalents.

New tools are coming up every day.

Page 10: Lessons Learned: Scala and its Ecosystem

simple-build-tool

Simple but powerful build tool for Scala.Configuration is written directly in Scala.

Provides interactive and batch mode.Dependency management support.Integrated support for many Scala tools.

Lot of plugins and extensions do exists.

Page 11: Lessons Learned: Scala and its Ecosystem

import sbt._

class ExampleProject(info: ProjectInfo) extends ParentProject(info) { override def fork = forkRun(Some(new File("demo")), "-Xmx2G" :: Nil)

  lazy val subA = project("subA", "Sub Project A", new ExampleSubProject(_)) lazy val subB = project("subB", "Sub Project B", new ExampleSubProject(_))

  class ExampleSubProject(info: ProjectInfo) extends DefaultProject(info) { def compileOptions: Seq[CompileOption] = Verbose :: Nil

  val specs = "org.scala-tools.testing" % "specs_2.8.0" % "1.6.5" % "test->default" }}

Page 12: Lessons Learned: Scala and its Ecosystem

specs

Behaviour-driven design framework for Scala.Simple and typed language for specifications.

Benefits from Scala expressive syntax.

Integration with testing tools and frameworks.

JUnit, ScalaCheck, Mockito, etc.

Support for literate programming.

Page 13: Lessons Learned: Scala and its Ecosystem

class GreetingSpecification extends HtmlSpecification with Textile {  "The greeting application" is <t>

h3. Presentation

This new application should say "hello" in different languages.

For example,<ex>by default, saying hello by default should use English</ex> { greet must_== "hello" } Then, other languages, like <ex>French and German should be supported too</ex> { eg {    greet("French") must_== "bonjour"    greet("German") must_== "hallo"  } }

<ex>Japanese should be supported also</ex> { notImplemented }

 </t>}

Page 14: Lessons Learned: Scala and its Ecosystem

Configgy

Library for handling configuration and logging.Simple configuration format.

But still very powerful.

Support for JMX and notification of changes.Extremelly simple API.

Page 15: Lessons Learned: Scala and its Ecosystem

include "/opt/config/local.conf"log (inherit="log-base") { filename = "/var/log/example.log" level = "debug" utc = true verbose { node = "com.example.*" level = "trace" }}hostname = "example.com"port = 3000

Configgy.configure("~/example.conf")

val config = Configgy.configval hostname = config.getString("hostname", "localhost")val port = config.getInt("port", 3000)

val log = Logger.getlog.error("Unable to listen on %s:%d!", hostname, port)

Page 16: Lessons Learned: Scala and its Ecosystem

03 Scala frameworks

Page 17: Lessons Learned: Scala and its Ecosystem

Akka framework

Framework for concurrent, fault-tolerant, scalable applications development.

Based on event-driven approach.

Provides actors, STM, transactors, etc.Together with Scala as well as Java API.

Many add-on modules available.REST, Comet, Spring, Guice, OSGi integration, etc.

Page 18: Lessons Learned: Scala and its Ecosystem

Lift web framework

Expressive and elegant web framework.Benefiting from Scala language features.

Embraces View-First approach to MVC.Importance of scalability and security.

Without loss of performance or maintainability.

Native support for Ajax a Comet.

Page 19: Lessons Learned: Scala and its Ecosystem

04 Collaborative Scaladoc

Page 20: Lessons Learned: Scala and its Ecosystem

Newest addition to Scala ecosystem.Consisting currently from two applications.

Contribution of Scala project documentation. New approach of documentation authoring.

Using the concepts of social collaboration.

Page 21: Lessons Learned: Scala and its Ecosystem

Scaladoc

Analogy of Javadoc for Scala.Part of Scala compiler currently as second generation.

Contains new sleek and modern interface.Provides improved comment syntax.

Supports wiki-like syntax in the source comments.

Page 22: Lessons Learned: Scala and its Ecosystem

Colladoc

Allows to edit Scala symbols documentation.Lift web application running the Scala compiler.Developed as a Google SoC 2010 project.

Now being developed as open-source project.

Based heavily upon Scaladoc 2 functionality.„Do not reinvent the wheel.“

Page 23: Lessons Learned: Scala and its Ecosystem

Mergedoc

Allows to merge changes into the source-code.Simple command-line utility.

Built on top of Scala compiler.

Not yet officially released.Reimplementation of scaladoc-merge tool.

Page 24: Lessons Learned: Scala and its Ecosystem

Collaboration is the main goal.Using collaborative development tools.

Joining the effort is easy.Fork and contribute at GitHub.Track the development at Lighthouse.

Learn more at http://petrhosek.name/

Page 25: Lessons Learned: Scala and its Ecosystem

05 Lessons learned

Page 26: Lessons Learned: Scala and its Ecosystem

Many dimensions of simplicity and complexity.Scala itself is a relatively simple language.

Grammar is somewhat smaller than Java or C#.

Scala concepts are very general and orthogonal.

They can be combined in a large number of ways.

Page 27: Lessons Learned: Scala and its Ecosystem

Scala is different from mainstream languages.

C/C++, Java, C#, etc.

Scala libraries & tools takes different approach.

simple-build-tool, specs, Lift framework, etc.

Learning Scala is not difficult.

Page 28: Lessons Learned: Scala and its Ecosystem

06 Questions & Answers