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