This page is no longer maintained — Please continue to the home page at www.scala-lang.org

scala compiler api?

3 replies
Baldur Norddahl
Joined: 2009-02-01,
User offline. Last seen 42 years 45 weeks ago.
Hi,

I am looking for a way to use Scala in a "PHP" like fashion. I want to be able to drop in a scala script in a directory and instantly have that script available to process HTTP requests.

Thinking about this, I believe what is needed is a servlet that can be deployed on any servlet container such as Apache Tomcat. The servlet would accept requests and look in a script directory for scala scripts to process the request. If the request maps to a new script or the script has been modified since last request, it would compile the file before handing over the request.

Has anyone played with this idea before? If not, where can I find information about how to embed the scala compiler, so I can compile the scripts?

It would be cool if there was a way to have the scripts start in xml mode, instead of requiring an object or class definition. This way the script file would end being a pure xhtml file with scala code embedded in {} sections. But I do not think that is possible. I should be able to make it work with a few lines of boilerplate code at the start and end of the script file.

I would appreachiate any input.

The inspiration for this idea is to match PHPs extremely quick prototyping cycle. It simply takes too long to start up new project with maven and other heavy tools. We are competing against 20 lines of php code to do a quick job.

Thanks,

Baldur

vpatryshev
Joined: 2009-02-16,
User offline. Last seen 1 year 24 weeks ago.
Re: scala compiler api?
Probably what you are suggesting is something like jsp, but for scala (ssp?) One solution is suggested here. Although I would prefer tweaking Jasper, so that it could build and compile scala code.
 

2009/2/22 Baldur Norddahl <baldur.norddahl@gmail.com>
Hi,

I am looking for a way to use Scala in a "PHP" like fashion. I want to be able to drop in a scala script in a directory and instantly have that script available to process HTTP requests.

Thinking about this, I believe what is needed is a servlet that can be deployed on any servlet container such as Apache Tomcat. The servlet would accept requests and look in a script directory for scala scripts to process the request. If the request maps to a new script or the script has been modified since last request, it would compile the file before handing over the request.

Has anyone played with this idea before? If not, where can I find information about how to embed the scala compiler, so I can compile the scripts?

It would be cool if there was a way to have the scripts start in xml mode, instead of requiring an object or class definition. This way the script file would end being a pure xhtml file with scala code embedded in {} sections. But I do not think that is possible. I should be able to make it work with a few lines of boilerplate code at the start and end of the script file.

I would appreachiate any input.

The inspiration for this idea is to match PHPs extremely quick prototyping cycle. It simply takes too long to start up new project with maven and other heavy tools. We are competing against 20 lines of php code to do a quick job.

Thanks,

Baldur




--
Thanks,
-Vlad
Jorge Ortiz
Joined: 2008-12-16,
User offline. Last seen 29 weeks 4 days ago.
Re: scala compiler api?
In Lift-land we use Jetty and JavaRebel for quick prototyping. There are some limitations to what JavaRebel can reload, but most of the time it works remarkably well. JavaRebel generously provides a free license for use with Scala.

--j

On Sun, Feb 22, 2009 at 5:29 PM, Baldur Norddahl <baldur.norddahl@gmail.com> wrote:
Hi,

I am looking for a way to use Scala in a "PHP" like fashion. I want to be able to drop in a scala script in a directory and instantly have that script available to process HTTP requests.

Thinking about this, I believe what is needed is a servlet that can be deployed on any servlet container such as Apache Tomcat. The servlet would accept requests and look in a script directory for scala scripts to process the request. If the request maps to a new script or the script has been modified since last request, it would compile the file before handing over the request.

Has anyone played with this idea before? If not, where can I find information about how to embed the scala compiler, so I can compile the scripts?

It would be cool if there was a way to have the scripts start in xml mode, instead of requiring an object or class definition. This way the script file would end being a pure xhtml file with scala code embedded in {} sections. But I do not think that is possible. I should be able to make it work with a few lines of boilerplate code at the start and end of the script file.

I would appreachiate any input.

The inspiration for this idea is to match PHPs extremely quick prototyping cycle. It simply takes too long to start up new project with maven and other heavy tools. We are competing against 20 lines of php code to do a quick job.

Thanks,

Baldur


Michael
Joined: 2009-02-23,
User offline. Last seen 20 weeks 1 day ago.
Re: scala compiler api?

>
> Hi,I am looking for a way to use Scala in a "PHP" like fashion. I want to be
able to drop in a scala script in a directory and instantly have that script
available to process HTTP requests.

You might also want to have a look at Apache Sling
(http://incubator.apache.org/sling/site/index.html) which supports various
scripting languages. Just recently I added scripting support for Scala. Be
warned though, Scala support is currently still kind of experimental and there
is no official documentation yet.

Michael

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland