Dynamic language

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Mar 15 15:53:41 PDT 2012


On Thu, Mar 15, 2012 at 06:15:39PM -0400, Nick Sabalausky wrote:
> "H. S. Teoh" <hsteoh at quickfur.ath.cx> wrote in message 
> news:mailman.713.1331843912.4860.digitalmars-d at puremagic.com...
> > On Thu, Mar 15, 2012 at 04:13:42PM -0400, Nick Sabalausky wrote:
> >> "H. S. Teoh" <hsteoh at quickfur.ath.cx> wrote in message
> >> news:mailman.709.1331842273.4860.digitalmars-d at 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.


More information about the Digitalmars-d mailing list