serverside javascript - translation to PHP

R

roman

Hello everybody,

I am working on application that will contain a shared portion running
on server and client and would like to be able to deploy on LAMP.

Looked at jsext, jslibs and wsjs and standalone SpiderMonkey. They are
all very nice, some even compile out of the box. But all need CGI or
FCGI, or own box (physical/virtual) + mod_js, since not many webhosts
yet support JavaScript and I doubt they just install it on request (I am
talking about cheapo shared hostings).

Another alternative is translation to supported environment. I found
J4P5 - it comes with parser and runtime (in PHP). Project seems
abandoned but it's very serious attempt very close to completion. It did
not work out of the box, but after few modifications in P4P5 runtime I
was able to run my routines with same testing results in browser and in
J4P5.

It's 100-150x slower than PHP, i.e. a lookup in some 200 member array
that took ~3ms with PHP was ~400ms in J4P5. Translation of 700 lines of
tables/code took 1.2sec, but this is done only first time after JS
source changes. Changing the table lookups to binary search made this
some 20x faster (average 20ms) - fairly workable. Of course this is not
usable for writing entire applications but until JS becomes as native on
servers as PHP, this may be the transition tool.

My code will not run with every HTTP request but only with final
request, when untrusted data from browser is received and must be
verified if it was not tampered.

I am looking for input. Can someone recommend better solution? Anyone
deployed similar system before? What are security implications (e.g.
user will be able to review non-critical portions of the business
logic), perhaps I did not think of something. I am aware of P4P5
licensing and at this point I do not mind my app to be GPL'd.

Thanks for your time.

Roman
 
E

Erwin Moller

roman schreef:
Hello everybody,

I am working on application that will contain a shared portion running
on server and client and would like to be able to deploy on LAMP.

Looked at jsext, jslibs and wsjs and standalone SpiderMonkey. They are
all very nice, some even compile out of the box. But all need CGI or
FCGI, or own box (physical/virtual) + mod_js, since not many webhosts
yet support JavaScript and I doubt they just install it on request (I am
talking about cheapo shared hostings).

Another alternative is translation to supported environment. I found
J4P5 - it comes with parser and runtime (in PHP). Project seems
abandoned but it's very serious attempt very close to completion. It did
not work out of the box, but after few modifications in P4P5 runtime I
was able to run my routines with same testing results in browser and in
J4P5.

It's 100-150x slower than PHP, i.e. a lookup in some 200 member array
that took ~3ms with PHP was ~400ms in J4P5. Translation of 700 lines of
tables/code took 1.2sec, but this is done only first time after JS
source changes. Changing the table lookups to binary search made this
some 20x faster (average 20ms) - fairly workable. Of course this is not
usable for writing entire applications but until JS becomes as native on
servers as PHP, this may be the transition tool.

My code will not run with every HTTP request but only with final
request, when untrusted data from browser is received and must be
verified if it was not tampered.

I am looking for input. Can someone recommend better solution? Anyone
deployed similar system before? What are security implications (e.g.
user will be able to review non-critical portions of the business
logic), perhaps I did not think of something. I am aware of P4P5
licensing and at this point I do not mind my app to be GPL'd.

Thanks for your time.

Roman

Hi Roman,



I think you have 2 obvious options:
1) Serverside PHP:
Why do you demand serverside JavaScript for your application?
Wouldn't it be easier to do it in PHP5 right away? It is supported
everywhere and can do anything JavaScript can (I think).

2) Stick with serverside JavaScript.
This leads to limitted hostingoptions as you said.
Or J4P5:
That project J4P5 looks very dead indeed.
Personally, I wouldn't bet on such a project: Judging by the number of
answered questions in their forum (0) one expects little to none from
the team for future development and bugfixing, or even answering
questions. So you'll have to do it yourself (and fix the sourcecode),
which means a lot of studying and testing. Well, who knows, maybe you
are the ONE that reignites the J4P5 project then, as maindeveloper. ;-)

I would pick option 1, but I love PHP at my server, so I am biased.

Just my 2 cent.

Regards,
Erwin Moller


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
E

Evertjan.

Erwin Moller wrote on 25 nov 2008 in comp.lang.javascript:
I think you have 2 obvious options:
1) Serverside PHP:
Why do you demand serverside JavaScript for your application?
Wouldn't it be easier to do it in PHP5 right away? It is supported
everywhere and can do anything JavaScript can (I think).

2) Stick with serverside JavaScript.
This leads to limitted hostingoptions as you said.
Or J4P5:
That project J4P5 looks very dead indeed.
Personally, I wouldn't bet on such a project: Judging by the number of
answered questions in their forum (0) one expects little to none from
the team for future development and bugfixing, or even answering
questions. So you'll have to do it yourself (and fix the sourcecode),
which means a lot of studying and testing. Well, who knows, maybe you
are the ONE that reignites the J4P5 project then, as maindeveloper. ;-)

I would pick option 1, but I love PHP at my server, so I am biased.

Indeed, Erwin. ;-)

I would use an classic ASP enabled server,
where the use of serverside Jscript is easy and well rooted.

The hosting is not that limited,
as you would need only one host.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top