-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Scala-Virtualized is an experimental branch of the Scala compiler and standard library that contains a few additions to provide even better support for embedded DSLs (we call that language virtualization).
The key features are as follows:
-
overloadable control structures (while-loops, if-then-else, pattern matching), variables, object creation, etc. Scala has always translated for-comprehensions into method calls, so that the programmer can change the meaning of a for-comprehension by implementing these methods in a certain way. We generalize this to all control flow operators, as well as to the representation of mutable variables and object creation (for now limited to struct-like datatypes, but providing precise types for field-selection).
-
extension methods: define new infix-methods on existing types (pimp-my-library with less boilerplate)
-
transparent proxies: re-route all method calls on these proxy objects to a forwarder method
- Virtualized Scala Reference: In-depth description of each feature
- Source Location and Source Context: Linking DSL expressions back to the original source
- Tutorial: Generating SQL
- Tutorial: Generating JavaScript from embedded Scala code
- Tutorial: Compiling embedded Scala code at runtime
Tutorial source code is available here.
NOTE: the build of the Scala Eclipse plugin based on virtualized Scala is experimental (the build, not the code of the plugin itself)! Please use a separate Eclipse installation (and workspace) when installing the virtualized Scala plugin for Eclipse.
That said, simply point a fresh install of Eclipse classic 3.7 to our virtualized-scala update site (built nightly). You'll probably see a security warning during the installation as we are not yet signing the plugin. Please see the official plugin website for more details and up-to-date instructions.
Be sure to enable -Xexperimental
in the plugin's advanced compiler settings if your code requires e.g., applyDynamic
.
The latest distribution (built nightly) of the virtualized Scala compiler and library is available as a zip-file. Archived nightlies are also available.
Additionally, the nightly artifacts are published to scala-tools.org as version 2.10.0-virtualized-SNAPSHOT, so they are readily available as maven dependencies.
To get a feel for the build stability, please have a look at our Jenkins dashboard. The downloads above are only made available if all tests pass, barring currently known issues.
Here is a sample build.sbt
file for use with the Simple Build Tool (SBT):
name := "My Scala-Virtualized Project"
version := "1.0"
resolvers += ScalaToolsSnapshots
scalaVersion := "2.10.0-virtualized-SNAPSHOT"
Some corner cases with the continuations plugin still need to be resolved.
Developers push to virtualized-mostrecent, which Jenkins continuously integrates into virtualized-master. Nightlies are built from virtualized-master and published to scala-tools.org as version 2.10.0-virtualized-SNAPSHOT. Every morning, plain vanilla Scala's master is automatically merged into virtualized-mostrecent (which is then built by Jenkins, and if successful, merged into virtualized-master and pushed back to github).
Scala-Virtualized is actively used in a couple of open source projects:
- OptiML: A DSL for machine learning developed at Stanford PPL
- Scala Integrated Query (SIQ): LINQ-style database interface in Scala
- Delite: Framework/Runtime for heterogeneous parallelism
- LMS-Core: Compiler framework for embedded DSLs
Community support is available on the regular Scala mailing lists. Posts should mention scala-virtualized in the subject line.
Using Scala-Virtualized for your project? Please let us know!