它是否使用这样的库:
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.
发布评论
评论(1)
node.js 包含它自己的 v8 嵌入式版本(不确定它是否是定制的,但可能是)。
Javascript 本身不提供文件系统 I/O 等接口,因此作为嵌入者(在本例中为节点)必须提供本机代码对象来公开该功能。顺便说一下,浏览器对 DOM 和网络功能做了同样的事情。
为此,您需要一个 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.
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.