what's differences, "d8 in v8" vs "nodejs"?

585 views
Skip to first unread message

anlex N

unread,
Nov 13, 2020, 3:25:48 AM11/13/20
to v8-dev
i am fresh student that learning v8 and nodejs source code, today i am learning v8 docs step by step, i know v8 have built in d8 that can directly run javascript file, but i don't know why we still need nodejs run javascript file.

Leszek Swirski

unread,
Nov 13, 2020, 3:34:04 AM11/13/20
to v8-dev
Hi,

You can think of V8 as a library used for compiling and running Javascript. Chrome/Chromium, d8 and Node.js are all "embedders" of V8, i.e. applications that use this library. d8 is a very simple, minimal wrapper around the library that we use primarily for debugging, testing, and as a "demo" of how to use the V8 API. Node.js is a larger application that adds a whole bunch of stuff on top of V8, for example 'requires' for module loading, file access APIs, all the server stuff, etc etc. You can think of the difference as "d8 runs Javascript code" and "Node.js runs programs written for Node, using Javascript as the language". If you just want to run an algorithm written in Javascript, d8 is fine, but if you want to run something that uses npm packages, you need Node.

Hope that helps,
Leszek

On Fri, Nov 13, 2020 at 9:25 AM anlex N <an02...@gmail.com> wrote:
i am fresh student that learning v8 and nodejs source code, today i am learning v8 docs step by step, i know v8 have built in d8 that can directly run javascript file, but i don't know why we still need nodejs run javascript file.

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/62dcd603-069a-46bc-98d3-615aa9b16596n%40googlegroups.com.

anlex N

unread,
Nov 13, 2020, 3:55:35 AM11/13/20
to v8-dev
why not let d8 replace nodejs? d8 is official and can add nodejs strength, such like npm. by the way, there is deno in js world that also use v8. oh my god, so many  embedders. i hope google can have official embedders such like d8/nodejs/deno. 

Leszek Swirski

unread,
Nov 13, 2020, 4:21:35 AM11/13/20
to v8-dev
Simply put, because Node.js is huge and does a _lot_ more than just running Javascript. d8 is very much just a simple internal debugging tool, and we want it to stay that way -- otherwise it'll be hard to tell if the issue we're seeing is in "d8 Node" or in V8, and it'll be harder to add support for new language features (since hacking them into d8 is way easier than properly wiring them up in Node). It's definitely the case, for example, that we find it easier to add new features to d8 than to Chromium, even though both are "official" embedders! We do support Node.js as a first-class client though, we help when they have V8 issues and we run a Node.js build as part of our "commit queue" so that every V8 commit is also tested against Node.js.

Besides, there's value in Node.js being separate from V8. For example, there's a fork of Node that uses ChakraCore (from IE) as the JavaScript engine instead of V8, and there's similar projects using JSC (from Safari) and SpiderMonkey (from Firefox); this sort of thing would be harder if Node was part of V8. Also, people associated with Node this way don't have to be associated with Google, and can represent Node's interests better in, for example, TC39 when discussing the JS language.

Overall, TL;DR, it's good to have big projects be separate, and keep small test runners small.

- Leszek

Leszek Swirski

unread,
Nov 13, 2020, 4:26:48 AM11/13/20
to v8-dev
One of my colleagues made a great additional point, that there's not really such a thing as "letting d8 replace node" -- Google could theoretically build d8 into an npm-compatible node competitor, but then that's really just xkcd:927.

- Leszek

anlex N

unread,
Nov 13, 2020, 10:47:41 AM11/13/20
to v8-dev

so many repetitive things. by the way, v8(GN) and nodejs(Makefile), why not use same build system? oh my god. i think cmake is good choice.

Leszek Swirski

unread,
Nov 13, 2020, 10:59:09 AM11/13/20
to v8-dev
To explain that, I can only really point you at xkcd:927 again :)
- Leszek

Reply all
Reply to author
Forward
0 new messages