node.js是传统脚本语言(如Perl和Python)的可行替代方案吗? [英] Is node.js a viable alternative to traditional scripting languages like Perl and Python?

查看:168
本文介绍了node.js是传统脚本语言(如Perl和Python)的可行替代方案吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我已经不再喜欢Perl作为跨平台的通用脚本语言了,而且Python和Ruby也没有真正吸引过我。



但是我在浏览器中越来越习惯使用JavaScript,它在V8等现代引擎中的表现相当不错,而node.js现在已经真正起飞了几年。



但node.js主要用于服务器端网络编程。正如它在其主页上声明的那样:


基于V8的事件驱动的I / O服务器端JavaScript环境。


我想知道node.js目前是否也适合作为* nix和Windows上的通用脚本语言,作为Perl,Python和Ruby。



我没有太多谈论以这种方式使用它但它似乎有一个广泛的社区,我没有注意到任何说它不是适合这种用途。这种方式被广泛使用吗?或者它缺少这类事物的关键特性或模块?

解决方案

就Node.js而言,我不能看到它成为使用javascript作为通用脚本语言的主流方式。主要原因是Node.js中99%的库和函数的异步性质。由于异步性质,你必须完全改变你的想法。没有可用的同步方法是绊脚石。它会减少脚本,因为你的代码不再是线性的。



因此,大多数时候你会想到采用的原因并非如此:I可以在Ruby / Python / ...中更快/更简单地写这个(只需尝试下载5个不同的文件,压缩它们并使用Node.js将它们复制到另一个文件夹)



<随着人们越来越习惯于以异步方式思考和编程,将node.js作为通用脚本工具的采用可能会发生变化。



如果节点中的每个异步函数都是如此有一个同步版本,采用会有所不同,人们最终会得到不可扩展的node.js服务器,因为他们选择在地方使用同步方法。可以说,节点不会变得流行,因为性能数字不会让它脱颖而出。



简而言之:



正在发生node.js,因为它具有异步特性。
采用node.js作为客户端通用脚本工具没有发生,因为它缺乏同步功能。



请记住,这是基于我自己的经验和意见,而不是我在互联网上找到的文章或数字,所以请亲自尝试并弥补你的自己的意见。


Recently I've fallen out of love with Perl as a cross-platform general purpose scripting language, and niether Python nor Ruby ever really appealed to me either.

But I've been getting more and more comfortable with JavaScript in the browser, it's getting pretty good performance in contemporary engines such as V8, and node.js has been really taking off for a couple of years now.

But node.js is intended for server side networking programming primarily. As it declares itself on its homepage:

Event-driven I/O server-side JavaScript environment based on V8.

I would like to know if node.js is also currently suitable as a general scripting language on *nix and Windows as an alternative to Perl, Python, and Ruby.

I don't find much talk of it being used in this way yet it does seem to have a broad community and I haven't noticed anything saying it's not suitable for this use. Is it widely used this way? Or does it lack key features or modules for this type of thing?

解决方案

In terms of Node.js, I can't see it becoming a mainstream way of using javascript as a general purpose scripting language. The main reason for that would be the async nature of 99% of the libraries and functions available in Node.js. Because of the async nature, you have to completely change your thinking. Not having synchronous methods available is the stumbling block. It makes things less script like as your code is not linear anymore.

So the adoption is not happening for the simple reason that most of the time you're thinking: I could write this a lot quicker/simpler in Ruby/Python/... (just try downloading 5 different files, zipping them and copying them to another folder using Node.js)

As people get more used to thinking and programming in an async way adoption of node.js as a general purpose scripting tool might change.

If every async function in node had a synchronous version, adoption would have been different and people would have ended up with non scalable node.js servers because they choose to use sync methods in places. Arguably, node would not have become popular as the performance numbers wouldn't have made it stand out.

In short:

adoption of node.js is happening because of it's async nature. adoption of node.js as a client side general purpose scripting tool is not happening due it's lack of synchronous functions.

Please keep in mind that this is based on my own experience and opinion and not on articles or numbers I found on the internet so try it out for yourself and make up your own opinion.

这篇关于node.js是传统脚本语言(如Perl和Python)的可行替代方案吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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