Download presentation
Presentation is loading. Please wait.
1
Scripting Languages For Virtual Worlds
2
Outline Necessary Features Classes, Prototypes, and Mixins Static vs. Dynamic Typing Concurrency Versioning Distribution States Time Security User Concerns
3
Necessary Features Garbage Collection Event driven programming Fault tolerance Standard library
4
Classes, Prototypes, and Mixins http://flickr.com/photos/orangeacid/273899875/http://flickr.com/photos/eondxd/672917412/ (Multiple Inheritance)(Prototype Cloning)
5
Classes, Prototypes, and Mixins Classes –Classes define behavior –Inheritance allows reuse of code Single inheritance () + Interfaces vs. Multiple Inheritance (C++) –Dynamic classes force updates –C++, Java, Python, Ruby, ….
6
Classes, Prototypes, and Mixins Prototypes (a.k.a. classless, instance-based) –Objects contain methods, code reuse by cloning –Delegation Parent references maintained, method dispatch traces up tree Changes to parent classes are forced to propagate if not overloaded by child class –Concatenation Pure concatenative prototyping – prototype copied exactly but given new name Efficient dispatch, less efficient storage Changes not easily propagated –MOO, Javascript, Lua, Self
7
Classes, Prototypes, and Mixins Mixins –A way to reuse code efficiently from multiple sources without using multiple inheritance –Mixing in a module copies all the methods in that module to the class Same copy vs. reference problem as prototypes –Usually there is a way to check if a module has been mixed in => similar to type checking
8
Static vs. Dynamic Typing http://flickr.com/photos/johncharlton/303794703/
9
Static vs. Dynamic Typing Static Typing –All variable types known at compile time –Type errors can be caught at compile time –How many errors are type errors? –Optimizations –Type inference
10
Static vs. Dynamic Typing Dynamic Typing –Variable types not known until runtime –Eval –Metaprogramming –Duck Typing Responds to vs. kind of
11
Static vs. Dynamic Typing MOO –Prototype based – closest to duck typing LSL –Statically typed –But interaction between objects handled by messages without type checking Unreal Script –Statically typed
12
Concurrency
13
Types of parallelism –Instruction level parallelism –Data parallelism –Task parallelism Implicit vs. Explicit Parallelism
14
Concurrency Object scripts are independent of each other Components of scripts may largely be independent of each other Some form of language or library support for exploiting this is necessary for a scalable solution
15
Stream Processing Exploits data parallelism by making data that can be operated on in parallel a built-in type Streams are sequences of data to be operated on Kernels are code blocks to be performed on the data Streams flow through series of kernels to produce final output Examples: Brook, CUDA
16
Shared-memory / Threading Multiple threads running concurrently –Procedural or object-oriented code –Possibly sharing memory Communication between threads –Shared memory –Mutexes / condition variables Examples: POSIX Threads, OpenMP, Java
17
Distributed-memory / Actor Model Actor Model –Actor – computational entity that responds to messages by, concurrently Sending messages to other actors Create new actors Change behavior for messages received in the future –Asynchronous messaging, no shared memory Erlang, E, MPI, Smalltalk
18
States http://flickr.com/photos/hipocondriaca/76085098/
19
States State based programming –Multiple states, each containing methods –Methods can be overloaded in different states –Could be accomplished using switch statements inside a single method –Complicates inheritance –Mixins? Multidimensional states?
20
Versioning
21
Continuously running system Scripts can be updated at any time MOO – prototype based, no versioning support LSL – scripts local to object only, no need for versioning
22
Distributed Computation
23
Two aspects of distribution –Language (or library) supports distributed objects –Distributing the interpreter itself
24
Distributed Computation Distributed Objects –Remote Procedure Call / Remote Method Invocations / MPI UNIX RPC, Java RMI, XML-RPC,.NET Remoting, CORBA, DCOM –Erlang, E – distribution built in can distribute processes to separate computers Asynchronous message passing handles this naturally Promises/proxies can be used for return values
25
Distributed Computation Distributed Interpreter –All nodes running interpreter act as a single, larger interpreter –Is consistency important? –To my knowledge nobody deals with this at the language level, programmer is expected to handle it
26
Distributed Computation MOO – no distribution Unreal Script – Deals with replication and some local execution, but objects are essentially undistributed Second Life – as far as we know, only at land grid level, although they could support object distribution, pure concatenative prototyping anyway
27
Time
28
Some operations can take a relatively long time for a variety of reasons –Animations –Messages to other objects, possibly on other servers –Resource loading, external resource requests
29
Time in UnrealScripts Latent functions –Can only be called in state code, which is lowest on the stack –Regular functions can’t call latent functions No delay in calling functions on other objects
30
Security
31
Standard languages don’t have much built-in security, public/private/friend MOO uses UNIX-like permission system Confused deputy problem Access control matrix Access control lists? Capabilities?
32
User Concerns
33
We want regular users to write scripts –Familiarity is important, even for those not very familiar with programming –Simple things can stump beginners Case sensitivity Integer division Memory management –Higher level languages built on basic language? –Visual programming?
34
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.