node.js/[我自己的库/插件]如何在 v8 上运行?

发布于 2024-11-04 12:54:33 字数 477 浏览 0 评论 0 原文

它是否使用这样的库:

http://code.google.com/p/v8-juice

http://ui.ajax.org/#o3

https://github.com/tsa/vu8

或者它编写了自己的库?如果 v8 是为了执行 javascript 而编写的,为什么 Node.js 库使用 C 代码?只是为了文件系统/事件的东西?如果是这样,为什么这是必要的,v8 本身不需要事件和文件系统内容吗?

如果我想使用仅支持 C api 的数据库,我该怎么做?现在我可能会写一个 v8-juice 插件。

Does it use any libraries like this:

http://code.google.com/p/v8-juice

http://ui.ajax.org/#o3

https://github.com/tsa/vu8

Or has it written its own libraries? If v8 is written for executing javascript, why do node.js libraries use C code? Just for the filesystem/event stuff? If so, why was that necessary, doesn't v8 need events and filesystem stuff itself?

If I want to work with a database that only supports a C api, how would I go about doing that? Right now I'd probably write a v8-juice plugin.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

败给现实 2024-11-11 12:54:33

node.js 包含它自己的 v8 嵌入式版本(不确定它是否是定制的,但可能是)。

Javascript 本身不提供文件系统 I/O 等接口,因此作为嵌入者(在本例中为节点)必须提供本机代码对象来公开该功能。顺便说一下,浏览器对 DOM 和网络功能做了同样的事情。

如果我想使用仅支持 C api 的数据库,我该怎么做?

为此,您需要一个 node.js 扩展(本机代码插件)。如果您幸运的话,有人已经为您的数据库系统开发了,如果没有,请查看类似扩展的源代码以了解它们是如何编写的。这是介绍文章。您需要熟悉如何编写 v8 扩展,因为这就是节点扩展的本质。

如果您通过网络连接与数据库通信,并且想要自己实现有线协议,您也可以尝试使用纯 Javascript 来实现,就像有人为 MySQL 所做的那样。

node.js includes its own embedded version of v8 (not sure if it is customized or not, but it could be).

Javascript itself provides no interface to things like file system I/O, so that you as the embedder (in this case node) have to provide native code objects to expose that functionality. The browser does the same thing for DOM and network features, by the way.

If I want to work with a database that only supports a C api, how would I go about doing that?

You'd need a node.js extension for this (a native code plugin). If you are lucky, someone has already made on for your database system, if not, look at the source code for a similar extension as to how those are written. And here is an introduction article. You'd need to be familiar with writing a v8 extension, because that is what a node extension basically is.

If you are talking to the database over a network connection, and feel like implementing the wire protocol yourself, you could also try to do that in pure Javascript, like someone did for MySQL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文