Wiki source code of WebObjects with Scala

Version 247.1 by Ravi Mendis on 2009/09/15 20:43

Hide last authors
Ravi Mendis 21.1 1 === What is Scala? ===
Ravi Mendis 195.1 2
3 Scala is a modern language not unlike Groovy.
Ravi Mendis 209.1 4 It is said to be more powerful (and faster) than Groovy or Rails which has been the reason for its adoption at sites like Twitter.
Ravi Mendis 195.1 5
Ravi Mendis 247.1 6 Many of its features and paradigms favor multi-threaded and concurrent development which may not be unfamiliar to Objective-C developers:
Ravi Mendis 195.1 7
Ravi Mendis 247.1 8 |= |= Objective-C |= Java |= Scala
9 |= Mutable/Immuable Datatypes |Collections //e.g: NSArray/NSMutableArray// | No | //All datatypes//
10 |= Closures | //Extension// | No | //Built-in//
11 |= Static variables | Yes | Yes | No
12 |= Static methods/functions | Yes | Yes | No
13 |= Concurrency | Grand Central Dispatch (//Extension//) | //Threads// | Actors
Ravi Mendis 195.1 14
15 Other notable features include:
16
17 |= |= Objective-C |= Java |= Scala
18 |= Parametered methods | Yes //e.g: addObject: to~:// | No | Yes //e.g: add(object= ,to=)//
19 |= Class composition | Categories | Interfaces | Traits
20
21 A fuller description of Scala can be found [[here>>http://en.wikipedia.org/wiki/Scala_(programming_language)]].
22
23 === Why Use Scala? ===
24
25 With Web 2.0, building concurrent WebObjects applications is a must.
26 Developing and maintaining a concurrent or multi-threaded WebObjects application can be challenging.
27
Ravi Mendis 247.1 28 Scala offers concurrency built into the language and is inherently thread-safe.
29 So it may offer new solutions to allowing concurrency in WebObjects.
Ravi Mendis 195.1 30
Ravi Mendis 247.1 31 === Can WebObjects be Programmed With Scala? ===
Ravi Mendis 195.1 32
33 Yes. It is very simple.
34 Scala compiles to java bytecode. Hence using it with WebObjects is fairly straightforward.
35
Ravi Mendis 247.1 36 == How to Develop WebObjects With Scala ==
Ravi Mendis 195.1 37
Ravi Mendis 231.1 38 1. [[Install the Scala eclipse IDE>>http://www.scala-lang.org/node/94]]
Ravi Mendis 247.1 39 1. Add Scala support to your project
Ravi Mendis 231.1 40 11. Right-click your project in the WO Explorer
41 11. In the context menu select Scala -> Add Scala Nature
42 1. Convert or use ##.scala## instead of ##.java## source
Ravi Mendis 195.1 43
44 {{note title="Note"}}
45
Ravi Mendis 247.1 46 This is for Eclipse/WOLips developers
Ravi Mendis 195.1 47
48 {{/note}}
49
50 == WO Scala Example ==
51
Ravi Mendis 205.1 52 The following is a mixed Java/Scala version of the WO Movies D2W app.
Ravi Mendis 195.1 53 All the EO logic and WO components are in Scala.
54 Only the Application class is Java.
55
56 {{attachments patterns=".*zip"}}{{/attachments}}
57
58 === Setup ===
59
60 1. Install and run the OpenBase OBMovies database.
61 1. Right-click on Application.java and run as a WOApplication (as usual).
62
63 ==== EO Templates ====
64
65 See: [[Scala templates>>http://wiki.objectstyle.org/confluence/display/WOL/EOGenerator+Templates+and+Additions]]