Live data from Hacker News

PHP: v8.js

php.net

1–10 of 43 posts

Re: PHP: v8.js

#2
It looks like a PHP extension to embed JavaScript using the V8 engine. The docs are pretty limited. The return value of executing a blob of JS is described thusly: "Returns the last variable instantiated in the Javascript code converted to matching PHP variable type." I supposed the mapping is obvious, to someone :). I'd personally want to know if JS objects come back as stdClass objects or assoc arrays.

It could definitely be handy for a lot of reasons. Seems like it might be handy for embedding a bit of JavaScript testing in your PHP test suite.

Re: PHP: v8.js

#3
I tried implementing the CommonJS spec (eg require) using this extension in order to integrate javascript libraries such as coffeescript and uglify directly into my PHP web stack.

For simple examples it worked fine, but trying it on real projects such as coffeescript it kept seg faulting.

It's definitely got potential though..

Re: PHP: v8.js

#4
I have to say: this is incredibly intresting! I woulbe be curious how one can pass-in variables.

I'm afraid you can not get much out of the great features of JS. Event drivenness..

Anyway, this blows my mind!

Re: PHP: v8.js

#5
Well that just makes me go WTF.

I genuinely can't think of a way this will be used which will be positive for PHP.

Re: PHP: v8.js

#7

It looks like a PHP extension to embed JavaScript using the V8 engine. The docs are pretty limited. The return value of executing a blob of JS is described thusly: "Returns the last variable instantiated in the Javascript code converted to matching PHP variable type." I supposed the mapping is obvious, to someone :). I'd personally want to know if JS objects come back as stdClass objects or assoc arrays. It could def…

I'm in complete agreement with you. Having a CI server is great for PHP work, but it would be better to have the one CI server process both PHP and javascript unit tests together.

Re: PHP: v8.js

#9
Can anybody give some use cases for this? Would this allow me to use JS libraries (made for node for instance) in my PHP code, or is there something else I could do with this?

Re: PHP: v8.js

#10
post #5

Well that just makes me go WTF. I genuinely can't think of a way this will be used which will be positive for PHP.

In theory, it will have the exact same use as the rubyracer gem (http://rubygems.org/gems/therubyracer). Possible uses of that are compiling coffee script using the official compiler or running the same form validation code on both the client- and the server side.

In general I'd be cautious about both the ruby racer and this as you are practically embedding a garbage-collected heap into another garbage collected heap, exchanging references between them (more so for the ruby racer - the PHP extension here is way less integrated).

This is memory errors waiting to happen.

Post reply on HN