On Thu, Nov 4, 2010 at 1:42 PM, Brian Meidell <
[email protected]> wrote:

> I'm an experienced c++ programmer (and js programmer), and normally I
> have no problem with diving into sparsely documented stuff, but there
> seems to be so much magic going on behind the scenes in v8 that I have
> a very hard time relying on anything but documentation and examples.
> And I'm having trouble finding much of that.
> Trying to inspect v8 stuff in the debugger doesn't work very well
> either, most of the time.
>

You and i are in the same boat. i've been working with v8 now long enough to
be halfway comfortable with it, but the same problem - nobody WTFM
(Write/Wrote The Fine Manual). Last i checked, the v8 API docs were nearly
useless, full of one-liner descriptions which mean nothing unless one
understands the whole (as you mention - how it all fits together).


> So, how did you people get a handle on v8?
> Do you know of good examples of v8 usage with lots of source
> available?
>

Someone mentioned node.js already, but i'll also shamelessly plug v8-juice,
which is a higher-level wrapper for v8 which primarily assists in binding
custom C/C++ functions and classes to v8, and converting arbitrary types
between JS/C++.

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

It's pedantically well-documented, but it doesn't document how v8 itself
works. (In fact, throughout the sources there are comments like "v8 _seems_
to behave like [this or that]...")


> - Creating constructor functions in the global space that can be used
> from JS, for example (js): var sprite = new ZSprite();
>

v8-juice has lots of examples of that. If you enjoy digging into code, you
might want to try:

http://code.google.com/p/v8-juice/wiki/ClassWrap
http://code.google.com/p/v8-juice/wiki/ClassBinder

those pages present two different class-wrapping mechanisms for v8, and code
links from there lead to the concrete implementations.

- Creating a member function on a constructor function (kinda like a
> static method in c++), so I can call it like this (js): var sprite =
> ZSprite.create( "foo.png" )
>

If you _really_ like getting messy with other people's code:

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

the code links from there show some examples of this. That said, that
particular code is down-and-dirty - code only a mother (or father, in this
case) could love.


> I've looked a bit at
> http://create.tpsitulsa.com/blog/2009/01/29/v8-objects/,
> and some of the info I am seeking seems to be there, but I still can't
> get my stuff to work.
>

My first few hundred hours with v8 were basically trial and error. The only
reason i stuck with it is because i find embeddable scripting so fascinating
and because i'm such a big fan of Google technologies. (No, i don't work for
google!)


> And generally, I'm just randomly trying stuff too much - I'd like to
> be programming deliberately, not by accident.
>

i'm not sure if that's really possible in v8 (except for the insiders who
understand The Whole). i've been at it almost 2 years now, and i still
question "how does (so and so) behave?" very often.


> Any pointers to how to go about grokking v8, the way to use it and how
> the "correct" way to map the c++ and js spaces to each other would be
> hugely appreciated.
>

Several list members have written wrappers which hide these details from
people who don't want to know them, but also internally implement these
details for people who are interested in seeing how they work.

See: http://code.google.com/p/v8-juice/wiki/HomePage
find the "Related work" section, and there are several links to such
projects there.

i hope this helps - i sympathize 100% with your position. If you have
questions regarding how/why v8-juice works, or how i accomplished some
specific feat in v8, feel free to contact me off-list.

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to