The first release of the Scala with Sails web framework is available at Source Forge and on the Scala with Sails web site.
Scala with Sails (SwS) is a web framework that stresses security, ease of development, ease of deployment, and compatibility with existing Java classes. SwS is built using the Scala Functional-O-O language and runs in any Java Servlet 2.4 container (e.g., Tomcat 5.5 running on a JDK 1.5.)
And just to be clear, this is my framework and I am promoting (pimping) it rather than making positive (or negative) comments about a framework I've spent some time using
SwS stresses security by presenting "secure by default" constructs to the developer, resisting replay attacks, and generally not trusting what is "on the wire." Additionally, SwS's model objects have semantically meaningful classes that hold mappings to database columns (e.g., a taxpayer ID field that presents ***-**-**** as the default view, ***-**-3344 as a 'semi-privileged' view, and 333-22-3344 as the 'fully-privileged' view where privileges are defined using algebraic notation and defined in a single place for all taxpayer ID instances and fields.) For more, see My rant about keeping meaning with bytes.
SwS stresses ease of development by separating model, view and controller and by presenting simple semantics for common tasks as well as "the right thing by default." SwS code for CRUD (Create, Read, Update, Delete) tasks should be as compact (or more compact) and as readable as similar Ruby on Rails code. On the other hand, SwS will support significantly richer state management than RoR. Pages will be composed of many long-lived controller/view objects which maintain state in Monads. Each controller may receive input from user-actions or external actions and may mark its associated view as dirty. Dirty views are sent back to the browser as (1) part of a page reload, (2) as a change "push" responding to an AJAX request or (3) forcing a Comet event. The controllers will be Scala Actors such that they may be hundreds or thousands of live controllers in the system at any one time. Associating code blocks with web links and form elements, SwS allows a very granular HTTP request routing.
SwS stresses ease of deployment by supporting packaging as a Java WAR file. An SwS application can be deployed by dropping the application in a target directory on a web server. SwS WAR files look and act like Java WAR files and are indistinguishable and thus work in existing infrastructures. This means no change in testing or deployment to use SwS.
Scala is a hybrid Functional-O-O language that compiles down to Java byte-code. Any Java class can be called by Scala code. Scala classes can implement Java interfaces and be passed as parameters into existing Java code. Legacy Java domain classes, O-R mapping systems, and general business logic can be accessed from Scala code. Because Scala is a strongly typed language, it does not suffer the performance penalties of "scripting" languages that have been implemented on the JVM (e.g., JRuby, Jython, etc.) However, Scala's typing system along with a lot of syntactic sugar makes Scala code as compact and almost (IMHO) as visually pleasing as Ruby code. Plus, Scala supports XML at the syntactic level which means that there's no need to have a separate templating language or system as it's built right into the language. Finally, because functions are objects, partial functions can be returned from function calls, functions can be stored in HashMaps, and functions can be chained, there's little need for Ruby's meta-programming, dynamic classes and method creation. In place, functions can be built up and chained together at run-time and the resulting functions can be cached. This gives much of the performance benefits of dynamic class/method creation without the nasty security and auditability issues.
I expect the improve and enhance SwS so that it becomes a useful product for real-world web applications.
In the near term, I plan to flesh out the O-R mapping stuff to handle primary keys and foreign keys and then spend some time designing and implementing the multiple views/controllers composited to make up a page. I also need to implement tests for the SwS as well as creating a testing framework.
I look forward to thoughts, feedback, contributions, rocks, and rotten tomatoes.
Ruby on Rails, Scala with Sails ... what's next, Tigers with Tails?...
Tracked: Dec 09, 09:50