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