Jump to page: 1 210  
Page
Thread overview
Object.factory() and exe file size bloat
Aug 21, 2015
Walter Bright
Aug 21, 2015
Dmitry Olshansky
Aug 21, 2015
deadalnix
Aug 21, 2015
H. S. Teoh
Aug 21, 2015
Johannes Pfau
Aug 21, 2015
BBasile
Aug 21, 2015
Walter Bright
Aug 21, 2015
Mike
Aug 21, 2015
Walter Bright
Aug 21, 2015
Johannes Pfau
Aug 21, 2015
Kagamin
Aug 21, 2015
Mike
Aug 21, 2015
Johannes Pfau
Aug 21, 2015
Iain Buclaw
Aug 21, 2015
Dicebot
Aug 21, 2015
Dicebot
Aug 21, 2015
Dicebot
Aug 21, 2015
Iain Buclaw
Aug 21, 2015
Dicebot
Aug 21, 2015
Walter Bright
Aug 21, 2015
Iain Buclaw
Aug 22, 2015
Johannes Pfau
Aug 22, 2015
Iain Buclaw
Aug 22, 2015
Johannes Pfau
Aug 23, 2015
Walter Bright
Aug 22, 2015
Iain Buclaw
Aug 26, 2015
Mike
Aug 26, 2015
Iain Buclaw
Aug 21, 2015
Kagamin
Aug 22, 2015
Johannes Pfau
Aug 22, 2015
Martin Nowak
Aug 22, 2015
Mike
Aug 21, 2015
deadalnix
Aug 21, 2015
sclytrack
Aug 21, 2015
Paolo Invernizzi
Aug 21, 2015
Rikki Cattermole
Aug 23, 2015
Rikki Cattermole
Aug 21, 2015
Jacob Carlborg
Aug 21, 2015
Walter Bright
Aug 23, 2015
Dicebot
Aug 23, 2015
Walter Bright
Aug 21, 2015
Benjamin Thaut
Aug 21, 2015
Jacob Carlborg
Aug 21, 2015
Benjamin Thaut
Aug 21, 2015
Jacob Carlborg
Aug 21, 2015
Johannes Pfau
Aug 21, 2015
Walter Bright
Aug 21, 2015
Dmitry Olshansky
Aug 21, 2015
Jacob Carlborg
Aug 21, 2015
Dicebot
Aug 21, 2015
Walter Bright
Aug 22, 2015
Dicebot
Aug 22, 2015
Walter Bright
Aug 22, 2015
David Nadlinger
Aug 22, 2015
Walter Bright
Aug 22, 2015
David Nadlinger
Aug 22, 2015
Adam D. Ruppe
Aug 22, 2015
Walter Bright
Aug 23, 2015
Benjamin Thaut
Aug 23, 2015
Rikki Cattermole
Aug 23, 2015
Benjamin Thaut
Aug 23, 2015
Dicebot
Aug 21, 2015
Freddy
Aug 21, 2015
Kagamin
Aug 21, 2015
Marc Schütz
Aug 21, 2015
Walter Bright
Aug 21, 2015
deadalnix
Aug 22, 2015
Marc Schütz
Aug 22, 2015
Marc Schütz
Aug 21, 2015
Vladimir Panteleev
Aug 21, 2015
tcak
Aug 21, 2015
Walter Bright
Aug 21, 2015
deadalnix
Aug 21, 2015
Walter Bright
Aug 21, 2015
deadalnix
Aug 21, 2015
rsw0x
Aug 24, 2015
Jacob Carlborg
Aug 21, 2015
ponce
Aug 21, 2015
Walter Bright
Aug 21, 2015
bitwise
Aug 22, 2015
Jonathan M Davis
Aug 22, 2015
Martin Nowak
Aug 23, 2015
Benjamin Thaut
Aug 23, 2015
Walter Bright
Aug 22, 2015
Manu
Aug 22, 2015
rsw0x
Aug 24, 2015
Jacob Carlborg
Aug 25, 2015
w0rp
Aug 25, 2015
Jacob Carlborg
Aug 25, 2015
Daniel Kozák
August 21, 2015
This function:

  http://dlang.org/phobos/object.html#.Object.factory

enables a program to instantiate any class defined in the program. To make it work, though, every class in the program has to have a TypeInfo generated for it. This leads to bloat:

  https://issues.dlang.org/show_bug.cgi?id=14758

and sometimes the bloat can be overwhelming.

The solution seems straightforward - only have Object.factory be able to instantiate classes marked as 'export'. This only makes sense anyway.

What do you think?
August 21, 2015
On 21-Aug-2015 08:06, Walter Bright wrote:
> This function:
>
>    http://dlang.org/phobos/object.html#.Object.factory
>
> enables a program to instantiate any class defined in the program. To
> make it work, though, every class in the program has to have a TypeInfo
> generated for it. This leads to bloat:
>
>    https://issues.dlang.org/show_bug.cgi?id=14758
>
> and sometimes the bloat can be overwhelming.
>
> The solution seems straightforward - only have Object.factory be able to
> instantiate classes marked as 'export'. This only makes sense anyway.
>
> What do you think?

+1000 Though I'd kill the whole object factory if I had a chance. It looks a lot like Java-woannabe feature that may be better done with UDA's and meta-programming (like e.g. run--time type info can be based on compile-time one).

-- 
Dmitry Olshansky
August 21, 2015
On Friday, 21 August 2015 at 05:06:47 UTC, Walter Bright wrote:
> This function:
>
>   http://dlang.org/phobos/object.html#.Object.factory
>
> enables a program to instantiate any class defined in the program. To make it work, though, every class in the program has to have a TypeInfo generated for it. This leads to bloat:
>
>   https://issues.dlang.org/show_bug.cgi?id=14758
>
> and sometimes the bloat can be overwhelming.
>
> The solution seems straightforward - only have Object.factory be able to instantiate classes marked as 'export'. This only makes sense anyway.
>
> What do you think?

Wait ? Why only classes marked export ? I don't follow the reasoning here.
August 21, 2015
On Friday, 21 August 2015 at 05:06:47 UTC, Walter Bright wrote:
> This function:
>
>   http://dlang.org/phobos/object.html#.Object.factory
>
> enables a program to instantiate any class defined in the program. To make it work, though, every class in the program has to have a TypeInfo generated for it:
>
> [...]
>
> What do you think?

This is a good idea. Some other langs use a similar system with a registration.
Eg instances can only be streamed if type is registered.

Other alternatives would be a pragma or an attribute to disable TypeInfo generation.
@NoTI.


August 21, 2015
On Fri, Aug 21, 2015 at 05:15:00AM +0000, deadalnix via Digitalmars-d wrote:
> On Friday, 21 August 2015 at 05:06:47 UTC, Walter Bright wrote:
> >This function:
> >
> >  http://dlang.org/phobos/object.html#.Object.factory
> >
> >enables a program to instantiate any class defined in the program. To make it work, though, every class in the program has to have a TypeInfo generated for it. This leads to bloat:
> >
> >  https://issues.dlang.org/show_bug.cgi?id=14758
> >
> >and sometimes the bloat can be overwhelming.
> >
> >The solution seems straightforward - only have Object.factory be able to instantiate classes marked as 'export'. This only makes sense anyway.
> >
> >What do you think?
> 
> Wait ? Why only classes marked export ? I don't follow the reasoning here.

Because if your code imports the module that defines the class, you already know the class name (either by design, or by compile-time introspection) so you don't need to use the object factory.  It's only when you want to dynamically load new classes at runtime that you didn't know about at compile-time, that you need to use the object factory -- and that's also when you'd mark classes as 'export'.

Makes sense to me.


T

-- 
Windows: the ultimate triumph of marketing over technology. -- Adrian von Bidder
August 21, 2015
On 8/20/2015 10:24 PM, BBasile wrote:
> Other alternatives would be a pragma or an attribute to disable TypeInfo
> generation.

Interestingly, my idea would not disable TypeInfo generation. Instead, the TypeInfo would be generated into a COMDAT section. Then, only if it is referenced is it linked in.

The ModuleInfo, as it currently is implemented, contains a reference to every class TypeInfo, thus pulling them all in.

August 21, 2015
On Friday, 21 August 2015 at 05:35:21 UTC, Walter Bright wrote:
> On 8/20/2015 10:24 PM, BBasile wrote:
>> Other alternatives would be a pragma or an attribute to disable TypeInfo
>> generation.
>
> Interestingly, my idea would not disable TypeInfo generation. Instead, the TypeInfo would be generated into a COMDAT section. Then, only if it is referenced is it linked in.

Disabling TypeInfo forces one to compromise on slicing, postblit, and potentially others useful features, so finding a way to keep TypeInfo, yet remove the dead code is much less of a blunt instrument, and very much preferred.

> The ModuleInfo, as it currently is implemented, contains a reference to every class TypeInfo, thus pulling them all in.

Ideally it would be nice to only pull in those ModuleInfo instances that are actually needed in the program, and by association, only pull in those TypeInfo instances needed by the ModuleInfo.  If no ModuleInfo is used, and the associated TypeInfo is also not used, then neither is pulled in.

Mike
August 21, 2015
On Friday, 21 August 2015 at 05:06:47 UTC, Walter Bright wrote:
> This function:
>
>   http://dlang.org/phobos/object.html#.Object.factory
>
> enables a program to instantiate any class defined in the program. To make it work, though, every class in the program has to have a TypeInfo generated for it. This leads to bloat:
>
>   https://issues.dlang.org/show_bug.cgi?id=14758
>
> and sometimes the bloat can be overwhelming.
>
> The solution seems straightforward - only have Object.factory be able to instantiate classes marked as 'export'. This only makes sense anyway.
>
> What do you think?

+1000!
August 21, 2015
On 8/20/2015 11:00 PM, Mike wrote:
> Ideally it would be nice to only pull in those ModuleInfo instances that are
> actually needed in the program, and by association, only pull in those TypeInfo
> instances needed by the ModuleInfo.  If no ModuleInfo is used, and the
> associated TypeInfo is also not used, then neither is pulled in.

I do plan to do a review of ModuleInfo with this in mind, but not immediately.

August 21, 2015
On 8/21/2015 5:06 PM, Walter Bright wrote:
> This function:
>
>    http://dlang.org/phobos/object.html#.Object.factory
>
> enables a program to instantiate any class defined in the program. To
> make it work, though, every class in the program has to have a TypeInfo
> generated for it. This leads to bloat:
>
>    https://issues.dlang.org/show_bug.cgi?id=14758
>
> and sometimes the bloat can be overwhelming.
>
> The solution seems straightforward - only have Object.factory be able to
> instantiate classes marked as 'export'. This only makes sense anyway.
>
> What do you think?

I need to look over my code that I've written for my to be web application server.
But: I'm a little concerned that if there is no alternative we won't be able to seriously be able to have a web application server ala JSP servlet style.

So while export may work, perhaps a slightly different approach. If an interface/class is marked as export, it gets inherited. So an child class/implementation would also be export because a super interface/class was export.
This would make me a lot happier.
« First   ‹ Prev
1 2 3 4 5 6 7 8 9 10