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

Firefox plug-in for Scala?

4 replies
christopherbalz
Joined: 2009-09-11,
User offline. Last seen 3 years 7 weeks ago.

If Scala could live in a Firefox plug-in, it could use the browser's DOM and avoid many issues that have plagued Java applets. It would also be a step toward offering a much-needed alternative to or replacement for JavaScript.

Where can I find out more on Scala, Scala-to-C++, and Scala + w3.org DOM Level 3? Thank you in advance.

christopherbalz
Joined: 2009-09-11,
User offline. Last seen 3 years 7 weeks ago.
Firefox plug-in for Scala?

If Scala could live in a Firefox plug-in, it could use the browser's DOM and avoid many issues that have plagued Java applets. It would also be a step toward offering a much-needed alternative to or replacement for JavaScript.

Where can I find out more on Scala, Scala-to-C++, and Scala + w3.org DOM Level 3? Thank you in advance.

Johannes Rudolph
Joined: 2008-12-17,
User offline. Last seen 29 weeks 20 hours ago.
Re: Firefox plug-in for Scala?

On Sat, Sep 12, 2009 at 12:55 AM, Christopher M. Balz
wrote:
> If Scala could live in a Firefox plug-in, it could use the browser's DOM and avoid many issues that have plagued Java applets.  It would also be a step toward offering a much-needed alternative to or replacement for JavaScript.

Actually, you can do something like this with a Java applet. See
http://code.google.com/p/ruby-in-browser/ for an example how to do
this with JRuby. In theory this scheme works for Scala as well.
But: Scala is in many respects no scripting language, one reason
being, that there is no light-weight way going from Scala source to
execution. (In this sense the JRuby compiler isn't light-weight
neither, but since Ruby is a script language by definition, it copes
much better with script-y environments).
Though, light-weight-ness is a relative matter that may lose it's
significance with upcoming processor generations and more memory
available at the client's computers.

> Where can I find out more on Scala, Scala-to-C++, and Scala + w3.org DOM Level 3?  Thank you in advance.
For the full fledged Scala support you are striving for, you should
look for a Java-XPCOM bridge, it should be possible to host a JVM in
firefox which runs a component that implements XPCOM interfaces and so
provides functionality to firefox. (Much of firefox is written in a
way in which XPCOM interfaces are implemented with Javascript code.
This should be possible similarly for (compiled) Java code)

Alternative solutions aside from writing firefox code:
* Use Scala to Javascript compilation before sending a page to the
client (=browser). The lift framework contains several functions for
generating Javascript code.
* Develop a scheme where web pages are preprocessed before
publishing. The preprocessing extracts scala script tags and compiles
them into Javascript code. (compiler-plugin? or clever tricks with
scala.reflect.Code or something similar)

Hope I could give some hints.

christopherbalz
Joined: 2009-09-11,
User offline. Last seen 3 years 7 weeks ago.
Re: Firefox plug-in for Scala?

Thanks Johannes, this is fascinating stuff. In my experience, client-side JavaScript is moving steadily away from its scripting roots. So I think a solution such as Scala, which (I read in the Scala doc; have not learned Scala yet) can offer some ease over Java at certain levels, could be a success on the Web browser. Currently on the web client we wonder about things such as using the 'canvas' tag as a byte array, and so forth. It would be nice to have a second-generation Web language, as awesome as JavaScript has been.

I like the Java applet approach, as long as it can be done without triggering the compatibility issues I've seen with those. It seems like that might be possible as long as no graphical Java libraries were loaded. It would seem that machine power would grow enough by the time a new client-side language could be adopted to replace JavaScript that a JVM approach would be feasible . . . as long as the JVM does not grow commensurately.

Generated code can be so hard to debug (of course) and often, because of tricky dom gui bugs, code has to be debugged as it rusn in the Web browser. So I don't favor the translator-compiler solution. Although, systems such as GWT are very impressive.

Thank you so much and I will have to check out the Ruby-in-browser project and the Java-XPCOM bridget in Firefox!

- cb

". . . / This Cabinet is formd of Gold / And Pearl & Crystal shining bright And within it opens into a World / . . .
Another England there I saw / Another London with its Tower Another Thames & other Hills / And another pleasant Surrey Bower . . ."
- from "The Crystal Cabinet", a poem by William Blake, in original spelling & grammar.

________________________________
From: Johannes Rudolph
To: christophermbalz [at] stanfordalumni [dot] org
Cc: scala-debate [at] listes [dot] epfl [dot] ch
Sent: Saturday, September 12, 2009 1:56:23 AM
Subject: Re: [scala-debate] Firefox plug-in for Scala?

On Sat, Sep 12, 2009 at 12:55 AM, Christopher M. Balz
wrote:
> If Scala could live in a Firefox plug-in, it could use the browser's DOM and avoid many issues that have plagued Java applets. It would also be a step toward offering a much-needed alternative to or replacement for JavaScript.

Actually, you can do something like this with a Java applet. See
http://code.google.com/p/ruby-in-browser/ for an example how to do
this with JRuby. In theory this scheme works for Scala as well.
But: Scala is in many respects no scripting language, one reason
being, that there is no light-weight way going from Scala source to
execution. (In this sense the JRuby compiler isn't light-weight
neither, but since Ruby is a script language by definition, it copes
much better with script-y environments).
Though, light-weight-ness is a relative matter that may lose it's
significance with upcoming processor generations and more memory
available at the client's computers.

> Where can I find out more on Scala, Scala-to-C++, and Scala + w3.org DOM Level 3? Thank you in advance.
For the full fledged Scala support you are striving for, you should
look for a Java-XPCOM bridge, it should be possible to host a JVM in
firefox which runs a component that implements XPCOM interfaces and so
provides functionality to firefox. (Much of firefox is written in a
way in which XPCOM interfaces are implemented with Javascript code.
This should be possible similarly for (compiled) Java code)

Alternative solutions aside from writing firefox code:
* Use Scala to Javascript compilation before sending a page to the
client (=browser). The lift framework contains several functions for
generating Javascript code.
* Develop a scheme where web pages are preprocessed before
publishing. The preprocessing extracts scala script tags and compiles
them into Javascript code. (compiler-plugin? or clever tricks with
scala.reflect.Code or something similar)

Hope I could give some hints.

Justin du coeur
Joined: 2009-03-04,
User offline. Last seen 42 years 45 weeks ago.
Re: Firefox plug-in for Scala?
Those looking for more inspiration about how better languages can be used in the browser should take a look at the Gestalt project:

http://visitmix.com/labs/gestalt/

This is a clever and astonishing toy, that leverages Silverlight to allow you to use any Silverlight language (Ruby, Python, XAML, etc) directly inside browser pages, with direct access to the DOM.  Something akin to this, using Scala, would be pretty much the coolest thing ever, IMO.  I suspect it's a *big* project, but this at least serves as a bit of proof-of-concept...

On Sun, Sep 13, 2009 at 8:58 PM, Christopher M. Balz <christophermbalz [at] stanfordalumni [dot] org> wrote:
Thanks Johannes, this is fascinating stuff.  In my experience, client-side JavaScript is moving steadily away from its scripting roots.  So I think a solution such as Scala, which (I read in the Scala doc; have not learned Scala yet) can offer some ease over Java at certain levels, could be a success on the Web browser.  Currently on the web client we wonder about things such as using the 'canvas' tag as a byte array, and so forth.  It would be nice to have a second-generation Web language, as awesome as JavaScript has been.

I like the Java applet approach, as long as it can be done without triggering the compatibility issues I've seen with those.  It seems like that might be possible as long as no graphical Java libraries were loaded.  It would seem that machine power would grow enough by the time a new client-side language could be adopted to replace JavaScript that a JVM approach would be feasible . . . as long as the JVM does not grow commensurately.

Generated code can be so hard to debug (of course) and often, because of tricky dom gui bugs, code has to be debugged as it rusn in the Web browser.  So I don't favor the translator-compiler solution.  Although, systems such as GWT are very impressive.

Thank you so much and I will have to check out the Ruby-in-browser project and the Java-XPCOM bridget in Firefox!

 - cb

". . . / This Cabinet is formd of Gold / And Pearl & Crystal shining bright And within it opens into a World / . . .
Another England there I saw / Another London with its Tower Another Thames & other Hills / And another pleasant Surrey Bower . . ."
- from "The Crystal Cabinet", a poem by William Blake, in original spelling & grammar.

________________________________
From: Johannes Rudolph <johannes [dot] rudolph [at] googlemail [dot] com>
To: christophermbalz [at] stanfordalumni [dot] org
Cc: scala-debate [at] listes [dot] epfl [dot] ch
Sent: Saturday, September 12, 2009 1:56:23 AM
Subject: Re: [scala-debate] Firefox plug-in for Scala?

On Sat, Sep 12, 2009 at 12:55 AM, Christopher M. Balz
<christophermbalz [at] stanfordalumni [dot] org> wrote:
> If Scala could live in a Firefox plug-in, it could use the browser's DOM and avoid many issues that have plagued Java applets.  It would also be a step toward offering a much-needed alternative to or replacement for JavaScript.

Actually, you can do something like this with a Java applet. See
http://code.google.com/p/ruby-in-browser/ for an example how to do
this with JRuby. In theory this scheme works for Scala as well.
But: Scala is in many respects no scripting language, one reason
being, that there is no light-weight way going from Scala source to
execution. (In this sense the JRuby compiler isn't light-weight
neither, but since Ruby is a script language by definition, it copes
much better with script-y environments).
Though, light-weight-ness is a relative matter that may lose it's
significance with upcoming processor generations and more memory
available at the client's computers.

> Where can I find out more on Scala, Scala-to-C++, and Scala + w3.org DOM Level 3?  Thank you in advance.
For the full fledged Scala support you are striving for, you should
look for a Java-XPCOM bridge, it should be possible to host a JVM in
firefox which runs a component that implements XPCOM interfaces and so
provides functionality to firefox. (Much of firefox is written in a
way in which XPCOM interfaces are implemented with Javascript code.
This should be possible similarly for (compiled) Java code)

Alternative solutions aside from writing firefox code:
* Use Scala to Javascript compilation before sending a page to the
client (=browser). The lift framework contains several functions for
generating Javascript code.
* Develop a scheme where web pages are preprocessed before
publishing. The preprocessing extracts scala script tags and compiles
them into Javascript code. (compiler-plugin? or clever tricks with
scala.reflect.Code or something similar)

Hope I could give some hints.

--
Johannes

-----------------------------------------------
Johannes Rudolph
http://virtual-void.net

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