"Using" syntax

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

"Using" syntax

Martijn Loots
Hi.

I have developed a data structure (tree like composition
of a lot of classes).

The program I made builds this structure by means of
parallel classes with all static methods, so that I
can serialize the data structure and read it into an
entire other surrounding (building it using subclasses
would break that).

The keyword "using" is perfect for these all-static, single
package methods, but I mostly need to specify a number of
them line by line, like:

   using Bottom;
   using Trunk;
   using Branch;
   using Leaf;

It would be sooooo very nice if it could be stated as:

   using Bottom, Trunk, Branch, Leaf;

Is this a reasonable possibility ?

TIA,
--
-Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
-          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
-         ( >__< )  ----------------------------------------
-         ^^^  ^^^  (   Netwerken, Security, Open Source   )

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

Re: "Using" syntax

Ian Liu Rodrigues
Not very related to the topic, but I guess that "using" is the kind of
thing that must be used with moderation I guess, since static
methods are more expensive than other kinds of calls.

Cheers,
Ian L.

On Fri, Oct 2, 2009 at 6:16 AM, Martijn Loots <[hidden email]> wrote:
Hi.

I have developed a data structure (tree like composition
of a lot of classes).

The program I made builds this structure by means of
parallel classes with all static methods, so that I
can serialize the data structure and read it into an
entire other surrounding (building it using subclasses
would break that).

The keyword "using" is perfect for these all-static, single
package methods, but I mostly need to specify a number of
them line by line, like:

 using Bottom;
 using Trunk;
 using Branch;
 using Leaf;

It would be sooooo very nice if it could be stated as:

 using Bottom, Trunk, Branch, Leaf;

Is this a reasonable possibility ?

TIA,
--
-Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
-          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
-         ( >__< )  ----------------------------------------
-         ^^^  ^^^  (   Netwerken, Security, Open Source   )

--
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: "Using" syntax

Armén
On Fri, Oct 2, 2009 at 15:01, Ian Liu <[hidden email]> wrote:
> Not very related to the topic, but I guess that "using" is the kind of
> thing that must be used with moderation I guess, since static
> methods are more expensive than other kinds of calls.
> Cheers,
> Ian L.

They are? In any case what you said can only be understood in a
context of a specific platform. Which platforms do you imply?
Certainly not true with CPP.

>
> On Fri, Oct 2, 2009 at 6:16 AM, Martijn Loots <[hidden email]> wrote:
>>
>> Hi.
>>
>> I have developed a data structure (tree like composition
>> of a lot of classes).
>>
>> The program I made builds this structure by means of
>> parallel classes with all static methods, so that I
>> can serialize the data structure and read it into an
>> entire other surrounding (building it using subclasses
>> would break that).
>>
>> The keyword "using" is perfect for these all-static, single
>> package methods, but I mostly need to specify a number of
>> them line by line, like:
>>
>>  using Bottom;
>>  using Trunk;
>>  using Branch;
>>  using Leaf;
>>
>> It would be sooooo very nice if it could be stated as:
>>
>>  using Bottom, Trunk, Branch, Leaf;
>>
>> Is this a reasonable possibility ?
>>
>> TIA,
>> --
>> -Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
>> -          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
>> -         ( >__< )  ----------------------------------------
>> -         ^^^  ^^^  (   Netwerken, Security, Open Source   )
>>
>> --
>> 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
|

Static method performance, was: "Using" syntax

Martijn Loots
In reply to this post by Ian Liu Rodrigues
Yes, I knew that, so the data structure I use is completely non-static.

It's no problem at all to use less performing static methods to
compose a "write once, use many times" data structure...

Static methods are just as useful as instance methods; they have
their own merit and should be used appropriatly.

But since you started this side note, I would really like to know
what the actual impact is with regard to the performance hit of
static methods. I mean, could someone fill a little table like:

   Flash: +3 ms / call
   Neko : +1 us / call
   PHP  : ...

Has there been any investigation on figures or is it just a matter
of "it *does* not perform as good"... ?

Grtz,
--
-Martijn

On Fri, 2 Oct 2009, Ian Liu wrote:

> Not very related to the topic, but I guess that "using" is the kind of
> thing that must be used with moderation I guess, since static
> methods are more expensive than other kinds of calls.
>
> Cheers,
> Ian L.
>
> On Fri, Oct 2, 2009 at 6:16 AM, Martijn Loots <[hidden email]> wrote:
>
>> Hi.
>>
>> I have developed a data structure (tree like composition
>> of a lot of classes).
>>
>> The program I made builds this structure by means of
>> parallel classes with all static methods, so that I
>> can serialize the data structure and read it into an
>> entire other surrounding (building it using subclasses
>> would break that).
>>
>> The keyword "using" is perfect for these all-static, single
>> package methods, but I mostly need to specify a number of
>> them line by line, like:
>>
>>  using Bottom;
>>  using Trunk;
>>  using Branch;
>>  using Leaf;
>>
>> It would be sooooo very nice if it could be stated as:
>>
>>  using Bottom, Trunk, Branch, Leaf;
>>
>> Is this a reasonable possibility ?
>>
>> TIA,
>> --
>> -Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
>> -          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
>> -         ( >__< )  ----------------------------------------
>> -         ^^^  ^^^  (   Netwerken, Security, Open Source   )
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
>

--
-Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
-          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
-         ( >__< )  ----------------------------------------
-         ^^^  ^^^  (   Netwerken, Security, Open Source   )

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

Re: "Using" syntax

Ian Liu Rodrigues
In reply to this post by Armén
Armencho, I'm flash inclined ;-)
I should have mentioned that.

Cheers!
Ian L.

On Fri, Oct 2, 2009 at 10:54 AM, [hidden email] <[hidden email]> wrote:
On Fri, Oct 2, 2009 at 15:01, Ian Liu <[hidden email]> wrote:
> Not very related to the topic, but I guess that "using" is the kind of
> thing that must be used with moderation I guess, since static
> methods are more expensive than other kinds of calls.
> Cheers,
> Ian L.

They are? In any case what you said can only be understood in a
context of a specific platform. Which platforms do you imply?
Certainly not true with CPP.

>
> On Fri, Oct 2, 2009 at 6:16 AM, Martijn Loots <[hidden email]> wrote:
>>
>> Hi.
>>
>> I have developed a data structure (tree like composition
>> of a lot of classes).
>>
>> The program I made builds this structure by means of
>> parallel classes with all static methods, so that I
>> can serialize the data structure and read it into an
>> entire other surrounding (building it using subclasses
>> would break that).
>>
>> The keyword "using" is perfect for these all-static, single
>> package methods, but I mostly need to specify a number of
>> them line by line, like:
>>
>>  using Bottom;
>>  using Trunk;
>>  using Branch;
>>  using Leaf;
>>
>> It would be sooooo very nice if it could be stated as:
>>
>>  using Bottom, Trunk, Branch, Leaf;
>>
>> Is this a reasonable possibility ?
>>
>> TIA,
>> --
>> -Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
>> -          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
>> -         ( >__< )  ----------------------------------------
>> -         ^^^  ^^^  (   Netwerken, Security, Open Source   )
>>
>> --
>> 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


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

Re: Static method performance, was: "Using" syntax

Michael Baczynski-2
In reply to this post by Martijn Loots
On 02.10.2009 15:55, Martijn Loots wrote:

> Yes, I knew that, so the data structure I use is completely non-static.
>
> It's no problem at all to use less performing static methods to
> compose a "write once, use many times" data structure...
>
> Static methods are just as useful as instance methods; they have
> their own merit and should be used appropriatly.
>
> But since you started this side note, I would really like to know
> what the actual impact is with regard to the performance hit of
> static methods. I mean, could someone fill a little table like:
>
>   Flash: +3 ms / call
>   Neko : +1 us / call
>   PHP  : ...
>
for flash (tested on latest flash release player) a static function call
is about 50% slower than a non-static call so it's not that worse - the
problem is access to static fields which is almost 10x slower that
non-static fields..

> Has there been any investigation on figures or is it just a matter
> of "it *does* not perform as good"... ?
>
> Grtz,


--
http://www.polygonal.de


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

Re: Static method performance, was: "Using" syntax

Martijn Loots
On Fri, 2 Oct 2009, Michael Baczynski wrote:

> On 02.10.2009 15:55, Martijn Loots wrote:
>> Yes, I knew that, so the data structure I use is completely non-static.
>>
>> It's no problem at all to use less performing static methods to
>> compose a "write once, use many times" data structure...
>>
>> Static methods are just as useful as instance methods; they have
>> their own merit and should be used appropriatly.
>>
>> But since you started this side note, I would really like to know
>> what the actual impact is with regard to the performance hit of
>> static methods. I mean, could someone fill a little table like:
>>
>>   Flash: +3 ms / call
>>   Neko : +1 us / call
>>   PHP  : ...
>>
> for flash (tested on latest flash release player) a static function call is
> about 50% slower than a non-static call so it's not that worse - the problem
> is access to static fields which is almost 10x slower that non-static
> fields..
>
Allright, so we have:

   Flash: +50% / call    +1000% / field access     static vs. instance

But how does that relate to actual times ? I understand that the iron
running it does have something to do with that (tongue-in-cheek...),
but are we talking about actual cost in milliseconds, microseconds ?

It's nice to know where repetitive tasks are concerned. I have no
feeling for it at all right now :(

Grtz,
--
-Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
-          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
-         ( >__< )  ----------------------------------------
-         ^^^  ^^^  (   Netwerken, Security, Open Source   )

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

Re: Static method performance, was: "Using" syntax

Ian Liu Rodrigues
In reply to this post by Michael Baczynski-2
Here is a very simple bench mark I did.
I know flash timer is not that reliable, but for curiosity I will put the results ;-)

The program runs a static and a non-static method n(j) times, where n(j) = 100.000 + j*10.000, for j = 0, 1, ..., 9

import haxe.Timer;

class Bench {
static function main() {
new Bench();
}
static function sum_static(i) {
i++;
}
public function sum(i) {
i++;
}
public function new() {
var t0:Float;
var MAX:Int;

for (j in 0...10) {
MAX = 100000 + j*10000;
trace(MAX);

t0 = Timer.stamp();
for (i in 0...MAX)
sum(0);
trace(Timer.stamp()-t0);

t0 = Timer.stamp();
for (i in 0...MAX)
sum_static(0);
trace(Timer.stamp()-t0);
}
}
}

This is the graphic for the result. The Y-axis is the time spent in seconds, the X-axis
is the n(j).

graphic.png

How accurate the timer is I don't know, I should make other experiments to check this ;)

Ian L.



On Fri, Oct 2, 2009 at 11:17 AM, Michael Baczynski <[hidden email]> wrote:
On 02.10.2009 15:55, Martijn Loots wrote:
Yes, I knew that, so the data structure I use is completely non-static.

It's no problem at all to use less performing static methods to
compose a "write once, use many times" data structure...

Static methods are just as useful as instance methods; they have
their own merit and should be used appropriatly.

But since you started this side note, I would really like to know
what the actual impact is with regard to the performance hit of
static methods. I mean, could someone fill a little table like:

 Flash: +3 ms / call
 Neko : +1 us / call
 PHP  : ...

for flash (tested on latest flash release player) a static function call is about 50% slower than a non-static call so it's not that worse - the problem is access to static fields which is almost 10x slower that non-static fields..


Has there been any investigation on figures or is it just a matter
of "it *does* not perform as good"... ?

Grtz,


--
http://www.polygonal.de


--
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: Static method performance, was: "Using" syntax

Martijn Loots
On Fri, 2 Oct 2009, Ian Liu wrote:

> Here is a very simple bench mark I did.I know flash timer is not that
> reliable, but for curiosity I will put the results ;-)
>
[...]
>
> How accurate the timer is I don't know, I should make other experiments to
> check this ;)
>
According to your graphs, it has a 1 ms resolution.

Nice little program; I'll use that later myself, thanks.

Grtz,
--
-Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
-          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
-         ( >__< )  ----------------------------------------
-         ^^^  ^^^  (   Netwerken, Security, Open Source   )

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

Re: Static method performance, was: "Using" syntax

Ian Liu Rodrigues
According to your graphs, it has a 1 ms resolution.

Indeed. That must be the operating system resolution.
 
Nice little program; I'll use that later myself, thanks.

You welcome!

Cheers,
Ian L. 

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

Re: Static method performance, was: "Using" syntax

Chris Hecker
In reply to this post by Martijn Loots

You guys should look in the archives, as well.  Nicolas and I were
talking about enregistering classes so the static calls were the same
speed as members, etc.  I don't post much, so it should be easy to find.

Chris


Martijn Loots wrote:

> On Fri, 2 Oct 2009, Ian Liu wrote:
>
>> Here is a very simple bench mark I did.I know flash timer is not that
>> reliable, but for curiosity I will put the results ;-)
>>
> [...]
>>
>> How accurate the timer is I don't know, I should make other
>> experiments to
>> check this ;)
>>
> According to your graphs, it has a 1 ms resolution.
>
> Nice little program; I'll use that later myself, thanks.
>
> Grtz,

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

Re: Static method performance, was: "Using" syntax

Martijn Loots
On Fri, 2 Oct 2009, Chris Hecker wrote:
>
> You guys should look in the archives, as well.  Nicolas and I were talking
> about enregistering classes so the static calls were the same speed as
> members, etc.  I don't post much, so it should be easy to find.
>
Well, you've been more productive in the list than you imagined...

I tried your name, refined to "hecker static", "hecker nicolas", ..
and there were some promising subjects, but no sigar.

I see that you've done a lot on the performance issue, but could
you be a little more specific ? It seems to be hidden within the
body texts...

TIA, grtz,
--
-Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
-          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
-         ( >__< )  ----------------------------------------
-         ^^^  ^^^  (   Netwerken, Security, Open Source   )

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

Re: "Using" syntax

Armén
In reply to this post by Ian Liu Rodrigues
On Fri, Oct 2, 2009 at 16:00, Ian Liu <[hidden email]> wrote:
> Armencho, I'm flash inclined ;-)
> I should have mentioned that.
> Cheers!
> Ian L.

Me too :-)

>
> On Fri, Oct 2, 2009 at 10:54 AM, [hidden email] <[hidden email]>
> wrote:
>>
>> On Fri, Oct 2, 2009 at 15:01, Ian Liu <[hidden email]> wrote:
>> > Not very related to the topic, but I guess that "using" is the kind of
>> > thing that must be used with moderation I guess, since static
>> > methods are more expensive than other kinds of calls.
>> > Cheers,
>> > Ian L.
>>
>> They are? In any case what you said can only be understood in a
>> context of a specific platform. Which platforms do you imply?
>> Certainly not true with CPP.
>>
>> >
>> > On Fri, Oct 2, 2009 at 6:16 AM, Martijn Loots <[hidden email]> wrote:
>> >>
>> >> Hi.
>> >>
>> >> I have developed a data structure (tree like composition
>> >> of a lot of classes).
>> >>
>> >> The program I made builds this structure by means of
>> >> parallel classes with all static methods, so that I
>> >> can serialize the data structure and read it into an
>> >> entire other surrounding (building it using subclasses
>> >> would break that).
>> >>
>> >> The keyword "using" is perfect for these all-static, single
>> >> package methods, but I mostly need to specify a number of
>> >> them line by line, like:
>> >>
>> >>  using Bottom;
>> >>  using Trunk;
>> >>  using Branch;
>> >>  using Leaf;
>> >>
>> >> It would be sooooo very nice if it could be stated as:
>> >>
>> >>  using Bottom, Trunk, Branch, Leaf;
>> >>
>> >> Is this a reasonable possibility ?
>> >>
>> >> TIA,
>> >> --
>> >> -Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
>> >> -          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
>> >> -         ( >__< )  ----------------------------------------
>> >> -         ^^^  ^^^  (   Netwerken, Security, Open Source   )
>> >>
>> >> --
>> >> 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
>
>
> --
> 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: Static method performance, was: "Using" syntax

Michael Baczynski-2
In reply to this post by Martijn Loots
If i remember correctly Chris refers to the fact that you can store a
reference to class in a variable (which isn't possible in AS3):

class MyClass
{
      public static function foo() {}
}
...
var cl = MyClass;
cl.foo(); //almost as fast as a non-static class.

best,
michael

On 03.10.2009 12:03, Martijn Loots wrote:

> On Fri, 2 Oct 2009, Chris Hecker wrote:
>>
>> You guys should look in the archives, as well.  Nicolas and I were
>> talking about enregistering classes so the static calls were the same
>> speed as members, etc.  I don't post much, so it should be easy to find.
>>
> Well, you've been more productive in the list than you imagined...
>
> I tried your name, refined to "hecker static", "hecker nicolas", ..
> and there were some promising subjects, but no sigar.
>
> I see that you've done a lot on the performance issue, but could
> you be a little more specific ? It seems to be hidden within the
> body texts...
>
> TIA, grtz,


--
http://www.polygonal.de


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

Re: Static method performance, was: "Using" syntax

Martijn Loots
I see, but "almost as fast" AS2 has no real meaning in a nowadays
quest for absolute figures. I just looked for a set of benchmark
programs, so to test several aspects of performance on all types
of haXe platforms on my own hardware/OS combinations.

There does not seem to exist a set of haXe timed benchmarks yet,
does it ?

Grtz,
--
-Martijn

On Sat, 3 Oct 2009, Michael Baczynski wrote:

> If i remember correctly Chris refers to the fact that you can store a
> reference to class in a variable (which isn't possible in AS3):
>
> class MyClass
> {
>     public static function foo() {}
> }
> ...
> var cl = MyClass;
> cl.foo(); //almost as fast as a non-static class.
>
> best,
> michael
>
> On 03.10.2009 12:03, Martijn Loots wrote:
>> On Fri, 2 Oct 2009, Chris Hecker wrote:
>>>
>>> You guys should look in the archives, as well.  Nicolas and I were talking
>>> about enregistering classes so the static calls were the same speed as
>>> members, etc.  I don't post much, so it should be easy to find.
>>>
>> Well, you've been more productive in the list than you imagined...
>>
>> I tried your name, refined to "hecker static", "hecker nicolas", ..
>> and there were some promising subjects, but no sigar.
>>
>> I see that you've done a lot on the performance issue, but could
>> you be a little more specific ? It seems to be hidden within the
>> body texts...
>>
>> TIA, grtz,
>
>
>

--
-Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
-          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
-         ( >__< )  ----------------------------------------
-         ^^^  ^^^  (   Netwerken, Security, Open Source   )

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

Re: Static method performance, was: "Using" syntax

John A. De Goes

There exists a fairly straightforward transformation from a static class A:

public class A {
    public function doX() { }
}

to a non-static singleton B:

public class B {
    public static var INSTANCE:B = new B();

    private function new() { }

    public function doX() { }
}

in which case any class (or method) that uses the static class can be refactored from this:

public class Foo {
    public functino myFunc() {
        A.doX();
    }
}

to something like this:

public class Foo {
    private var bInstance:B;

    public function new() { bInstance = B.INSTANCE; }

    public functino myFunc() {
        bInstance.doX();
    }
}


In any case, no one should be avoiding language constructs (e.g. static) merely because they have poor performance. The compiler can always be optimized (indeed, in the next version of FP, statics might be faster than instance methods, who knows!). In the long run, it's more important that the code you write be easy to understand, easy to use, and easy to maintain.

Regards,

John

On Oct 3, 2009, at 7:53 AM, Martijn Loots wrote:

I see, but "almost as fast" AS2 has no real meaning in a nowadays
quest for absolute figures. I just looked for a set of benchmark
programs, so to test several aspects of performance on all types
of haXe platforms on my own hardware/OS combinations.

There does not seem to exist a set of haXe timed benchmarks yet,
does it ?

Grtz,
--
-Martijn

On Sat, 3 Oct 2009, Michael Baczynski wrote:

If i remember correctly Chris refers to the fact that you can store a reference to class in a variable (which isn't possible in AS3):

class MyClass
{
   public static function foo() {}
}
...
var cl = MyClass;
cl.foo(); //almost as fast as a non-static class.

best,
michael

On 03.10.2009 12:03, Martijn Loots wrote:
On Fri, 2 Oct 2009, Chris Hecker wrote:
You guys should look in the archives, as well.  Nicolas and I were talking about enregistering classes so the static calls were the same speed as members, etc.  I don't post much, so it should be easy to find.
Well, you've been more productive in the list than you imagined...
I tried your name, refined to "hecker static", "hecker nicolas", ..
and there were some promising subjects, but no sigar.
I see that you've done a lot on the performance issue, but could
you be a little more specific ? It seems to be hidden within the
body texts...
TIA, grtz,




--
-Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
-          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
-         ( >__< )  ----------------------------------------
-         ^^^  ^^^  (   Netwerken, Security, Open Source   )

--
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: Static method performance, was: "Using" syntax

Armén
On Sat, Oct 3, 2009 at 19:33, John A. De Goes <[hidden email]> wrote:
> In any case, no one should be avoiding language constructs (e.g. static)
> merely because they have poor performance. The compiler can always be
> optimized (indeed, in the next version of FP, statics might be faster than
> instance methods, who knows!). In the long run, it's more important that the
> code you write be easy to understand, easy to use, and easy to maintain.

In fact, of all things, haXe can be made to re-factor statics into
something completely different at runtime. Thing is nobody cares how
his/her code is run at runtime, unless a) they are debugging it
through runtime constructs themselves (reflection etc) b) they plan to
interface the runtime code through external objects (for example as a
library loaded into a project written in AS3).

We should assume as little as possible about target platform. This
includes how our classes are compiled etc. This is already what is
happening without us caring about it - I use "using" very often and
frankly could not care less that all the static functions that end up
doing work on objects of my classes, are in fact not connected to
these classes at all.

This is what C++ compilers did for years - the most popular platform
(x86) is so "low-level" (no runtime classes etc), many "web"
programmers would be amazed how in fact classes are compiled and work
at all. However it is all very very feasable, as experience indicates.
Classes become packed structures, and methods simply work on these
structures, in addition to accepting user-given arguments.

My point is, haXe should be free about compiling our syntax in
whatever way it wants, providing guarantees that it will run as
expected (from language specification, which could/should be
abstracted from platform internals) and such things. If this means
compiling methods written with "static" keyword into actual runtime
instance methods, fine by me. Unless I need to assume certain platform
specific layout of my code, as in when accessing it from another
application etc, it is all valid. Otherwise, haXe could extend the
"extern" keyword to flag code which needs to make it into runtime with
as little abstraction/translation as possible.


> Regards,
> John
> On Oct 3, 2009, at 7:53 AM, Martijn Loots wrote:
>
> I see, but "almost as fast" AS2 has no real meaning in a nowadays
> quest for absolute figures. I just looked for a set of benchmark
> programs, so to test several aspects of performance on all types
> of haXe platforms on my own hardware/OS combinations.
>
> There does not seem to exist a set of haXe timed benchmarks yet,
> does it ?
>
> Grtz,
> --
> -Martijn
>
> On Sat, 3 Oct 2009, Michael Baczynski wrote:
>
> If i remember correctly Chris refers to the fact that you can store a
> reference to class in a variable (which isn't possible in AS3):
>
> class MyClass
>
> {
>
>    public static function foo() {}
>
> }
>
> ...
>
> var cl = MyClass;
>
> cl.foo(); //almost as fast as a non-static class.
>
> best,
>
> michael
>
> On 03.10.2009 12:03, Martijn Loots wrote:
>
> On Fri, 2 Oct 2009, Chris Hecker wrote:
>
> You guys should look in the archives, as well.  Nicolas and I were talking
> about enregistering classes so the static calls were the same speed as
> members, etc.  I don't post much, so it should be easy to find.
>
> Well, you've been more productive in the list than you imagined...
>
> I tried your name, refined to "hecker static", "hecker nicolas", ..
>
> and there were some promising subjects, but no sigar.
>
> I see that you've done a lot on the performance issue, but could
>
> you be a little more specific ? It seems to be hidden within the
>
> body texts...
>
> TIA, grtz,
>
>
>
>
> --
> -Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
> -          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
> -         ( >__< )  ----------------------------------------
> -         ^^^  ^^^  (   Netwerken, Security, Open Source   )
>
> --
> 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: Static method performance, was: "Using" syntax

back2dos
[hidden email] wrote:

> On Sat, Oct 3, 2009 at 19:33, John A. De Goes <[hidden email]> wrote:
>  
>> In any case, no one should be avoiding language constructs (e.g. static)
>> merely because they have poor performance. The compiler can always be
>> optimized (indeed, in the next version of FP, statics might be faster than
>> instance methods, who knows!). In the long run, it's more important that the
>> code you write be easy to understand, easy to use, and easy to maintain.
>>    
>
>  
i totally agree ... actually, it's a thing i never really understood ...
on the AVM2, it's not so much about statics, if i understand correctly,
it's about globals in general ...
i don't get why they are slower ... they are the only thing known for
certain at compile time, and they are slower ...

> In fact, of all things, haXe can be made to re-factor statics into
> something completely different at runtime. Thing is nobody cares how
> his/her code is run at runtime, unless a) they are debugging it
> through runtime constructs themselves (reflection etc) b) they plan to
> interface the runtime code through external objects (for example as a
> library loaded into a project written in AS3).
>
> We should assume as little as possible about target platform. This
> includes how our classes are compiled etc. This is already what is
> happening without us caring about it - I use "using" very often and
> frankly could not care less that all the static functions that end up
> doing work on objects of my classes, are in fact not connected to
> these classes at all.
>  
[...]

>
> My point is, haXe should be free about compiling our syntax in
> whatever way it wants, providing guarantees that it will run as
> expected (from language specification, which could/should be
> abstracted from platform internals) and such things. If this means
> compiling methods written with "static" keyword into actual runtime
> instance methods, fine by me. Unless I need to assume certain platform
> specific layout of my code, as in when accessing it from another
> application etc, it is all valid. Otherwise, haXe could extend the
> "extern" keyword to flag code which needs to make it into runtime with
> as little abstraction/translation as possible.
>
>
>  
very good point ... i think, in fact one shouldn't really care ...
reflection API is cross platform, so it could actually provide
runtime-compiltime consistency ... up to now it even sort of does,
accept for accessors and optional parameters ...
when it comes to interfacing with external objects, i don't care ... as
for me, i'm really having an awful time getting haXe and AS3 run
together (really hand in hand, not just side by side) ... from the AS3
perspective everything is public and all typedefs and type parameters
are gone ... and from haXe perspective, there is no way to capture the
semantics of AS3 accessors and access modifiers (including custom
namespaces) ... also, you will have a very hard time trying to subclass
accross languages ...

a little side note, before someone else points it out ... ;)
i know, it provides a certain barrier for people coming from the compile
target's "native" language, when switching to haXe, if you just say
"well, haXe doesn't really care too much about interfacing with your
language" ... but i think making haXe even more powerful at that cost,
also provides more reasons to switch ... and anyway, for most targets,
you need to write externals, if not even wrappers, to make it interface
in a sensible way ...

in the end, i think haXe could still provide a way to retain the
semantics at runtime ... for example, refactor statics into something
different, but at the same time make sure, there is a class object that
works as expected ... i think haXe should care more about preserving its
own semantics at runtime, than about keeping close to the native
language's semantics ...

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

Re: Static method performance, was: "Using" syntax

Ian Liu Rodrigues
In any case, no one should be avoiding language constructs (e.g. static)
merely because they have poor performance. The compiler can always be
optimized (indeed, in the next version of FP, statics might be faster than
instance methods, who knows!). In the long run, it's more important that the
code you write be easy to understand, easy to use, and easy to maintain.   
 
i totally agree ... actually, it's a thing i never really understood ... on the AVM2, it's not so much about statics, if i understand correctly, it's about globals in general ...
i don't get why they are slower ... they are the only thing known for certain at compile time, and they are slower ...

I also agree with this thought, but its always good to know where slowness can come from.

Regards,
Ian L.

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