March 15, 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)
March 15, 2012
"H. S. Teoh" <hsteoh@quickfur.ath.cx> wrote in message news:mailman.713.1331843912.4860.digitalmars-d@puremagic.com...
> On Thu, Mar 15, 2012 at 04:13:42PM -0400, Nick Sabalausky wrote:
>> "H. S. Teoh" <hsteoh@quickfur.ath.cx> wrote in message news:mailman.709.1331842273.4860.digitalmars-d@puremagic.com...
>> > On Thu, Mar 15, 2012 at 09:15:34PM +0200, Manu wrote:
>> >> On 15 March 2012 20:59, so <so@so.so> wrote:
>> > [...]
>> >> > On Thursday, 15 March 2012 at 17:30:49 UTC, Adam D. Ruppe wrote:
>> > [...]
>> >> >> I just talked about D because D rox, but if you are doing it for education, Lisp is a good choice because it is fairly unique.
>> >> >>
>> >> >
>> >> > 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 dunno, that sounds like a pretty interesting idea to me! :)
>> >
>> > It certainly is, though it does bring up the problem of what to do if the game scripting is editable at runtime. Does that mean we'll need to bundle a D compiler with the game? Doesn't seem practical.
>> >
>>
>> Why not?
> [...]
>
> So your game will have to ship with dmd and optlink bundled?
>

As long as it's a platform on which dmd runs, and you have permission from Walter, I don't see the problem with that. Sure, it'd be another thing to deal with in the installation/packaging scripts, but it shouldn't be too bad.

Plus, people have already done the same sort of thing with Python/Ruby (not sure about games, but other apps). Yea, scripting in Python/Ruby is probably super-easy if your app is already written in Python/Ruby, but when isn't then you're really just doing the same thing as you would to do your scripting in D.

'Course, if you *like* dynamic interpreted languages, then yea, just simply using Lua would be easier. Point is though, I don't think I'd say it's impractical with D. At least for desktop/laptop games anyway (platforms dmd doesn't run *on* could still use D for scripting, but just not edited in-game - could still reload in-game if the platform has dynamic lib support, but it'd be compiled off-line...possibly even by the game sending the code to a compile server).

And all that would only matter for user-generated content. Any built-in scripts would naturally just already come pre-built. Hell, they could even come statically-linked if you wanted - develop them using the dynamic editing tools, and then statically link when you're ready to ship.

Speaking of such things, I wonder how hard it would be to port dmd to run on another platform? Targeting that platform might be a lot of work, but just making it run on it...it *is* written in C++, probably the second-most common language in the world (just behind straight C), and it's not like it does a bunch direct hardware I/O access, or GUI, or anything like that. So I'd imagine mostly just some occasional OS calls and assembly. Don't know how much of that there is in there.

> -- 
> "The number you have dialed is imaginary. Please rotate your phone 90 degrees and try again."

I love this one :)


March 15, 2012
On Thu, Mar 15, 2012 at 3:56 PM, F i L <witte2008@gmail.com> wrote:

> 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/<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<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)
>

Got a score of 292 while spending most of the time with just a sliver of life.  Those sneaky health powerups kept getting knocked off the screen before they'd reach me.  Fun though.

Regards,
Brad Anderson


March 15, 2012
On 15 March 2012 22:12, H. S. Teoh <hsteoh@quickfur.ath.cx> wrote:

> On Thu, Mar 15, 2012 at 09:15:34PM +0200, Manu wrote:
> > On 15 March 2012 20:59, so <so@so.so> wrote:
> [...]
> > > On Thursday, 15 March 2012 at 17:30:49 UTC, Adam D. Ruppe wrote:
> [...]
> > >> I just talked about D because D rox, but if you are doing it for education, Lisp is a good choice because it is fairly unique.
> > >>
> > >
> > > 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 dunno, that sounds like a pretty interesting idea to me! :)
>
> It certainly is, though it does bring up the problem of what to do if the game scripting is editable at runtime. Does that mean we'll need to bundle a D compiler with the game? Doesn't seem practical.
>

Do you expect users to be modifying the scripts in the retail release?
Surely scripting is still for what it has always been for, rapid
iteration/prototyping during development.
Hot-plugging DLL's written in D sounds pretty interesting to me :) .. You
only need the compiler as a part of the games asset-pipeline, and can
static link when you release for extra FPS's!


March 15, 2012
On 16 March 2012 11:37, Manu <turkeyman@gmail.com> wrote:
> Do you expect users to be modifying the scripts in the retail release?
> Surely scripting is still for what it has always been for, rapid
> iteration/prototyping during development.
> Hot-plugging DLL's written in D sounds pretty interesting to me :) .. You
> only need the compiler as a part of the games asset-pipeline, and can static
> link when you release for extra FPS's!

Also, less files to download, I like a lot of indie games because they are often a single binary, more things need to have the assets compiled in...

--
James Miller
March 15, 2012
Brad Anderson wrote:
> Got a score of 292 while spending most of the time with just a sliver of
> life.  Those sneaky health powerups kept getting knocked off the screen
> before they'd reach me.  Fun though.
>
> Regards,
> Brad Anderson

Ha! I once got a score of ~1,200 on my Tablet. You get more points by shooting asteroids and picking up the items. Thanks for the support, btw! :D


March 15, 2012
On Thu, 15 Mar 2012 18:09:37 +1100, so <so@so.so> wrote:

> Hello,
>
> Not related to D but this is a community which i can find at least a few objective person. I want to invest some "quality" time on a dynamic language but i am not sure which one. Would you please suggest one?
>
> To give you an idea what i am after:
> Of all one-liners i have heard only one gets me.
> "The programmable programming language". Is it true? If so Lisp will be my first choice.

I'm not so objective, but don't let that dissuade you.

For a programmable language, you might want to look at Forth. I use it as an embedded scripting language in a couple of my programs.

For a language that has built-in static types and built-in dynamic types, you might want to check out the Euphoria language at
http://www.openeuphoria.org  and also as a web language:  http://openeuphoria.org/forum/117802.wc?last_id=117805

-- 
Derek
March 15, 2012
On Thu, Mar 15, 2012 at 06:15:39PM -0400, Nick Sabalausky wrote:
> "H. S. Teoh" <hsteoh@quickfur.ath.cx> wrote in message news:mailman.713.1331843912.4860.digitalmars-d@puremagic.com...
> > On Thu, Mar 15, 2012 at 04:13:42PM -0400, Nick Sabalausky wrote:
> >> "H. S. Teoh" <hsteoh@quickfur.ath.cx> wrote in message news:mailman.709.1331842273.4860.digitalmars-d@puremagic.com...
[...]
> >> > It certainly is, though it does bring up the problem of what to do if the game scripting is editable at runtime. Does that mean we'll need to bundle a D compiler with the game? Doesn't seem practical.
> >> >
> >>
> >> Why not?
> > [...]
> >
> > So your game will have to ship with dmd and optlink bundled?
> >
> 
> As long as it's a platform on which dmd runs, and you have permission from Walter, I don't see the problem with that. Sure, it'd be another thing to deal with in the installation/packaging scripts, but it shouldn't be too bad.

Oh, I wasn't worried about the licensing part. It's more about needing to ship dmd + druntime sources (and possibly some game-specific .d libraries), plus optlink. Which is not horrible, I suppose. But it feels a bit like buying a chair from IKEA and getting a toolbox, a full set of tools, 5 boxes of nails of different types, a power-drill, an engine replacement kit, and a sledgehammer included in the box. :-)


> Plus, people have already done the same sort of thing with Python/Ruby (not sure about games, but other apps). Yea, scripting in Python/Ruby is probably super-easy if your app is already written in Python/Ruby, but when isn't then you're really just doing the same thing as you would to do your scripting in D.

True.


> 'Course, if you *like* dynamic interpreted languages, then yea, just simply using Lua would be easier. Point is though, I don't think I'd say it's impractical with D. At least for desktop/laptop games anyway (platforms dmd doesn't run *on* could still use D for scripting, but just not edited in-game - could still reload in-game if the platform has dynamic lib support, but it'd be compiled off-line...possibly even by the game sending the code to a compile server).

Actually, I like this idea. Don't ship the compiler/linker (which feels like overkill), but user-generated scripts will be compiled by an online server and sent back to the game as a DLL.

Although that does have potential for abuse... somebody could figure out the game/server protocol and use it as a compile-farm for arbitrary D code. Or write a "script" that contains a complete D app and use the game to compile it "for free" using the game server's resources.

It can also be a security concern. Somebody could offer players an "awesome script" in DLL form that actually contains arbitrary exploit code. Or a "script" that contains D code for an exploit.


> And all that would only matter for user-generated content. Any built-in scripts would naturally just already come pre-built. Hell, they could even come statically-linked if you wanted - develop them using the dynamic editing tools, and then statically link when you're ready to ship.

I like this.


> Speaking of such things, I wonder how hard it would be to port dmd to run on another platform? Targeting that platform might be a lot of work, but just making it run on it...it *is* written in C++, probably the second-most common language in the world (just behind straight C), and it's not like it does a bunch direct hardware I/O access, or GUI, or anything like that. So I'd imagine mostly just some occasional OS calls and assembly. Don't know how much of that there is in there.

What's the point of dmd running on some platform but unable to generate code for it? Cross-compiling from your Android to your PC? Sounds a bit backwards to me. :-) (Though it might be useful if you're travelling and working on code on a portable device.)


[...]
> > "The number you have dialed is imaginary. Please rotate your phone 90 degrees and try again."
> 
> I love this one :)

A related one: Life is complex. It consists of real and imaginary parts.


T

-- 
There are three kinds of people in the world: those who can count, and those who can't.
March 15, 2012
"H. S. Teoh" <hsteoh@quickfur.ath.cx> wrote in message news:mailman.712.1331843803.4860.digitalmars-d@puremagic.com...
> On Thu, Mar 15, 2012 at 03:24:24PM -0400, Nick Sabalausky wrote: [...]
>> - If you can stomach the indent-scoping, Python is very well-regarded and has a lot of fancy advanced features.
>
> I used to despise Python's indent-scoping too, though since then I've had some opportunity to use Python for build scripts (google for SCons), and I have to say that it certainly has its own kind of beauty to it. You never have to worry about closing blocks in if statements and the like, for example, and you never have subtle bugs like:
>
> auto func(bool x) {
> int y=0;
> if (x)
> y = 1;
> writeln("x is true");
>
> return y;
> }
>
> But I certainly sympathize with the WAT sentiment when one first learns that Python has indent scoping. :-)
>

I've used some Python, and I've done a fair amount of SPIN (Parallax's Propeller microcontroller) which also does indent-scoping. Granted, SPIN is a lousy language (the Propeller is awesome though) regardless of its indent-scoping, but still, even the indent-scoping *itself* never ceased being irritating for me, for various different reasons.

I do like the indent-scoping in YAML, though. But that's very different: It's optional in YAML and YAML's only a data langauge, not a programming language.

As far as SCons, though, I haven't done much with it, but I have looked into it. Even though it techically is Python, I'd argue that its charter leaves it somewhat more similar to YAML than actually writing a whole program in Python.

>
> [...]
>> - If you're looking for the most painful dynamic experince imaginable, ActionScript2 should be at the top of your list. Make sure to use all-Adobe tools, and the newest versions of each, so the whole experience will be *truly* unbearable.
>
> Shouldn't that be ActionScript3?
>

I've never used ActionScript3. I've heared it's better, but I have no idea how much better.

ActionScript2 is truly horrid though. Almost any error that isn't an outright syntax error is *completely* ignored. So if you sneeze wrong near one end of the codebase, then something clear over in another section will just...act wrong, for no apperent reason. I've wasted hours on things like trying to figure out why an image or text wasn't showing up, or was displayed wrong, just becase I declared some *other* object or array and forgot to manually initialize it with a "new MyClass()" or a "new Array()". That's right: you can dereference null, but it isn't an error: it's a no-op that triggers a cascade of no-ops. (And shit, even the heavily-static D lets you declare an array and just start appending to it - and have the data actually *stick* and not be mysteriously gone when you try to read it back.)

The API is awful, too. MovieClip, the *foundation* of AS2-based Flash, has got to be the most poorly designed sprite class I've ever seen. When I switched to Haxe, I ended up going to great lengths to wrap MovieClip in a much more sane Sprite class.

I think the only way they could have made ActionScript2 worse is if they made it indent-syntax. Ok, and entirely removed what little declaring and type-tagging it does have.

And the IDE is wretched. It has one of the most awkward editors I've used, and the bloat...christ, the bloat gets twice as bad with each version, the UI gets more goofily-skinned with each version, and the bloat in CS5 - honest to god - it makes a fully loaded Eclipse seem downright *lean*.


> (And no, I would not touch any of this stuff with a 10-foot pole.)
>

With ActionScript, ignorance truly is bliss. I'd probably be a happier, [somewhat] less disgruntled man if I'd never needed to use it.

>
>> I admit though, I'm not very familiar with the extent of the metaprogramming abilities of any of those languages.
> [...]
>
> I can't say I'm familiar with all the languages you listed either, but in my limited experience, I find that D's metaprogramming capabilities outright beats every other language I know by a loooong shot.
>

Yea, I do agree. Admittedly D isn't "dynamic" enough to do so called "monkey patching" like some languages can, but really that's a *benefit*.

From what I've seen, dynamic and interpreted languages generally prefer to do runtime tricks *instead* of things we would consider "metaprogramming". Which does stay neatly in line with the standard dynamic/interpreted manifesto of "Efficiency? What's that?"

> C++ seems to come farther than most other languages, but its horrible template syntax is just ... unpalatable. I mean, before C++11, even something as straightforward as vector<vector<int>> is a syntax error. How ridiculous is that?!

Seriously? Christ, I knew it was bad, but I'd never have guessed anything like that. Even Haxe can handle that.

> Nevermind the dubious wisdom of using <> for
> template arguments in the first place (try, e.g., a template with bool
> arguments that you want to instantiate with expressions that have
> comparison operators).  Sure, C++ templates are Turing-complete. They're
> also Turing tarpits for anything except the most trivial uses.
>
> D templates + CTFE rox the sox off C++ any day.
>

God yes. The only thing I've ever seen that comes close is Nemerle, which takes a whole different approach that's both better and worse than D, just in different ways. But Nemerle's strictly locked behind the VM wall (.NET), so it's not exactly the same class of language as D.


March 15, 2012
On 16 March 2012 12:05, Nick Sabalausky <a@a.a> wrote:
> "H. S. Teoh" <hsteoh@quickfur.ath.cx> wrote in message news:mailman.712.1331843803.4860.digitalmars-d@puremagic.com...
>> On Thu, Mar 15, 2012 at 03:24:24PM -0400, Nick Sabalausky wrote: [...]
>>> - If you can stomach the indent-scoping, Python is very well-regarded and has a lot of fancy advanced features.
>>
>> I used to despise Python's indent-scoping too, though since then I've had some opportunity to use Python for build scripts (google for SCons), and I have to say that it certainly has its own kind of beauty to it. You never have to worry about closing blocks in if statements and the like, for example, and you never have subtle bugs like:
>>
>> auto func(bool x) {
>> int y=0;
>> if (x)
>> y = 1;
>> writeln("x is true");
>>
>> return y;
>> }
>>
>> But I certainly sympathize with the WAT sentiment when one first learns that Python has indent scoping. :-)
>>
>
> I've used some Python, and I've done a fair amount of SPIN (Parallax's Propeller microcontroller) which also does indent-scoping. Granted, SPIN is a lousy language (the Propeller is awesome though) regardless of its indent-scoping, but still, even the indent-scoping *itself* never ceased being irritating for me, for various different reasons.
>
> I do like the indent-scoping in YAML, though. But that's very different: It's optional in YAML and YAML's only a data langauge, not a programming language.
>
> As far as SCons, though, I haven't done much with it, but I have looked into it. Even though it techically is Python, I'd argue that its charter leaves it somewhat more similar to YAML than actually writing a whole program in Python.
>
>>
>> [...]
>>> - If you're looking for the most painful dynamic experince imaginable, ActionScript2 should be at the top of your list. Make sure to use all-Adobe tools, and the newest versions of each, so the whole experience will be *truly* unbearable.
>>
>> Shouldn't that be ActionScript3?
>>
>
> I've never used ActionScript3. I've heared it's better, but I have no idea how much better.
>
> ActionScript2 is truly horrid though. Almost any error that isn't an outright syntax error is *completely* ignored. So if you sneeze wrong near one end of the codebase, then something clear over in another section will just...act wrong, for no apperent reason. I've wasted hours on things like trying to figure out why an image or text wasn't showing up, or was displayed wrong, just becase I declared some *other* object or array and forgot to manually initialize it with a "new MyClass()" or a "new Array()". That's right: you can dereference null, but it isn't an error: it's a no-op that triggers a cascade of no-ops. (And shit, even the heavily-static D lets you declare an array and just start appending to it - and have the data actually *stick* and not be mysteriously gone when you try to read it back.)
>
> The API is awful, too. MovieClip, the *foundation* of AS2-based Flash, has got to be the most poorly designed sprite class I've ever seen. When I switched to Haxe, I ended up going to great lengths to wrap MovieClip in a much more sane Sprite class.
>
> I think the only way they could have made ActionScript2 worse is if they made it indent-syntax. Ok, and entirely removed what little declaring and type-tagging it does have.
>
> And the IDE is wretched. It has one of the most awkward editors I've used, and the bloat...christ, the bloat gets twice as bad with each version, the UI gets more goofily-skinned with each version, and the bloat in CS5 - honest to god - it makes a fully loaded Eclipse seem downright *lean*.
>
>
>> (And no, I would not touch any of this stuff with a 10-foot pole.)
>>
>
> With ActionScript, ignorance truly is bliss. I'd probably be a happier, [somewhat] less disgruntled man if I'd never needed to use it.

I hate the fact that Flash games are created the way they are. For one, it's impenetrable to try and learn properly, I had so much trouble figuring out how to do things properly, you can attach scripts to almost any object, but sometimes it might be shared over all of the same objects, and other times only on that instance, depending on how you've placed them on the canvas.

I probably wrote some terrible code when I started making Flash games, and now Actionscript is so foreign to me that i can barely understand where to start.

--
James Miller