javascriptserverside-javascriptjaxer

pros and cons of serverside javascript implementation?


I just started experimenting with Aptana Jaxer server side javascript engine for my next project. And i have few quesions about that

i know this is too long (and naive questions). I am just hoping someone have already come across all these while implementing serverside JS.

EDIT:

As per Matthew & Ken comments, i have added some clarity to the question Is it really a better approach??

this is what i intend to ask..

Is it really a better approach than using server side languages (assume c#), how we can compare this with the c# implementation of a website (performance , language features)?? And which one is a better approach , using JS alone in serverside or JS in middle layer between other language stack and webserver??


Solution

  • I am the developer for Myna (www.mynajs.org), an Open Source server-side JS platform based on Rhino and Java. I'll address the issues as they relate to Myna, but many of these points apply to server-side JS in general:

    By using server side JS, can we implement the whole web application without using any server side languages (like C#,java etc). Or server side JS sits in between the web server and other langauge stack.

    In Myna it is possible to write your entire app in JS. Myna already includes API's for Database access, Object Relational Mapping, crytogrophy, OpenID, etc.

    Is it really a better approach than c#/Java?

    With a Rhino based server it is trivial to drop down to Java whenever needed. You can easily install open-source/commercial/hand-coded Java libraries and then script them from JS. This means you get the rapid development of JS but maintain the advantages of the Java platform

    what are the advantages and disadvantages?

    pros:

    cons:

    how this works well in terms of performance?

    In raw computational speed, few dynamic languages can match statically typed compiled languages like C# and Java. Having said that, it really doesn't matter. Any part of your application that is computationally intensive should probably be written in Java, or use an existing Java library. I wouldn't suggest that anyone write a Database in JS for instance. For real world web applications/SOA services, the primary cause of slowdowns isn't raw computational speed, it is inefficient code, especially database access. Myna helps with this by doing things like:

    how well we can implement & maintain db transactions? can we do that in serverside JS..?

    If you mean transaction as in "a set of SQL statements that can be reversed or committed", then Myna does not yet support transactions. I am open to implementing this if there is enough interest.

    If you mean "what kind of database support does server-side JS have?" then the answer is platform dependent. The Myna platform provides the following database features:

    is it possible to develop RESTFul and SOAP services in serverside JS..??

    REST and SOAP support are platform specific features. Myna's WebService object supports the following protocols:

    Myna also understands the PUT and DELETE request methods and presents access to request body content in both text and binary form, so that it is possible to handle these RESTful methods in an application specific way.

    Debugging

    Traditional breakpoint debugging is a real challenge serverside. Although Rhino supports debugger hooks, using these from a stateless web app would be pretty involved. Personally I don't even use breakpoint debuggers even when they are available (e.g. firebug). Instead I prefer logging.

    In Myna,

     Myna.log(type,label,detail)
    

    will spawn a low priority thread to write an HTML log message to Myna's logging database. These logs can then be searched through the Myna Administrator. Logs also record timestamps and elapsed milliseconds for profiling purposes. Myna.dump(obj) can also be used to present an HTML table representation of any object. Myna also logs all un-handled exceptions with stack traces, source code context, and request details. Between dump(), log(), and the default error handler I haven't much difficulty debugging Myna code