Dynamic language

F i L witte2008 at gmail.com
Thu Mar 15 14:56:46 PDT 2012


> Paulo Pinto wrote:
> The main benefit dynamic languages bring to the table is not 
> requiring to
> write types everywhere, duck typing, and the flexibility 
> metaprogramming
> has.

I'll give you the metaprogramming bit, but duck-typing is rarely 
a benefit over languages, like D and C#, which support 
"auto"/"var" keywords. I'd actually argue that getting early 
compile-time error when I accidentally change variable type 
(except in areas I explicitly want it) is actually a time saver 
of statically typed languages. Granted casting types is a bit 
lower-level concept and can be a pain to type.


> Andrei Alexandrescu wrote:
> Relevant insight: 
> http://existentialtype.wordpress.com/2011/03/19/dynamic-languages-are-static-languages/

Thanks for the link. I understand all code eventually becomes 
binary, of course, and I have a pretty good understanding of how 
V8 JS functions internally. I just can't see why someone would 
want to use an "expressively straightjacketed" (as the article 
puts it) language when they have the option not to.


> Adam D. Ruppe wrote:
> import std.variant;
> struct Extendable {
>     Variant[string] properties;
>     Variant opDispatch(string name)() {
>        return properties[name];
>     }
>     Variant opDispatch(string name, T)(T t) {
>        properties[name] = t;
>        return properties[name];
>     }
> }
> 
> void main() {
>     auto a = Extendable();
>     a.sweet = 10;
>     a.cool = { a.sweet = a.sweet + 1; }
>     a.cool();
> }

Awesome! I knew it was possible, just didn't think it'd be that 
easy! You know, it might be nice to an std.dynamic or extend 
variant to include a general purpose Dynamic type. Just a thought.


> so Wrote:
> I'd love to use D but it is not an option is it? At least for 
> the
> things i am after, say game scripting.

I think D's a great option. A D compiler would only have to be 
distributed with the  tool-chain/editor, and scripts could be 
statically compiled with the rest of engine. Safe-D is safe, and 
comparably easy to understand as other common scripting languages 
(Unity's uses C# for example) and advanced scripters would have 
the options of getting real low-level with their logic blocks. 
Plus, if the rest of the game engine was written in D, 
integrating the scripts would be completely seamless.


~~~~~~~~~~


On a completely irrelevant, but slightly related note: I have 
just released my first Unity 3D game for Android/iPhone, Space 
Pizza Delivery! 
(https://play.google.com/store/apps/details?id=com.ReignStudios.SpacePizzaDelivery)

Woohoo! It's simple, but fun, and we have a much more ambitious 
project in the works. Hopefully the start of my game-maker 
career! :-D (and yes, I am shamelessly advertising ;p)


More information about the Digitalmars-d mailing list