python vs d

Kapps via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 28 12:34:36 PDT 2014


On Monday, 28 April 2014 at 18:18:25 UTC, Ola Fosheim Grøstad 
wrote:
> On Monday, 28 April 2014 at 18:07:45 UTC, John Colvin wrote:
>> What features does python, as a language (syntactical 
>> preferences aside), actually have to recommend it over D 
>> (assuming drepl* or similar became full-featured)?
>
> Libraries.
> For closures for arrays and dicts.
> Tuples.
> Heavy duty reflection and runtime dynamics.
> (Runtime extensible classes.)
> (Runtime integration of python and templates.)
> System support (app engine, etc).
> Lots of how-to-stuff on the web.

D can actually do a rather good job of runtime reflection. I made 
a runtime reflection module 
(https://shardsoft.com/stash/projects/SHARD/repos/shardtools/browse/source/ShardTools/Reflection.d 
/ https://shardsoft.com/docs/ShardTools/Reflection.html) for my 
own personal code and it's served the uses I've needed it for 
quite nicely. Python I'd imagine has runtime reflection by 
default, but you could do this in D too by using RTInfo to 
automatically generate reflection data for every class. And while 
I'm sure Python has much more advanced reflection capabilities, I 
don't think the vast majority of users really require much more 
than the basics like looking up fields / invoking methods from 
user input, which D can easily handle. In the situations where 
you do need a completely dynamic type, people have already made 
such types in D by using opDispatch 
(http://forum.dlang.org/post/kuxfkakrgjaofkrdvgmx@forum.dlang.org).

(I wouldn't recommend others to use my reflection module directly 
as it'll get breaking changes and probably has bugs, but it's 
Boost licensed so if anyone wanted to they could add relevant 
parts into their project. I think it's also responsible for very 
large executables on OSX/Linux, but not on Windows.)


More information about the Digitalmars-d mailing list