Thread overview | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 28, 2003 Dynamic Capabilities of D | ||||
---|---|---|---|---|
| ||||
Hi, I was looking at the language comparison chart for D and I was wondering how dynamic was the language at runtime? One of the things that I don't like about C++ is its lack of virtual constructors, or any other mechanism within the language to be able to instantiate an object without compile time knowledge of its type. Java and C# get around this through reflection - not ideal but it works. Delphi has a datatype design to hold class references that make dynamic instantiation very easy. Does D have a similar facility? If not, could you explain why this feature wasn't included as it strikes me as being an absolutely vital feature of any OO language. I also notice that someone else asked a similar question in this newsgroup in Feb 2001; Has any progress been made in this area since then? Cheers, Barry Carr Ixian Software Components Ltd Blairgowrie Perthshire Scotland www.Ixian-Software.com |
December 28, 2003 Re: Dynamic Capabilities of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Barry Carr | dunno why this should be vital at all.. D is not a scripting language, and not written in runtime.. why should it be able to create objects of unknown type at runtime? there are simply no unkown types anymore at runtime. and creating a factory in D is ridiculous easy.. so no problem. In article <Xns945F864EEC85Abarrycarrixiansoftwa@63.105.9.61>, Barry Carr says... > >Hi, > >I was looking at the language comparison chart for D and I was wondering how dynamic was the language at runtime? > >One of the things that I don't like about C++ is its lack of virtual constructors, or any other mechanism within the language to be able to instantiate an object without compile time knowledge of its type. Java and C# get around this through reflection - not ideal but it works. Delphi has a datatype design to hold class references that make dynamic instantiation very easy. Does D have a similar facility? If not, could you explain why this feature wasn't included as it strikes me as being an absolutely vital feature of any OO language. I also notice that someone else asked a similar question in this newsgroup in Feb 2001; Has any progress been made in this area since then? > >Cheers, > >Barry Carr > >Ixian Software Components Ltd >Blairgowrie >Perthshire >Scotland >www.Ixian-Software.com |
December 28, 2003 Re: Dynamic Capabilities of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to davepermen | In article <bsmu5g$1m96$1@digitaldaemon.com>, davepermen says... > >dunno why this should be vital at all.. D is not a scripting language, and not written in runtime.. why should it be able to create objects of unknown type at runtime? there are simply no unkown types anymore at runtime. > >and creating a factory in D is ridiculous easy.. so no problem. > >In article <Xns945F864EEC85Abarrycarrixiansoftwa@63.105.9.61>, Barry Carr says... >> >>Hi, >> >>I was looking at the language comparison chart for D and I was wondering how dynamic was the language at runtime? >> >>One of the things that I don't like about C++ is its lack of virtual constructors, or any other mechanism within the language to be able to instantiate an object without compile time knowledge of its type. Java and C# get around this through reflection - not ideal but it works. Delphi has a datatype design to hold class references that make dynamic instantiation very easy. Does D have a similar facility? If not, could you explain why this feature wasn't included as it strikes me as being an absolutely vital feature of any OO language. I also notice that someone else asked a similar question in this newsgroup in Feb 2001; Has any progress been made in this area since then? >> >>Cheers, >> >>Barry Carr >> >>Ixian Software Components Ltd >>Blairgowrie >>Perthshire >>Scotland >>www.Ixian-Software.com > > |
December 28, 2003 Re: Dynamic Capabilities of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Barry Carr | Hmm, you own Ixian software ? Is that a dune refrence ? C "Barry Carr" <barrycarr@ixian-software.com> wrote in message news:Xns945F864EEC85Abarrycarrixiansoftwa@63.105.9.61... > Hi, > > I was looking at the language comparison chart for D and I was wondering how dynamic was the language at runtime? > > One of the things that I don't like about C++ is its lack of virtual constructors, or any other mechanism within the language to be able to instantiate an object without compile time knowledge of its type. Java and C# get around this through reflection - not ideal but it works. Delphi has a datatype design to hold class references that make dynamic instantiation very easy. Does D have a similar facility? If not, could you explain why this feature wasn't included as it strikes me as being an absolutely vital feature of any OO language. I also notice that someone else asked a similar > question in this newsgroup in Feb 2001; Has any progress been made in this area since then? > > Cheers, > > Barry Carr > > Ixian Software Components Ltd > Blairgowrie > Perthshire > Scotland > www.Ixian-Software.com |
December 28, 2003 Re: Dynamic Capabilities of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Barry Carr | Barry Carr wrote:
> Hi,
>
> I was looking at the language comparison chart for D and I was wondering
> how dynamic was the language at runtime?
>
> One of the things that I don't like about C++ is its lack of virtual constructors, or any other mechanism within the language to be able to instantiate an object without compile time knowledge of its type. Java and C# get around this through reflection - not ideal but it works. Delphi has a datatype design to hold class references that make dynamic instantiation very easy. Does D have a similar facility? If not, could you explain why this feature wasn't included as it strikes me as being an absolutely vital feature of any OO language. I also notice that someone else asked a similar question in this newsgroup in Feb 2001; Has any progress been made in this area since then?
Maybe my C++ background is showing, but I've never found this to be much of a problem. The prototype and factory patterns accomplish this without much fuss. I have used this sort of thing in Python, but not enough that I'd call it a vital feature of the language.
-- andy
|
December 28, 2003 Re: Dynamic Capabilities of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to davepermen | davepermen <davepermen_member@pathlink.com> wrote in news:bsmu5g$1m96$1@digitaldaemon.com: > dunno why this should be vital at all.. D is not a scripting language, and not written in runtime.. why should it be able to create objects of unknown type at runtime? there are simply no unkown types anymore at runtime. > > and creating a factory in D is ridiculous easy.. so no problem. It is vital because an application should be a network of autonomous objects able to react to new situations (within reason) and work with derived classes without any trouble - as Liskov states. For instance: loading plugins at runtime (dlls are not adquate for this purpose as they don't allow access to objects unless you use COM); streaming in and creating objects etc. esp. if you're using an OODBMS; any form of data driven application is extremly difficult to construct without this facility. Having the ability to create instances dynamically adds an extra dimension of flexibility to your software at NO extra cost if the feature is support by the language. I can never understand why the C++ community cannot see this - instead they bang on about how you don't need it. Why does the C++ community defend this position when they could be petitioning for this feature to be added? If the facility is there you are not compelled to use it, but with out it all other options are kludges and workarounds (IMHO). An OO language should support the ability to create objects anonimously. When I used to use C++ the lack of this feature caused me no end of problems, it was one of the main reasons why I ditched it. Factories are NOT the answer, as adding new classes to the app means making changes to the factory. Factories are not orthogonal. And I didn't say D was a scripting language and non of the example languages I cited were scripting languages either. It is possible to have this feature in an efficent compiled language with no cost to runtime performance; esp. in garbage collected language because the gc is going to take up more time then any extra runtime info will do. I'm not here to start a language war - I just want to understand why the C++ community does think this is an important feature, esp when it has every other feature under the sun crammed in there? And why D, as an improvement to C++ (which it certainly looks likes), hasn't added this feature either. Cheers Barry Carr Ixian Software Components Ltd |
December 28, 2003 Re: Dynamic Capabilities of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles | "Charles" <sanders-consulting@comcast.net> wrote in news:bsn0tu$1rcr$1@digitaldaemon.com: > Hmm, you own Ixian software ? Is that a dune refrence ? > Yup! well spotted. Cheers Barry Carr Ixian Software Components Ltd |
December 28, 2003 Re: Dynamic Capabilities of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Friesen | Andy Friesen wrote:
> Barry Carr wrote:
>
>> Hi,
>>
>> I was looking at the language comparison chart for D and I was wondering
>> how dynamic was the language at runtime?
>> One of the things that I don't like about C++ is its lack of virtual constructors, or any other mechanism within the language to be able to instantiate an object without compile time knowledge of its type. Java and C# get around this through reflection - not ideal but it works. Delphi has a datatype design to hold class references that make dynamic instantiation very easy. Does D have a similar facility? If not, could you explain why this feature wasn't included as it strikes me as being an absolutely vital feature of any OO language. I also notice that someone else asked a similar question in this newsgroup in Feb 2001; Has any progress been made in this area since then?
>
>
> Maybe my C++ background is showing, but I've never found this to be much of a problem. The prototype and factory patterns accomplish this without much fuss. I have used this sort of thing in Python, but not enough that I'd call it a vital feature of the language.
>
> -- andy
It's not so much the language background, as the selection of problems you deal with. (That is, of course, constrained by the language you use.) Most modern languages are "complete", but the jobs that one tends to tackle with them are the jobs that they make easy to solve. One could theoretically implement a full object system with persistent memory caching and distributed computational capabilities in C. In fact, Gnome practically is such a project. But doing this in C means that you must carry around a huge amount of custom created software. And Gnome doesn't think of itself as the project that I've described, despite the fact that about half (WAG) of the project is useful towards those ends.
Prototype and factory don't do this. They don't approach it. And a modern language should contain "hooks" to support this kind of thing. But this is a far different thing than saying that the language should, itself, support this. The capabilities probably fit more neatly into a standard library. But the hooks to enable them need to be present in the basic language. You can't write a factory to deal with an unknown object being presented to you from a machine at the other end of a telecom line. OTOH, what you need is some way to a) run things in a sandbox and b) allow code to be treated as a first class object. (I'm not sure whether it should be source or binary, though I lean towards source, which means that this capability would only be present when the compiler was present, but it allows portability between architectures. Java does this with "jvm" code, but I prefer source anyway, though you could compress it.) Note that this basically means that the library needs to be able to link in a routine that is built during the code execution. No "magic" required. But the alternative is sometimes the requirement to embed a FORTH, LISP, or Python engine into the code. And run them in a sandbox...so you've still got the need for a sandbox.
|
December 28, 2003 Re: Dynamic Capabilities of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Barry Carr | Ok, I'll bite, being predominantly a C++ person.
I am prepared to be compelled, so please supply a compelling example.
:)
--
Matthew Wilson
STLSoft moderator (http://www.stlsoft.org)
Contributing editor, C/C++ Users Journal
(www.synesis.com.au/articles.html#columns)
"If I'm curt with you it's because time is a factor. I think fast, I talk fast, and I need you guys to act fast" -- Mr Wolf
----------------------------------------------------------------------------
---
"Barry Carr" <barrycarr@ixian-software.com> wrote in message news:Xns945FD4AE1AF7Fbarrycarrixiansoftwa@63.105.9.61...
> davepermen <davepermen_member@pathlink.com> wrote in news:bsmu5g$1m96$1@digitaldaemon.com:
>
> > dunno why this should be vital at all.. D is not a scripting language, and not written in runtime.. why should it be able to create objects of unknown type at runtime? there are simply no unkown types anymore at runtime.
> >
> > and creating a factory in D is ridiculous easy.. so no problem.
>
> It is vital because an application should be a network of autonomous objects able to react to new situations (within reason) and work with derived classes without any trouble - as Liskov states. For instance: loading plugins at runtime (dlls are not adquate for this purpose as they don't allow access to objects unless you use COM); streaming in and creating objects etc. esp. if you're using an OODBMS; any form of data driven application is extremly difficult to construct without this facility. Having the ability to create instances dynamically adds an extra dimension of flexibility to your software at NO extra cost if the feature is support by the language.
>
> I can never understand why the C++ community cannot see this - instead they bang on about how you don't need it. Why does the C++ community defend this position when they could be petitioning for this feature to be added? If the facility is there you are not compelled to use it, but with out it all other options are kludges and workarounds (IMHO). An OO language should support the ability to create objects anonimously.
>
> When I used to use C++ the lack of this feature caused me no end of problems, it was one of the main reasons why I ditched it. Factories are NOT the answer, as adding new classes to the app means making changes to the factory. Factories are not orthogonal.
>
> And I didn't say D was a scripting language and non of the example languages I cited were scripting languages either. It is possible to have this feature in an efficent compiled language with no cost to runtime performance; esp. in garbage collected language because the gc is going to take up more time then any extra runtime info will do.
>
> I'm not here to start a language war - I just want to understand why the C++ community does think this is an important feature, esp when it has every other feature under the sun crammed in there? And why D, as an improvement to C++ (which it certainly looks likes), hasn't added this feature either.
>
> Cheers
>
> Barry Carr
> Ixian Software Components Ltd
|
December 28, 2003 Re: Dynamic Capabilities of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Barry Carr | I've never had a problem with it, then again I've never used it, can you give an example in a compiled language that has this ability ( reflection its called ? ). I must say it looks very cool , though I'm not sure how a 'compiled' language would implement it. C "Barry Carr" <barrycarr@ixian-software.com> wrote in message news:Xns945FD4AE1AF7Fbarrycarrixiansoftwa@63.105.9.61... > davepermen <davepermen_member@pathlink.com> wrote in news:bsmu5g$1m96$1@digitaldaemon.com: > > > dunno why this should be vital at all.. D is not a scripting language, and not written in runtime.. why should it be able to create objects of unknown type at runtime? there are simply no unkown types anymore at runtime. > > > > and creating a factory in D is ridiculous easy.. so no problem. > > It is vital because an application should be a network of autonomous objects able to react to new situations (within reason) and work with derived classes without any trouble - as Liskov states. For instance: loading plugins at runtime (dlls are not adquate for this purpose as they don't allow access to objects unless you use COM); streaming in and creating objects etc. esp. if you're using an OODBMS; any form of data driven application is extremly difficult to construct without this facility. Having the ability to create instances dynamically adds an extra dimension of flexibility to your software at NO extra cost if the feature is support by the language. > > I can never understand why the C++ community cannot see this - instead they bang on about how you don't need it. Why does the C++ community defend this position when they could be petitioning for this feature to be added? If the facility is there you are not compelled to use it, but with out it all other options are kludges and workarounds (IMHO). An OO language should support the ability to create objects anonimously. > > When I used to use C++ the lack of this feature caused me no end of problems, it was one of the main reasons why I ditched it. Factories are NOT the answer, as adding new classes to the app means making changes to the factory. Factories are not orthogonal. > > And I didn't say D was a scripting language and non of the example languages I cited were scripting languages either. It is possible to have this feature in an efficent compiled language with no cost to runtime performance; esp. in garbage collected language because the gc is going to take up more time then any extra runtime info will do. > > I'm not here to start a language war - I just want to understand why the C++ community does think this is an important feature, esp when it has every other feature under the sun crammed in there? And why D, as an improvement to C++ (which it certainly looks likes), hasn't added this feature either. > > Cheers > > Barry Carr > Ixian Software Components Ltd |
Copyright © 1999-2021 by the D Language Foundation