• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Why Scala?
 

Why Scala?

on

  • 2,211 views

A short presentation given at my workplace introducing the Scala programming language.

A short presentation given at my workplace introducing the Scala programming language.

Statistics

Views

Total Views
2,211
Views on SlideShare
2,176
Embed Views
35

Actions

Likes
1
Downloads
41
Comments
0

4 Embeds 35

http://www.linkedin.com 18
https://www.linkedin.com 10
http://www.slideshare.net 6
http://www.lmodules.com 1

Accessibility

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Why Scala? Why Scala? Presentation Transcript

    • Why Scala? (or why not Java?)
    • What is Scala?
      • Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages. It is also fully interoperable with Java.
      • -- Martin Odersky
      • Huh?
      • -- Fogus
    • Let's Create a Map!
      • Java
      • Scala
      Map<String, Integer> numMap = new HashMap<String, Integer>(); numMap.put(&quot;one&quot;, 1); numMap.put(&quot;two&quot;, 2); nummap.put(&quot;three&quot;, 3); var numMap = Map(&quot;one&quot; -> 1, &quot;two&quot; -> 2, &quot;three&quot; -> 3) These are equivalent constructs and will work identically thanks to type-inference. Hooray for compile-time type checking and succinctness!
    • Boilerplate
      • public class Person
      • {
      • private String lastName;
      • private String firstName;
      • private Person spouse;
      • public Person(String fn, String ln, Person s) {
      • lastName = ln;
      • firstName = fn;
      • spouse = s;
      • }
      • public Person(String fn, String ln) {
      • this(fn, ln, null);
      • }
      • public String getFirstName() { return firstName; }
      • public String getLastName() { return lastName; }
      • public Person getSpouse() { return spouse; }
      • public void setSpouse(Person p) { spouse = p; }
      • public String introduction() {
      • return &quot;Hi, my name is &quot; + firstName + &quot; &quot; + lastName +
      • (spouse != null ?
      • &quot; and this is my spouse, &quot; + spouse.firstName + &quot; &quot; + spouse.lastName + &quot;.&quot; :
      • &quot;.&quot;);
      • }
      • }
    • No Boilerplate
      • class Person(val lastName:String, val firstName:String, val spouse:Option[Person]) {
      • def this(ln:String, fn:String) = this(ln, fn, None)
      • def intro():String =
      • (spouse match {
      • case None => &quot;.&quot;
      • case Some(s) => &quot; and this is my spouse, &quot; + s.firstName + &quot; &quot; + s.lastName + &quot;.&quot;
      • });
      • }
      By default , Scala classes are immutable.
    • Concurrency
      • Actors
        • Send a finite number of messages to other actors
          • No shared state
        • Create a finite number of new actors
        • Designate the behavior to be used for the next message it receives
          • Event driven
    • Misc.
        • You can embed XML directly into Scala clauses
        • Functional programming
        • Everything is an object
        • List comprehensions
        • Case classes
        • Pattern Matching
    • Why Not Java?
      • Actually, we will use Java extensively as every Java class can be seamlessly integrated into Scala. However, we will leverage the advantages that Scala provides.
    • L@@k
      • http://scala-lang.org
      • http://www.artima.com/weblogs/index.jsp?blogger=modersky
      • http://ola-bini.blogspot.com/search/label/scala
      • http://www.drmaciver.com/planetscala/
      • http://lambda-the-ultimate.org/search/node/Scala
      • #scala