serverside javascript - translation to PHP

Discussion in 'Javascript' started by roman, Nov 25, 2008.

  1. roman

    roman Guest

    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
     
    roman, Nov 25, 2008
    #1
    1. Advertising

  2. roman

    Erwin Moller Guest

    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
     
    Erwin Moller, Nov 25, 2008
    #2
    1. Advertising

  3. roman

    Evertjan. Guest

    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.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Nov 25, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rotsey
    Replies:
    1
    Views:
    412
    Rotsey
    Dec 20, 2006
  2. Replies:
    2
    Views:
    340
    Simon Brooke
    Nov 18, 2006
  3. Rajive Narain
    Replies:
    0
    Views:
    2,077
    Rajive Narain
    Sep 18, 2009
  4. Robert Mark Bram

    Serverside javascript and vbscript on same page?

    Robert Mark Bram, Aug 15, 2004, in forum: ASP General
    Replies:
    4
    Views:
    237
    Evertjan.
    Aug 15, 2004
  5. eastcoastguyz
    Replies:
    1
    Views:
    123
    Flamer
    Jul 11, 2006
Loading...

Share This Page