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