pros and cons of serverside javascript implementation?

后端 未结 3 1158
半阙折子戏
半阙折子戏 2020-12-07 23:40

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

  • By using server side JS

3条回答
  •  情书的邮戳
    2020-12-08 00:03

    By using server side JS, can we implement the whole web application without using any server side languages (like C#,java etc).

    It shouldn't be necessary to write code in any other languages, although many server-side JavaScript frameworks use the Rhino engine, which allows you to call any Java code.

    Is it really a better approach??

    I don't think JavaScript (as a language) is really a better or worse option than traditional server-side languages. It has advantages (along with other dynamic languages like Ruby and Python) like flexibility, fast prototyping (no pun intended), flexibility, etc. On the other hand, it doesn't have the library support that Java and C# have or static typing (I won't get into the debate over which is better here; I like both for different reasons).

    If you want the best of both, you can use JavaScript as a scripting language, embedded in your application. Rhino for Java, and JScript.NET make it easy to manipulate "native" objects in JavaScript. You could, for example, write your domain classes in Java or C#, and script them with JavaScript where you want more flexibility. If you are comfortable enough with JavaScript, writing in a single language may be simpler though.

    I've never written a "real" server-side application using JavaScript, so I can't really make a judgment about whether its better or worse than .NET (I've also never used JScript.NET). I have played around with a few frameworks for fun though and I'm currently rewriting my personal site using Helma NG. So far it's been a good experience (much better than PHP, which I've never really liked).

    what are the advandages and disadvandages?

    Advantanges:

    • Only one language needed for server-side and client-side programming.
    • Possibility for shared code, for things like form validation. Jaxer lets you run scripts on the client, server, or both.
    • You get to program in JavaScript (assuming you like the language).

    Disadvantages:

    • Many frameworks are experimental/not very mature.
    • You have to program in JavaScript (assuming you don't like the language).

    how this works well in terms of performance?

    Performance should be approximately comparable to other scripting languages.

    is there any real time implementation (public websites) only using server side JS(no other languages)?

    I don't know of any large websites using JavaScript, but there may be some.

    what are the alternatives available over Aptana jaxer (open source)??

    Wikipedia has a large list of options, but it doesn't have much useful information. There are lots of options with a wide range in maturity and size.

    Here are a few that I'm familiar with (to varying degrees)

    • Helma - Rhino (Java) based framework with active record.
    • Helma NG - Helma Next Generation (experimental rewrite, under active development).
    • Phobos - Has good support in NetBeans.
    • v8cgi - Small and simple, uses Google's V8 engine, probably not production-ready yet.
    • Jaxer - Runs on Spidermonkey with a DOM implementation, so you can manipulate the page with frameworks like jQuery or Prototype. Has good IDE support in Aptana Studio.

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

    Rhino-based frameworks let you use Java classes, so you have full JDBC support. I haven't used Jaxer's database libraries, so I don't know anything about its capabilities.

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

    RESTful APIs shouldn't be any problem. I don't know of any specific support for SOAP, but it should be possible.

提交回复
热议问题