www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Developing a browser (Firefox) extension with D

reply Justin Johansson <no spam.com> writes:
I'm just wondering for a moment if D might be a good vehicle for 
developing a browser extension for Firefox, or any other browser for 
that matter.

Has anyone either considered doing, or has actually done, any browser 
extension development with D and have some thoughts or experience to share?

Thanks for all feedback,
Justin Johansson
Nov 17 2009
next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Justin Johansson" <no spam.com> wrote in message 
news:hdvrmr$215l$1 digitalmars.com...
 I'm just wondering for a moment if D might be a good vehicle for 
 developing a browser extension for Firefox, or any other browser for that 
 matter.

 Has anyone either considered doing, or has actually done, any browser 
 extension development with D and have some thoughts or experience to 
 share?

 Thanks for all feedback,
 Justin Johansson

I thought FF extensions were JS-only, is that not the case?
Nov 17 2009
next sibling parent Clay Smith <clay.smith.r gmail.com> writes:
Nick Sabalausky wrote:
 "Justin Johansson" <no spam.com> wrote in message 
 news:hdvrmr$215l$1 digitalmars.com...
 I'm just wondering for a moment if D might be a good vehicle for 
 developing a browser extension for Firefox, or any other browser for that 
 matter.

 Has anyone either considered doing, or has actually done, any browser 
 extension development with D and have some thoughts or experience to 
 share?

 Thanks for all feedback,
 Justin Johansson

I thought FF extensions were JS-only, is that not the case?

https://developer.mozilla.org/En/Creating_Custom_Firefox_Extensions_with_the_Mozilla_Build_System C/C++ works, I imagine D could with some effort.
Nov 17 2009
prev sibling parent Justin Johansson <no spam.com> writes:
Nick Sabalausky wrote:
 "Justin Johansson" <no spam.com> wrote in message 
 news:hdvrmr$215l$1 digitalmars.com...
 I'm just wondering for a moment if D might be a good vehicle for 
 developing a browser extension for Firefox, or any other browser for that 
 matter.

 Has anyone either considered doing, or has actually done, any browser 
 extension development with D and have some thoughts or experience to 
 share?

 Thanks for all feedback,
 Justin Johansson

I thought FF extensions were JS-only, is that not the case?

While extentions can be written/partly written in JS, the "system level" for extensions is C++. The FF code base is built on a single-threaded COM model (similar in theory but definitely not binary compatible with Microsoft COM). Think it's called NSCOM (as in Netscape). Components (aka objects) are managed with the usual AddRef/Release and interfaces found with the familiar QueryInterface (familiar that is if you have ever used MS COM). The basic interface of a component is NSIUnknown or similar. The methods of the NSIUnknown interface are AddRef, Release and QueryInterface. Such mechanism effectively implements a reference-counted garbage-collection strategy. As with a lot of COM development (in C++), people often resort to the use of so-called smart-pointers to hide/manage calls to AddRef and Release. So my guess/hunch is that if D is any good for writing MS COM applications, it might also be good for writing FF extensions. If it could be demonstrated that D was a good platform for writing FF extensions, that might be a boon for expanding D's "market acceptance".
Nov 17 2009
prev sibling next sibling parent reply Frank Benoit <keinfarbton googlemail.com> writes:
Justin Johansson schrieb:
 I'm just wondering for a moment if D might be a good vehicle for
 developing a browser extension for Firefox, or any other browser for
 that matter.
 
 Has anyone either considered doing, or has actually done, any browser
 extension development with D and have some thoughts or experience to share?
 
 Thanks for all feedback,
 Justin Johansson

As an extension, there might be more than one extension running in one Firefox process. Each extension written in D must bring in its own GC, here comes the problem. The GC is implemented in D using signals, which are global to the process. So if there are two D extensions, they will get confused by each other. This is also the reason, i give up about running D and Java in the same process. Also Java uses those signals for its own GC. But nevertheless, if you want to give it a try, the DWT firefox bindings might be of interest for you.
Nov 17 2009
parent reply Justin Johansson <no spam.com> writes:
Frank Benoit wrote:
 Justin Johansson schrieb:
 I'm just wondering for a moment if D might be a good vehicle for
 developing a browser extension for Firefox, or any other browser for
 that matter.

 Has anyone either considered doing, or has actually done, any browser
 extension development with D and have some thoughts or experience to share?

 Thanks for all feedback,
 Justin Johansson

As an extension, there might be more than one extension running in one Firefox process. Each extension written in D must bring in its own GC, here comes the problem. The GC is implemented in D using signals, which are global to the process. So if there are two D extensions, they will get confused by each other. This is also the reason, i give up about running D and Java in the same process. Also Java uses those signals for its own GC. But nevertheless, if you want to give it a try, the DWT firefox bindings might be of interest for you.

Hi Frank, Thanks for this very valuable information. I was soon to post about D interoperability with JNI (Java Native Interface), but sounds like as you say "D extensions" for Java could also be problematic. Okay if you are the only guy in there but big trouble if your "extension" is trying to co-exist with other "vendor" extensions in D. I am left wondering though, is this a permanent show-stopper for the future (technically) or could something, at least in theory, be worked out to overcome the GC issue? beers/commiserations Justin
Nov 18 2009
parent Frank Benoit <keinfarbton googlemail.com> writes:
Justin Johansson schrieb:
 Hi Frank,
 
 Thanks for this very valuable information.  I was soon to post about D
 interoperability with JNI (Java Native Interface), but sounds like as
 you say "D extensions" for Java could also be problematic.  Okay if you
 are the only guy in there but big trouble if your "extension" is trying
 to co-exist with other "vendor" extensions in D.

There might be also a problem if firefox or something else in the same process uses signals.
 
 I am left wondering though, is this a permanent show-stopper for the
 future (technically) or could something, at least in theory, be worked
 out to overcome the GC issue?

Perhaps start a child process and do inter process communication. For one of my application I use a Java GUI and then I start a D process and use stdin+stdout for JSON communication.
Nov 18 2009
prev sibling parent Jacob Carlborg <doob me.com> writes:
On 11/18/09 05:03, Justin Johansson wrote:
 I'm just wondering for a moment if D might be a good vehicle for
 developing a browser extension for Firefox, or any other browser for
 that matter.

 Has anyone either considered doing, or has actually done, any browser
 extension development with D and have some thoughts or experience to share?

 Thanks for all feedback,
 Justin Johansson

I think someone tried to do (or did) an extension for internet explorer using DWT.
Nov 18 2009