服务器端javascript实现的优缺点? [英] pros and cons of serverside javascript implementation?

查看:223
本文介绍了服务器端javascript实现的优缺点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始为我的下一个项目试用 Aptana Jaxer 服务器端javascript引擎。我对此几乎没有任何疑问

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


  • 通过使用服务器端JS,我们可以在不使用任何服务器端的情况下实现整个Web应用程序语言(如C#,java等)。或者服务器端JS位于Web服务器和其他语言堆栈之间。

  • 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.

它真的是一个更好的方法吗?

Is it really a better approach ??

什么是优惠和减价?

这是如何运作良好的性能?

how this works well in terms of performance?

是否有任何实时实施(公共网站)仅使用服务器端JS(没有其他语言)?

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

Aptana jaxer(开源)提供的替代方案有哪些?

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

我们的实施能力如何? maitain db交易?我们可以在服务器端JS中做到吗?

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

是否可以在服务器端JS中开发RESTFul和SOAP服务.. ??

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

我知道这太长了(天真的问题)。我只是希望有人在实现serverside JS时已经遇到过这些问题。

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

编辑:

根据Matthew&肯评论,我已经添加了一些清晰的问题它真的是一个更好的方法吗?

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..

这是一种比使用服务器端语言更好的方法(假设是c#),我们如何将它与网站的c#实现(性能,语言功能)进行比较? ?
哪一个是更好的方法,在服务器端单独使用JS或在其他语言堆栈和网络服务器之间的中间层使用JS?

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??

推荐答案

我是 Myna (www.mynajs.org)的开发者,这是一个开源服务器 - 基于Rhino和Java的JS平台。我将解决与Myna相关的问题,但其中许多要点一般适用于服务器端JS:

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:

使用服务器如果没有使用任何服务器端语言(如C#,java等),我们可以实现整个Web应用程序。或者服务器端JS位于Web服务器和其他语言堆栈之间。

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.

在Myna中可以用JS编写整个应用程序。 Myna已经包含了用于数据库访问,对象关系映射,crytogrophy,OpenID等的API。

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.

它真的比c#/ Java更好吗?

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

使用基于Rhino的服务器,只要需要,就可以轻松下载到Java。您可以轻松安装开源/商业/手动编码的Java库,然后从JS编写脚本。这意味着您可以快速开发JS但保持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?

专业人士:


  • 快速发展:在Myna中,您只需使用.sjs扩展名在webroot中创建文件。这意味着您可以创建一个编辑 - 保存 - 刷新浏览器周期,调试/调整代码非常快。

  • Rapid development: In Myna you just create files in the webroot with an .sjs extension. This means you can create an edit-save-refresh browser cycle with is very fast for debugging/tweaking code.

Easy JSON :拥有JS支持服务器端意味着移动复杂的结构非常容易

Easy JSON: Having JS support server-side means moving complex structures is very easy

共享代码:如果需要执行相同的操作在服务器和浏览器上运行,你可以使用相同的代码

Shared code: If you need to perform the the same function on both the server and the browser, you can use the same code

动态ORM :静态类型的编译语言让它变得困难在运行时更改对象。这通常意味着必须事先定义ORM。在Myna构建中,ORM非常简单

Dynamic ORM: Statically typed compiled languages make it hard to alter objects at runtime. This usually means that ORM has to be defined in advance. In Myna building ORM is as simple as

var manager =new Myna.DataManager("DataSource name").getManager("table name");

您可以获得一个可以执行所有基本CRUD操作的对象,而无需显式定义数据库表。作为另一个示例,您可以插入一个包含表单帖子中所有匹配值的行:

You get an object that can do all basic CRUD operations without ever explicitly defining the DB tables. As another example you can insert a row with all the matching values from a form post:

manager.create($req.data);


  • 功能编程:如果您已开始使用高级JavaScript功能,那么你会感谢他们在服务器端的帮助。由于服务器端环境一致,因此使用高级功能是安全的,例如 Array Extras 生成器和迭代器解构分配,以及 E4X

  • Functional Programing: If you have started playing with advanced JavaScript features then you will appreciate how helpful they are server-side. Because of the consistent server-side environment it is safe to use advanced features such as Array Extras, generators and iterators, destructuring assignments, and E4X

    缺点:


    • 工具:静态类型语言(如C#和Java)具有出色的IDE和开发人员工具。像JS这样的动态语言还没有工具支持。就个人而言,我发现样板代码和繁琐的类型转换的大量减少弥补了这一点,但如果你在IDE中进行了大量的开发,这仍然是一个很大的缺点。如果您当前正在使用IDE,请考虑使用 jedit 用于动态语言

    • Tools: Statically typed languages like C# and Java have excellent IDE and developer tools. Dynamic languages like JS just don't have the tool support yet. Personally I find that the large reduction in boilerplate code and fussy type casting makes up for this, but this is still a big disadvantage if you have been doing a lot of development in IDEs. If you are currently using an IDE, consider using jedit for dynamic languages

    成熟度/标准化:Serverside JS仍然是一个新的范例,有很多玩家而且没有明确的赢家。 ECMA对于服务器端JS没有任何标准。正如Brandon的回答中所提到的, CommonJS 小组正试图形成服务器端JS标准,而Myna已经通过独角鲸实验性的CommonJS支持

    Maturity/Standardization: Serverside JS is still a new paradigm, and there are many players and no clear winners. ECMA does not have any standards for serverside JS. As mentioned in Brandon's answer, the CommonJS group is attempting to form a serverside JS standard and Myna has experimental CommonJS support via Narwhal

    这在性能方面表现如何?

    how this works well in terms of performance?

    在原始计算速度方面,很少有动态语言可以匹配静态类型的编译语言,如C#和Java。话虽如此,这无关紧要。应用程序中计算密集的任何部分都应该用Java编写,或者使用现有的Java库。我不建议任何人在JS中编写数据库。对于真实的Web应用程序/ SOA服务,减速的主要原因不是原始计算速度,而是低效的代码,尤其是数据库访问。 Myna通过以下方式帮助解决这个问题:

    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:


    • 内部缓存已编译的JS脚本

    • 内部使用缓存准备好的数据库事务语句

    • 查询和输出片段缓存

    • 数据库连接池

    • 自动ETag哈希支持

    • 分析工具

    • 延迟加载元数据

    • internally caching compiled JS scripts
    • Internally using cached prepared statements for database transactions
    • Query and output fragment caching
    • Database connection pooling
    • Automatic ETag hash support
    • Profiling tools
    • Lazy loading of metadata

    我们如何实施&维护数据库事务?我们可以在服务器端JS中执行此操作吗?

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

    如果您的意思是一组可以撤消的SQL语句或承诺,然后Myna还不支持交易。如果有足够的兴趣,我愿意实现这个。

    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.

    如果你的意思是服务器端JS有什么样的数据库支持?然后答案是平台依赖的。 Myna平台提供以下数据库功能:

    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:


    • 基于Web的管理应用程序,您可以在其中定义数据源,即数据库连接信息。然后,您可以按名称查询这些数据源。 Myna包含用于H2,MySQL,Microsoft SQL Server和Postgresql的JDBC驱动程序,但可以使用任何JDBC或ODBC数据源

    • Myna.Database Myna.Table 提供数据库中立的元数据访问以及表创建和修改。

    • Myna的查询对象支持maxRows,分页,SQL参数,自定义行处理程序,查询查询,缓存等等

    • Myna的 DataManager 对象支持运行时ORM对象创建

    • A web-based administration application where you can define "datasources", i.e database connection information. You can then query these datasources by name. Myna includes JDBC drivers for H2, MySQL, Microsoft SQL Server, and Postgresql, but any JDBC or ODBC datasource can be used
    • Myna.Database and Myna.Table provide database-neutral metdata access as well as table creation and modification.
    • Myna's Query object supports maxRows, paging, SQL parameters,custom row handlers, query-of-query, caching and more
    • Myna's DataManager object supports runtime ORM object creation

    是否有可能在服务器端JS中开发RESTFul和SOAP服务。

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

    REST和SOAP支持是特定于平台的功能。 Myna的 WebService 对象支持以下协议:

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


    • SOAP

    • XML-RPC

    • JSON- RPC

    • Ext Direct

    • JSON-MYNA
      (使用普通表单帖子并返回JSON的简单协议。易于使用浏览器)

    • SOAP
    • XML-RPC
    • JSON-RPC
    • Ext Direct
    • JSON-MYNA (a simple protocol that uses normal form posts and returns JSON. Easy to use from the browser)

    Myna还了解PUT和DELETE请求方法,并以文本和二进制形式呈现对请求正文内容的访问权限,以便可以以特定于应用程序的方式处理这些RESTful方法。

    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

    传统的断点调试是一个真正的挑战服务器。虽然Rhino支持调试器挂钩,但是使用来自无状态Web应用程序的挂钩非常复杂。就个人而言,我甚至没有使用断点调试器,即使它们可用(例如萤火虫)。相反,我更喜欢伐木。

    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.

    在Myna中,

     Myna.log(type,label,detail)
    

    将产生一个低优先级线程,将HTML日志消息写入Myna的日志记录数据库。然后可以通过Myna管理员搜索这些日志。日志还记录用于分析目的的时间戳和经过的毫秒数。 Myna.dump(obj)也可用于呈现任何对象的HTML表格表示。 Myna还使用堆栈跟踪,源代码上下文和请求详细信息记录所有未处理的异常。在dump(),log()和默认错误处理程序之间我调试Myna代码没有太大困难

    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

    这篇关于服务器端javascript实现的优缺点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆