简体   繁体   English

Javascript作为通用语言?

[英]Javascript as a general purpose language?

In a weekend geek seminar I attended, several instructors extolled the virtues of Javascript. 在我参加的一个周末极客研讨会上,几位讲师赞美了Javascript的优点。 I've used Javascript to some extent, but their enthusiasm caused me to want to step a little closer. 我在某种程度上使用过Javascript,但是他们的热情使我想要更接近一点。

I've learned bits-and-pieces about Rhino & SpiderMonkey. 我学到了关于Rhino和SpiderMonkey的点点滴滴。 I know about server-side scripting & the restrictions placed on local file access (and the reasons why). 我知道服务器端脚本和对本地文件访问的限制(以及原因)。

I wondered if Javascript would ever take it's place alongside perl and python as a general purpose language? 我想知道Javascript是否会将它与perl和python一起作为通用语言? Not b/c there is any lacking in the languages that exist, but simply for those skilled in its use to broaden the scope of their reach. 不是b / c存在任何缺乏的语言,而仅仅是为了扩大其覆盖范围的技术人员。

I'm not so interested in a prediction of the future as I am about the current possibilities, the barriers in the way, and what's on the near-term table that might make this more of a reality. 我对未来的预测并不那么感兴趣,因为我关注当前的可能性,障碍,以及近期表格中可能使这更成为现实的内容。

Are some of you perhaps using the language in such way now? 你们当中有些人现在可能会以这种方式使用这种语言吗? Shell scripting, local apps, etc.? Shell脚本,本地应用程序等?

If so, how are you working around the issues of local file access and other things, such as databases? 如果是这样,您如何解决本地文件访问和其他问题,如数据库?

Server-side Javascript doesn't have the restrictions on file access that client-side Javascript has. 服务器端Javascript没有客户端Javascript所具有的文件访问限制。

Look at the node.js project for some inspiration. 查看node.js项目以获得一些灵感。

I haven't used it, but JSLibs - http://code.google.com/p/jslibs/ - aims to be a way to get javascript running as a general purpose scripting language. 我没有使用它,但JSLibs - http://code.google.com/p/jslibs/ - 旨在成为一种将javascript作为通用脚本语言运行的方法。

"Jslibs is a standalone JavaScript development runtime environment for using JavaScript as a general-purpose scripting language." “Jslibs是一个独立的JavaScript开发运行时环境,用于将JavaScript用作通用脚本语言。”

Of course, with new developments like Google's Web Apps, web apps, written in JavaScript, start to become more like desktop apps, written in Python and other languages (if that's what you're after). 当然,随着像Google的Web应用程序这样的新开发,用JavaScript编写的网络应用程序开始变得更像桌面应用程序,用Python和其他语言编写(如果这就是你所追求的)。 For instance, Chrome 7(?)+ has an about:labs feature named Background WebApps: 例如,Chrome 7(?)+有一个名为Background WebApps的about:labs功能:

"Allows installed web apps to run in the background at system startup and continue running after all windows are closed." “允许已安装的网络应用程序在系统启动时在后台运行,并在所有窗口关闭后继续运行。”

And new features like the HTML5 File API also allow closer integration with the desktop, allowing you to do more from JavaScript in a web app than before. HTML5 File API等新功能还允许与桌面更紧密地集成,使您可以在Web应用程序中使用JavaScript做更多的事情。 There are still restrictions on these features, and not all browsers implement them, but they allow you to do more with just JavaScript in a browser. 这些功能仍有限制,并非所有浏览器都实现这些功能,但它们允许您在浏览器中使用JavaScript执行更多操作。

Google Chrome OS also does this - now all the applications are just web applications, built on HTML, JavaScript, etc. This is still in the future, however. 谷歌Chrome OS也可以做到这一点 - 现在所有的应用程序都只是基于HTML,JavaScript等的Web应用程序。但是,这仍然是未来。

EDIT: I remembered some other ways to get JavaScript on the desktop. 编辑:我记得在桌面上获取JavaScript的其他一些方法。

QtWebkit - part of Qt - allows you to embed webkit in a Qt application, along with JavaScript. QtWebkit - Qt的一部分 - 允许您将JavaScript包与JavaScript一起嵌入到Qt应用程序中。

Appcelerator Titanium ( http://www.appcelerator.com/ ) allows you to make desktop applications with HTML, CSS, JavaScript, Python, Ruby, and PHP, is cross-platform, is actively developed and used, and generally seems nice. Appcelerator Titanium( http://www.appcelerator.com/ )允许您使用HTML,CSS,JavaScript,Python,Ruby和PHP制作桌面应用程序,跨平台,积极开发和使用,并且通常看起来不错。

Adobe AIR ( http://www.adobe.com/products/air/ ) is similar to Titanium in its concepts. Adobe AIR( http://www.adobe.com/products/air/ )在概念上类似于Titanium。

All of these are ways to basically integrate web apps into the desktop. 所有这些都是将Web应用程序基本集成到桌面的方法。

You can use node.js for server side development. 您可以使用node.js进行服务器端开发。 It is pretty neat. 它非常整洁。 You can also use Rhino , both to integrate with Java or to have freeform scripts. 您还可以使用Rhino ,既可以与Java集成,也可以使用自由格式脚本。 Here is an example of a Rhino script that reads in a file. 以下是读取文件的Rhino脚本示例。

At least in the circles that I follow it seems that JavaScript is becoming incredibly popular thanks to node.js. 至少在我关注的圈子中,由于node.js,JavaScript似乎变得非常受欢迎。 The fact that almost everyone has done some level of JS development appeals to people. 几乎每个人都做过某种程度的JS开发的事实都吸引了人们。

Firefox is partly written in Javascript (the GUI if I remember well). Firefox部分用Javascript编写(如果我记得很清楚的话,GUI)。 So yes, someone used it as a general purpose language. 是的,有人用它作为通用语言。

有一个新的替代方案,在桌面上使用javascript -webkit带来(nodejs本机模块和模块系统+ node-webkit v8 C ++绑定功能+ GUI API)到chrome envirement

I do most of my general scripting these days using rhino. 这些天我使用rhino执行大部分通用脚本编写。 As a java dev, I find it gives me the best of both worlds. 作为一个java开发者,我发现它给了我两全其美。 The flexibility of javascript, and the libs I'm familiar with when I need them. javascript的灵活性,以及​​我需要时熟悉的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM