1.1 motivation

356 views
343 views

Published on

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
356
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

1.1 motivation

  1. 1. Scala workshop
  2. 2. If I were to pick a language to use today other than Java, it would be Scala. James Gosling
  3. 3. Scala, it must be stated, is the current heirapparent to the Java throne. No other language on the JVM seems as capable of being a "replacement for Java" as Scala, and themomentum behind Scala is now unquestionable. Charlies Olivier Nutter - JRuby lead
  4. 4. Though my tip though for the long term replacement of javac is Scala. Im very impressed with it! I can honestly say ifsomeone had shown me the Programming in Scala book by by Martin Odersky, Lex Spoon & Bill Venners back in 2003 Id probably have never created Groovy. James Strachen
  5. 5. public class Person { private int age; private String name; public Person(int age, String name) { this.age = age; this.name = name; } public int getAge() { return this.age; } public void setAge(int age) { this.age = age; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } }class Person(var age: Int, var name: String)
  6. 6. List<Person> persons = ...List<Person> adults = new LinkedList<Person>();List<Person> kids = new LinkedList<Person>();for (Person person : persons) { if (person.getAge() < 18) { kids.add(person); } else { adults.add(person); }}val (kids, adults) = persons.partition(_.age < 18)
  7. 7. String s = "!em esreveR";System.out.println(s.reverse());val s: java.lang.String = "!em esreveR"println(s.reverse)=> Reverse me!
  8. 8. BufferedReader reader = null;try { reader = new BufferedReader(new FileReader("f.txt")); System.out.println(reader.readLine());} finally { if (reader != null) { try { reader.close(); } catch (IOException e) { // Exception on close, ignore } }}using(new BufferedReader(new FileReader("f.txt"))) { reader => println(reader.readLine())}
  9. 9. I will never forget these words: "With great power comes great responsibility." This is my gift, my curse. Who am I? Im Spider-man.
  10. 10. val myList = List(1, 2, 3)val res = (10/:myList)(_+_)??
  11. 11. ScalaObject oriented and functionalStatically typedJava compatible Complies to Java bytecode (and CLR) Existing libraries/frameworksBetter Java
  12. 12. Todays scheduleBasic syntaxREPL, IDEs and setupFirst class functionsPattern matchingOO and traitsFunctional programming++

×