hxV8 - New Compilation Target

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

hxV8 - New Compilation Target

blackdog-2

Hi there

haXe js compilation target is specifically for web scripting, I have a
new target for V8 (googles javascript engine) which will target the
server.

PLEASE NOTE, THIS IS A FUNCTIONAL BUT CRUDE WORK IN PROGRESS

V8 consumes Javascript as it's "bytecode" and converts it directly to
machine code - currently for x86 and ARM. Further, V8 is optimized for a
sweet spot where Javascript objects, although very dynamic, don't change
that much. This is very much like haXe, where objects  are constructed
as classes which don't change much but can if necessary.

In practice, programming with Javascript, for me, always requires a
"compilation" process,  usually JSLint. If one needs to perform this
step anyway then why not use a a real compiler?

The great thing is that the creation of the v8 target was a no-brainer;
copy the js target and tweak - so it's probably mostly correct
notwithstanding typos and errors due to search and replace. To get
things up and running quickly I've implemented most of the interfaces of
the V8/C++ "node" (http://tinyclouds.org/node/) network library in
v8.node package. This provides File IO, TCP and HTTP clients and
asynchronous servers ala pythons Twisted

An example usage ...

bin/haxe -v8 Test.js -main Test Test.hx
node Test.js

(obviously download and compile node first)

and I've attached the Test.hx file which includes a tcp and http server.
I'll be looking into sqlite bindings shortly, and will probably look to
implementing the ServerJS API's if I can. If anyone is interested in
contributing, you can find the latest at github ...

http://github.com/blackdog66/hxV8/tree/master


Cheers

bd.

--
haXe - an open source web programming language
http://haxe.org

Test.hx (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

Lee Sylvester
Ritchie!!!! Wow, dude, I thought we'd lost you to Clojure. Man, where
have you been?  You coming back or what?

Anyway... Ahem... Good to hear from you ;-)

Lee





ritchie turner wrote:

> Hi there
>
> haXe js compilation target is specifically for web scripting, I have a
> new target for V8 (googles javascript engine) which will target the
> server.
>
> PLEASE NOTE, THIS IS A FUNCTIONAL BUT CRUDE WORK IN PROGRESS
>
> V8 consumes Javascript as it's "bytecode" and converts it directly to
> machine code - currently for x86 and ARM. Further, V8 is optimized for a
> sweet spot where Javascript objects, although very dynamic, don't change
> that much. This is very much like haXe, where objects  are constructed
> as classes which don't change much but can if necessary.
>
> In practice, programming with Javascript, for me, always requires a
> "compilation" process,  usually JSLint. If one needs to perform this
> step anyway then why not use a a real compiler?
>
> The great thing is that the creation of the v8 target was a no-brainer;
> copy the js target and tweak - so it's probably mostly correct
> notwithstanding typos and errors due to search and replace. To get
> things up and running quickly I've implemented most of the interfaces of
> the V8/C++ "node" (http://tinyclouds.org/node/) network library in
> v8.node package. This provides File IO, TCP and HTTP clients and
> asynchronous servers ala pythons Twisted
>
> An example usage ...
>
> bin/haxe -v8 Test.js -main Test Test.hx
> node Test.js
>
> (obviously download and compile node first)
>
> and I've attached the Test.hx file which includes a tcp and http server.
> I'll be looking into sqlite bindings shortly, and will probably look to
> implementing the ServerJS API's if I can. If anyone is interested in
> contributing, you can find the latest at github ...
>
> http://github.com/blackdog66/hxV8/tree/master
>
>
> Cheers
>
> bd.
>  


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

alstrup
In reply to this post by blackdog-2
Sweet. What is your impression in terms of performance? How does it compare compared to neko or the C++ target?

Regards,
Asger

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

Franco Ponticelli
In reply to this post by blackdog-2
Nice project and it is really good to have you back ;)

Franco

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

Quickform | Marcus Bergstrom
In reply to this post by blackdog-2
Dawg!! Where on earth have you been. Nice to see you're still around!

Marcus Bergstrom
Lead Developer
Quickform S.L.
T: (+34) 951 272 137
M: (+34) 619 825 566
http://www.quickform.net

On 04/06/2009, at 20:29, ritchie turner <[hidden email]>  
wrote:

>
> Hi there
>
> haXe js compilation target is specifically for web scripting, I have a
> new target for V8 (googles javascript engine) which will target the
> server.
>
> PLEASE NOTE, THIS IS A FUNCTIONAL BUT CRUDE WORK IN PROGRESS
>
> V8 consumes Javascript as it's "bytecode" and converts it directly to
> machine code - currently for x86 and ARM. Further, V8 is optimized  
> for a
> sweet spot where Javascript objects, although very dynamic, don't  
> change
> that much. This is very much like haXe, where objects  are constructed
> as classes which don't change much but can if necessary.
>
> In practice, programming with Javascript, for me, always requires a
> "compilation" process,  usually JSLint. If one needs to perform this
> step anyway then why not use a a real compiler?
>
> The great thing is that the creation of the v8 target was a no-
> brainer;
> copy the js target and tweak - so it's probably mostly correct
> notwithstanding typos and errors due to search and replace. To get
> things up and running quickly I've implemented most of the  
> interfaces of
> the V8/C++ "node" (http://tinyclouds.org/node/) network library in
> v8.node package. This provides File IO, TCP and HTTP clients and
> asynchronous servers ala pythons Twisted
>
> An example usage ...
>
> bin/haxe -v8 Test.js -main Test Test.hx
> node Test.js
>
> (obviously download and compile node first)
>
> and I've attached the Test.hx file which includes a tcp and http  
> server.
> I'll be looking into sqlite bindings shortly, and will probably look  
> to
> implementing the ServerJS API's if I can. If anyone is interested in
> contributing, you can find the latest at github ...
>
> http://github.com/blackdog66/hxV8/tree/master
>
>
> Cheers
>
> bd.
> <Test.hx>
> --
> haXe - an open source web programming language
> http://haxe.org

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

blackdog-2
In reply to this post by alstrup

Only anecdotal,

http://www.lassus.eu/2009/05/v8-is-really-really-fast.html

however Lars Bak, creator of 3 other VMs, Hotspot, StrongTalk and Self
reckons it will double speed in a year and quadruple in 4.

Some design notes ...

http://code.google.com/apis/v8/design.html

I think in principle the design is quite similar to neko, whereas neko
uses neko as "bytecode" and can jit it, v8 takes js as bytecode and jits
it. Who's fastest I don't know.  Obviously the C++ target will be
faster.


bd

On Thu, 2009-06-04 at 20:41 +0200, Asger Ottar Alstrup wrote:
> Sweet. What is your impression in terms of performance? How does it
> compare compared to neko or the C++ target?
>
>
> Regards,
> Asger
> --
> haXe - an open source web programming language
> http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

blackdog-2
In reply to this post by Lee Sylvester
Thanks for the welcomes.

bd.


On Thu, 2009-06-04 at 19:32 +0100, Lee McColl Sylvester wrote:

> Ritchie!!!! Wow, dude, I thought we'd lost you to Clojure. Man, where
> have you been?  You coming back or what?
>
> Anyway... Ahem... Good to hear from you ;-)
>
> Lee
>
>
>
>
>
> ritchie turner wrote:
> > Hi there
> >
> > haXe js compilation target is specifically for web scripting, I have a
> > new target for V8 (googles javascript engine) which will target the
> > server.
> >
> > PLEASE NOTE, THIS IS A FUNCTIONAL BUT CRUDE WORK IN PROGRESS
> >
> > V8 consumes Javascript as it's "bytecode" and converts it directly to
> > machine code - currently for x86 and ARM. Further, V8 is optimized for a
> > sweet spot where Javascript objects, although very dynamic, don't change
> > that much. This is very much like haXe, where objects  are constructed
> > as classes which don't change much but can if necessary.
> >
> > In practice, programming with Javascript, for me, always requires a
> > "compilation" process,  usually JSLint. If one needs to perform this
> > step anyway then why not use a a real compiler?
> >
> > The great thing is that the creation of the v8 target was a no-brainer;
> > copy the js target and tweak - so it's probably mostly correct
> > notwithstanding typos and errors due to search and replace. To get
> > things up and running quickly I've implemented most of the interfaces of
> > the V8/C++ "node" (http://tinyclouds.org/node/) network library in
> > v8.node package. This provides File IO, TCP and HTTP clients and
> > asynchronous servers ala pythons Twisted
> >
> > An example usage ...
> >
> > bin/haxe -v8 Test.js -main Test Test.hx
> > node Test.js
> >
> > (obviously download and compile node first)
> >
> > and I've attached the Test.hx file which includes a tcp and http server.
> > I'll be looking into sqlite bindings shortly, and will probably look to
> > implementing the ServerJS API's if I can. If anyone is interested in
> > contributing, you can find the latest at github ...
> >
> > http://github.com/blackdog66/hxV8/tree/master
> >
> >
> > Cheers
> >
> > bd.
> >  
>
>


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

Zjnue Brzavi
another one from me. back with a bang, very nice :)

On Thu, Jun 4, 2009 at 8:12 PM, ritchie turner <[hidden email]> wrote:

> Thanks for the welcomes.
>
> bd.
>
>
> On Thu, 2009-06-04 at 19:32 +0100, Lee McColl Sylvester wrote:
>> Ritchie!!!! Wow, dude, I thought we'd lost you to Clojure. Man, where
>> have you been?  You coming back or what?
>>
>> Anyway... Ahem... Good to hear from you ;-)
>>
>> Lee
>>
>>
>>
>>
>>
>> ritchie turner wrote:
>> > Hi there
>> >
>> > haXe js compilation target is specifically for web scripting, I have a
>> > new target for V8 (googles javascript engine) which will target the
>> > server.
>> >
>> > PLEASE NOTE, THIS IS A FUNCTIONAL BUT CRUDE WORK IN PROGRESS
>> >
>> > V8 consumes Javascript as it's "bytecode" and converts it directly to
>> > machine code - currently for x86 and ARM. Further, V8 is optimized for a
>> > sweet spot where Javascript objects, although very dynamic, don't change
>> > that much. This is very much like haXe, where objects  are constructed
>> > as classes which don't change much but can if necessary.
>> >
>> > In practice, programming with Javascript, for me, always requires a
>> > "compilation" process,  usually JSLint. If one needs to perform this
>> > step anyway then why not use a a real compiler?
>> >
>> > The great thing is that the creation of the v8 target was a no-brainer;
>> > copy the js target and tweak - so it's probably mostly correct
>> > notwithstanding typos and errors due to search and replace. To get
>> > things up and running quickly I've implemented most of the interfaces of
>> > the V8/C++ "node" (http://tinyclouds.org/node/) network library in
>> > v8.node package. This provides File IO, TCP and HTTP clients and
>> > asynchronous servers ala pythons Twisted
>> >
>> > An example usage ...
>> >
>> > bin/haxe -v8 Test.js -main Test Test.hx
>> > node Test.js
>> >
>> > (obviously download and compile node first)
>> >
>> > and I've attached the Test.hx file which includes a tcp and http server.
>> > I'll be looking into sqlite bindings shortly, and will probably look to
>> > implementing the ServerJS API's if I can. If anyone is interested in
>> > contributing, you can find the latest at github ...
>> >
>> > http://github.com/blackdog66/hxV8/tree/master
>> >
>> >
>> > Cheers
>> >
>> > bd.
>> >
>>
>>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

Russell Weir
In reply to this post by Quickform | Marcus Bergstrom
Speak of the Devil, Franco and I were just lamenting your disappearance on IRC the other
day... and you come back with a bang.

Nice work, and once again you've saved me a bunch of work... I was just working on
implementing spidermonkey as a vm container... can't wait to try V8!

R

On Thu, Jun 4, 2009 at 12:53 PM, Marcus Bergstrom <[hidden email]> wrote:
Dawg!! Where on earth have you been. Nice to see you're still around!

Marcus Bergstrom
Lead Developer
Quickform S.L.
T: (+34) 951 272 137
M: (+34) 619 825 566
http://www.quickform.net


On 04/06/2009, at 20:29, ritchie turner <[hidden email]> wrote:


Hi there

haXe js compilation target is specifically for web scripting, I have a
new target for V8 (googles javascript engine) which will target the
server.

PLEASE NOTE, THIS IS A FUNCTIONAL BUT CRUDE WORK IN PROGRESS

V8 consumes Javascript as it's "bytecode" and converts it directly to
machine code - currently for x86 and ARM. Further, V8 is optimized for a
sweet spot where Javascript objects, although very dynamic, don't change
that much. This is very much like haXe, where objects  are constructed
as classes which don't change much but can if necessary.

In practice, programming with Javascript, for me, always requires a
"compilation" process,  usually JSLint. If one needs to perform this
step anyway then why not use a a real compiler?

The great thing is that the creation of the v8 target was a no-brainer;
copy the js target and tweak - so it's probably mostly correct
notwithstanding typos and errors due to search and replace. To get
things up and running quickly I've implemented most of the interfaces of
the V8/C++ "node" (http://tinyclouds.org/node/) network library in
v8.node package. This provides File IO, TCP and HTTP clients and
asynchronous servers ala pythons Twisted

An example usage ...

bin/haxe -v8 Test.js -main Test Test.hx
node Test.js

(obviously download and compile node first)

and I've attached the Test.hx file which includes a tcp and http server.
I'll be looking into sqlite bindings shortly, and will probably look to
implementing the ServerJS API's if I can. If anyone is interested in
contributing, you can find the latest at github ...

http://github.com/blackdog66/hxV8/tree/master


Cheers

bd.
<Test.hx>

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

Nicolas Cannasse
In reply to this post by blackdog-2
ritchie turner a écrit :
> The great thing is that the creation of the v8 target was a no-brainer;
> copy the js target and tweak - so it's probably mostly correct
> notwithstanding typos and errors due to search and replace. To get
> things up and running quickly I've implemented most of the interfaces of
> the V8/C++ "node" (http://tinyclouds.org/node/) network library in
> v8.node package. This provides File IO, TCP and HTTP clients and
> asynchronous servers ala pythons Twisted

Great work.

Could you comment about your changes in the generator ? Are they mostly
for performances or are really required to get V8 running ?

What could be done would be to make some changes in the standard haXe
classes and maybe in the generator when -D v8 is defined.

Best,
Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

blackdog-2
Hi Nicholas

I added the v8 target to allow generation with a new set of libraries,
it seemed to me I needed a new v8 so I could sidestep all the client
side js libs. It would have been better to use the -js with another
flag , like uselibs=v8 or uselibs=js.

In the generator whereever I saw reference to js i replaced with v8,
for the libs I added #if/#elseif where appropriate. As I mentioned haXe
could be a good producer of code for V8, by default, as I heard Lars Bak
talking about the fact that they've optimised for a sweet spot of rarely
changing classes which haXe promotes. That was one of the reasons for
trying it, but apart from that notion, there's certainly nothing more
clever that search/replace :)

bd

On Thu, 2009-06-04 at 21:40 +0200, Nicolas Cannasse wrote:

> ritchie turner a écrit :
> > The great thing is that the creation of the v8 target was a no-brainer;
> > copy the js target and tweak - so it's probably mostly correct
> > notwithstanding typos and errors due to search and replace. To get
> > things up and running quickly I've implemented most of the interfaces of
> > the V8/C++ "node" (http://tinyclouds.org/node/) network library in
> > v8.node package. This provides File IO, TCP and HTTP clients and
> > asynchronous servers ala pythons Twisted
>
> Great work.
>
> Could you comment about your changes in the generator ? Are they mostly
> for performances or are really required to get V8 running ?
>
> What could be done would be to make some changes in the standard haXe
> classes and maybe in the generator when -D v8 is defined.
>
> Best,
> Nicolas
>


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

blackdog-2
In reply to this post by Nicolas Cannasse
Ah so I could have used -js with -D v8 for the libraries only ?? I
thought -D was for client code only not really for "internal" stuff like
targets, but if that's the preferred method I'll tweak it.

bd

On Thu, 2009-06-04 at 21:40 +0200, Nicolas Cannasse wrote:

> ritchie turner a écrit :
> > The great thing is that the creation of the v8 target was a no-brainer;
> > copy the js target and tweak - so it's probably mostly correct
> > notwithstanding typos and errors due to search and replace. To get
> > things up and running quickly I've implemented most of the interfaces of
> > the V8/C++ "node" (http://tinyclouds.org/node/) network library in
> > v8.node package. This provides File IO, TCP and HTTP clients and
> > asynchronous servers ala pythons Twisted
>
> Great work.
>
> Could you comment about your changes in the generator ? Are they mostly
> for performances or are really required to get V8 running ?
>
> What could be done would be to make some changes in the standard haXe
> classes and maybe in the generator when -D v8 is defined.
>
> Best,
> Nicolas
>


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

blackdog-2
In reply to this post by Nicolas Cannasse

but doing a -D v8 I think means a shared top level js for both client
and server libraries is that wanted?

bd

On Thu, 2009-06-04 at 21:40 +0200, Nicolas Cannasse wrote:

> ritchie turner a écrit :
> > The great thing is that the creation of the v8 target was a no-brainer;
> > copy the js target and tweak - so it's probably mostly correct
> > notwithstanding typos and errors due to search and replace. To get
> > things up and running quickly I've implemented most of the interfaces of
> > the V8/C++ "node" (http://tinyclouds.org/node/) network library in
> > v8.node package. This provides File IO, TCP and HTTP clients and
> > asynchronous servers ala pythons Twisted
>
> Great work.
>
> Could you comment about your changes in the generator ? Are they mostly
> for performances or are really required to get V8 running ?
>
> What could be done would be to make some changes in the standard haXe
> classes and maybe in the generator when -D v8 is defined.
>
> Best,
> Nicolas
>


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

clemos
In reply to this post by blackdog-2
Hi

Your project looks really awesome.
I'm still working on a (simple) way to generate Rhino/JS, to build
basic Java scripted programs, but also to target Red5, which has
Javascript support. I'm using "-D rhino" as much as I can, because I
don't want to create  another real "target".
It looks like Javascript is not browser-only anymore these times, and
the work on Rhino makes me feel like haXe's javascript target should
be a bit more "generic", and thus allow "subtargets"...
For example, I guess objects like "window", "document", ... should go
in a "js.Browser" class or something like that.
I have no idea how this could be done, but making the JS target
stronger may bring more people to haXe, since JS is becoming sexy,
very powerful, and could be even more sexy with haXe's feature like
typing, inheritance, etc...

++++++
Clément

ps: I'm working with Geany + hxDev since I've started programming in
haXe, and I'm so happy with it so it's time to thank you very much :)

On Thu, Jun 4, 2009 at 10:04 PM, ritchie turner
<[hidden email]> wrote:

> Hi Nicholas
>
> I added the v8 target to allow generation with a new set of libraries,
> it seemed to me I needed a new v8 so I could sidestep all the client
> side js libs. It would have been better to use the -js with another
> flag , like uselibs=v8 or uselibs=js.
>
> In the generator whereever I saw reference to js i replaced with v8,
> for the libs I added #if/#elseif where appropriate. As I mentioned haXe
> could be a good producer of code for V8, by default, as I heard Lars Bak
> talking about the fact that they've optimised for a sweet spot of rarely
> changing classes which haXe promotes. That was one of the reasons for
> trying it, but apart from that notion, there's certainly nothing more
> clever that search/replace :)
>
> bd
>
> On Thu, 2009-06-04 at 21:40 +0200, Nicolas Cannasse wrote:
>> ritchie turner a écrit :
>> > The great thing is that the creation of the v8 target was a no-brainer;
>> > copy the js target and tweak - so it's probably mostly correct
>> > notwithstanding typos and errors due to search and replace. To get
>> > things up and running quickly I've implemented most of the interfaces of
>> > the V8/C++ "node" (http://tinyclouds.org/node/) network library in
>> > v8.node package. This provides File IO, TCP and HTTP clients and
>> > asynchronous servers ala pythons Twisted
>>
>> Great work.
>>
>> Could you comment about your changes in the generator ? Are they mostly
>> for performances or are really required to get V8 running ?
>>
>> What could be done would be to make some changes in the standard haXe
>> classes and maybe in the generator when -D v8 is defined.
>>
>> Best,
>> Nicolas
>>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

blackdog-2
On Fri, 2009-06-05 at 00:26 +0200, clemos wrote:
> Hi
>
> Your project looks really awesome.

It only took a few hours given that it's just a tweaked version of the
Nicolas js generator. Nevertheless, it's quite a strategically good
idea, as it provides a second, production quality, well supported, low
memory consumption (my java gripe) serverside VM.

> I'm still working on a (simple) way to generate Rhino/JS, to build
> basic Java scripted programs, but also to target Red5, which has
> Javascript support. I'm using "-D rhino" as much as I can, because I
> don't want to create  another real "target".

I wish I'd remembered -D :)

> It looks like Javascript is not browser-only anymore these times, and
> the work on Rhino makes me feel like haXe's javascript target should
> be a bit more "generic", and thus allow "subtargets"...

Yes, I'll be interested to hear Nicholas's ideas on that.

> For example, I guess objects like "window", "document", ... should go
> in a "js.Browser" class or something like that.
> I have no idea how this could be done, but making the JS target
> stronger may bring more people to haXe, since JS is becoming sexy,
> very powerful, and could be even more sexy with haXe's feature like
> typing, inheritance, etc...
>

Agreed. Like i said in my original post, probably no one uses Javascript
without running Jslint over it first, so a compilation phase which
actually provides type safety, more features and the ability to escape
from them when required  is really exceptional. What I think haXe is
missing and what a lot of JS developers will look for is a means of
loading code dynamically - one monolithic file per window doesn't cut
it. This would be my #1 request for strengthening the js target - unless
that's changed since I was last here :).  Not so important for the
server, and unfortunately for the other targets, but it's a requirement
for ajax developers.

> ++++++
> Clément
>
> ps: I'm working with Geany + hxDev since I've started programming in
> haXe, and I'm so happy with it so it's time to thank you very much :)
>

Your welcome, and a lot of effort was put in by BlueZenix too on hxDev.

> On Thu, Jun 4, 2009 at 10:04 PM, ritchie turner
> <[hidden email]> wrote:
> > Hi Nicholas
> >
> > I added the v8 target to allow generation with a new set of libraries,
> > it seemed to me I needed a new v8 so I could sidestep all the client
> > side js libs. It would have been better to use the -js with another
> > flag , like uselibs=v8 or uselibs=js.
> >
> > In the generator whereever I saw reference to js i replaced with v8,
> > for the libs I added #if/#elseif where appropriate. As I mentioned haXe
> > could be a good producer of code for V8, by default, as I heard Lars Bak
> > talking about the fact that they've optimised for a sweet spot of rarely
> > changing classes which haXe promotes. That was one of the reasons for
> > trying it, but apart from that notion, there's certainly nothing more
> > clever that search/replace :)
> >
> > bd
> >
> > On Thu, 2009-06-04 at 21:40 +0200, Nicolas Cannasse wrote:
> >> ritchie turner a écrit :
> >> > The great thing is that the creation of the v8 target was a no-brainer;
> >> > copy the js target and tweak - so it's probably mostly correct
> >> > notwithstanding typos and errors due to search and replace. To get
> >> > things up and running quickly I've implemented most of the interfaces of
> >> > the V8/C++ "node" (http://tinyclouds.org/node/) network library in
> >> > v8.node package. This provides File IO, TCP and HTTP clients and
> >> > asynchronous servers ala pythons Twisted
> >>
> >> Great work.
> >>
> >> Could you comment about your changes in the generator ? Are they mostly
> >> for performances or are really required to get V8 running ?
> >>
> >> What could be done would be to make some changes in the standard haXe
> >> classes and maybe in the generator when -D v8 is defined.
> >>
> >> Best,
> >> Nicolas
> >>
> >
> >
> > --
> > haXe - an open source web programming language
> > http://haxe.org
> >
>


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

Niel Drummond-3
In reply to this post by blackdog-2
Hi Ritchie welcome back..

Just wondering out of interest, why Node ? there are quite a few
server-side js implementations:

http://narwhaljs.org/
http://www.persvr.org/
http://code.google.com/p/v8cgi/

the latter seems to be the most similar to node, but also provides an
apache module. there are more implementations here
https://wiki.mozilla.org/ServerJS

- Niel

ritchie turner wrote:

> Hi there
>
> haXe js compilation target is specifically for web scripting, I have a
> new target for V8 (googles javascript engine) which will target the
> server.
>
> PLEASE NOTE, THIS IS A FUNCTIONAL BUT CRUDE WORK IN PROGRESS
>
> V8 consumes Javascript as it's "bytecode" and converts it directly to
> machine code - currently for x86 and ARM. Further, V8 is optimized for a
> sweet spot where Javascript objects, although very dynamic, don't change
> that much. This is very much like haXe, where objects  are constructed
> as classes which don't change much but can if necessary.
>
> In practice, programming with Javascript, for me, always requires a
> "compilation" process,  usually JSLint. If one needs to perform this
> step anyway then why not use a a real compiler?
>
> The great thing is that the creation of the v8 target was a no-brainer;
> copy the js target and tweak - so it's probably mostly correct
> notwithstanding typos and errors due to search and replace. To get
> things up and running quickly I've implemented most of the interfaces of
> the V8/C++ "node" (http://tinyclouds.org/node/) network library in
> v8.node package. This provides File IO, TCP and HTTP clients and
> asynchronous servers ala pythons Twisted
>
> An example usage ...
>
> bin/haxe -v8 Test.js -main Test Test.hx
> node Test.js
>
> (obviously download and compile node first)
>
> and I've attached the Test.hx file which includes a tcp and http server.
> I'll be looking into sqlite bindings shortly, and will probably look to
> implementing the ServerJS API's if I can. If anyone is interested in
> contributing, you can find the latest at github ...
>
> http://github.com/blackdog66/hxV8/tree/master
>
>
> Cheers
>
> bd.
>  


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

Nicolas Cannasse
In reply to this post by blackdog-2
ritchie turner a écrit :
> but doing a -D v8 I think means a shared top level js for both client
> and server libraries is that wanted?

By doing -D v8 you're able to use

#if v8

In the .hx classes.
This way you can modify haXe/std classes but also add yours and
distribute the whole thing inside a haxelib package which people will be
able to use with -lib v8

BTW, -lib v8 also defines -D v8

Nicolas




--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

blackdog-2
In reply to this post by Niel Drummond-3

It provides the V8 infrastructure and I wanted to test out the idea with
something useful and simple, a non blocking tcp and http sever with file
ops fits that bill. However, node is not a general purpose API and does
not fit well with the typical haXe backend api as everything is done
with callbacks. I think maybe a serverjs implementation could be good as
the standard api, to try and make it attractive to current
javascripters.

bd

On Fri, 2009-06-05 at 08:01 +0200, Niel Drummond wrote:

> Hi Ritchie welcome back..
>
> Just wondering out of interest, why Node ? there are quite a few
> server-side js implementations:
>
> http://narwhaljs.org/
> http://www.persvr.org/
> http://code.google.com/p/v8cgi/
>
> the latter seems to be the most similar to node, but also provides an
> apache module. there are more implementations here
> https://wiki.mozilla.org/ServerJS
>
> - Niel
>
> ritchie turner wrote:
> > Hi there
> >
> > haXe js compilation target is specifically for web scripting, I have a
> > new target for V8 (googles javascript engine) which will target the
> > server.
> >
> > PLEASE NOTE, THIS IS A FUNCTIONAL BUT CRUDE WORK IN PROGRESS
> >
> > V8 consumes Javascript as it's "bytecode" and converts it directly to
> > machine code - currently for x86 and ARM. Further, V8 is optimized for a
> > sweet spot where Javascript objects, although very dynamic, don't change
> > that much. This is very much like haXe, where objects  are constructed
> > as classes which don't change much but can if necessary.
> >
> > In practice, programming with Javascript, for me, always requires a
> > "compilation" process,  usually JSLint. If one needs to perform this
> > step anyway then why not use a a real compiler?
> >
> > The great thing is that the creation of the v8 target was a no-brainer;
> > copy the js target and tweak - so it's probably mostly correct
> > notwithstanding typos and errors due to search and replace. To get
> > things up and running quickly I've implemented most of the interfaces of
> > the V8/C++ "node" (http://tinyclouds.org/node/) network library in
> > v8.node package. This provides File IO, TCP and HTTP clients and
> > asynchronous servers ala pythons Twisted
> >
> > An example usage ...
> >
> > bin/haxe -v8 Test.js -main Test Test.hx
> > node Test.js
> >
> > (obviously download and compile node first)
> >
> > and I've attached the Test.hx file which includes a tcp and http server.
> > I'll be looking into sqlite bindings shortly, and will probably look to
> > implementing the ServerJS API's if I can. If anyone is interested in
> > contributing, you can find the latest at github ...
> >
> > http://github.com/blackdog66/hxV8/tree/master
> >
> >
> > Cheers
> >
> > bd.
> >  
>
>


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

hxV8 - NOT New Compilation target

blackdog-2
In reply to this post by Nicolas Cannasse

As per Nicholas's suggestions below, I have removed the tweaks and
additions to the ml and can now just use the -js target like so

bin/haxe -D v8 -cp . -js Test.js -main Test Test.hx
node Test.js

where there is a v8 directory in the -cp . classpath.

However, there are #if v8 additions to the js Lib.hx and Boot.hx (and
others as I get into it) which would need to be added to the
distribution once I had something more concrete than this test.

Pushed to github at

http://github.com/blackdog66/hxV8/

bd



On Thu, 2009-06-04 at 21:40 +0200, Nicolas Cannasse wrote:

> ritchie turner a écrit :
> > The great thing is that the creation of the v8 target was a no-brainer;
> > copy the js target and tweak - so it's probably mostly correct
> > notwithstanding typos and errors due to search and replace. To get
> > things up and running quickly I've implemented most of the interfaces of
> > the V8/C++ "node" (http://tinyclouds.org/node/) network library in
> > v8.node package. This provides File IO, TCP and HTTP clients and
> > asynchronous servers ala pythons Twisted
>
> Great work.
>
> Could you comment about your changes in the generator ? Are they mostly
> for performances or are really required to get V8 running ?
>
> What could be done would be to make some changes in the standard haXe
> classes and maybe in the generator when -D v8 is defined.
>
> Best,
> Nicolas
>


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxV8 - New Compilation Target

blackdog-2
In reply to this post by alstrup
Here's an unscientific microbenchmark. I use this to generate bingo
cards, just two runs each , looks like neko is slightly ahead on 100,000
iterations, however, javascript performance not bad!

public function testCard() {
        for (i in 0...100000) {
                Server.getCard();
        }
}

public static function getCard():Array<Int> {
var f = [];
for (c in 0...5) {
        var start = 1 + c * 15,
        s = [];
        for (i in start ... start + 15) {
                s.push(i);
        }

        for (l in 0...5) {
                var ri = Std.random(s.length);
                f.push(s[ri]);
                s.splice(ri,1);
        }
}
return f;
}

haxe -D v8 -main Tests -js tests.js -cp . -cp Tests
time node tests.jsClass: TestFoo

real 0m9.245s
user 0m9.219s
sys 0m0.007s

real 0m9.811s
user 0m9.783s
sys 0m0.007s

haxe -main Tests -neko tests.n -cp . Tests

real 0m9.343s
user 0m9.329s
sys 0m0.003s

real 0m9.396s
user 0m9.386s
sys 0m0.000s


bd


On Thu, 2009-06-04 at 20:41 +0200, Asger Ottar Alstrup wrote:
> Sweet. What is your impression in terms of performance? How does it
> compare compared to neko or the C++ target?
>
>
> Regards,
> Asger
> --
> haXe - an open source web programming language
> http://haxe.org


--
haXe - an open source web programming language
http://haxe.org