Wiki source code of WebObjects with Scala
Version 267.1 by Ravi Mendis on 2009/09/15 20:36
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | === What is Scala? === | ||
2 | |||
3 | Scala is a modern language not unlike Groovy. | ||
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. | ||
5 | |||
6 | Many of its features and paradigms favor multi-threaded and concurrent development: | ||
7 | |||
8 | |= |= Objective-C |= Java |= Scala | ||
9 | |= Mutable/Immuable Datatypes |Collections (e.g: //NSArray/NSMutableArray//) | No | //All datatypes// | ||
10 | |= Closures | (//extensions//) | No | //Built-in// | ||
11 | |= Static variables | Yes | Yes | No | ||
12 | |= Static methods/functions | Yes | Yes | No | ||
13 | |= Concurrency | Grand Central Dispatch (//extensions//) | //Threads// | Actors | ||
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 | |||
20 | === Why Use Scala? === | ||
21 | |||
22 | With Web 2.0, building concurrent WebObjects applications is a must. | ||
23 | Developing and maintaining a concurrent or multi-threaded WebObjects application can be challenging. | ||
24 | |||
25 | Scala offers concurrency built into the language. | ||
26 | So it may offer new solutions to allowing concurrency in WebObjects. | ||
27 | |||
28 | === Can WebObjects be Programmed With Scala? === | ||
29 | |||
30 | Yes. It is very simple. | ||
31 | Scala compiles to java bytecode. Hence using it with WebObjects is fairly straightforward. | ||
32 | |||
33 | == How to Develop WebObjects With Scala == | ||
34 | |||
35 | 1. [[Install the Scala eclipse IDE>>http://www.scala-lang.org/node/94]] | ||
36 | 1. Add Scala support to your project | ||
37 | 11. Right-click your project in the WO Explorer | ||
38 | 11. In the context menu select Scala -> Add Scala Nature | ||
39 | 1. Convert or use ##.scala## instead of ##.java## source | ||
40 | |||
41 | {{note title="Note"}} | ||
42 | |||
43 | This is for Eclipse/WOLips developers | ||
44 | |||
45 | {{/note}} | ||
46 | |||
47 | == WO Scala Example == | ||
48 | |||
49 | The following is a mixed Java/Scala version of the WO Movies D2W app. | ||
50 | All the EO logic and WO components are in Scala. | ||
51 | Only the Application class is Java. | ||
52 | |||
53 | {{attachments patterns=".*zip"}}{{/attachments}} | ||
54 | |||
55 | === Setup === | ||
56 | |||
57 | 1. Install and run the OpenBase OBMovies database. | ||
58 | 1. Right-click on Application.java and run as a WOApplication (as usual). | ||
59 | |||
60 | ==== EO Templates ==== | ||
61 | |||
62 | See: [[Scala templates>>http://wiki.objectstyle.org/confluence/display/WOL/EOGenerator+Templates+and+Additions]] |