Slashdot Mirror


Introduction to Linden Scripting Language

prostoalex writes "Dr. Dobb's Journal runs a lengthy introduction to Linden Scripting Language, the language behind avatars and their interaction in Second Life: "LSL is a scripting language that runs server-side, on a piece of software called the simulator. The simulator does just what it's name implies — it simulates the virtual world of Second Life. Each simulator runs everything for 16 acres of virtual land — buildings, physics, and of course, scripts. While you manipulate the script text in a form that is somewhat easy to read, the actual code that runs on the simulator is compiled. A compiler is a piece of software that takes the text version of the script and converts it into something that can actually run. In the case of LSL, the compiler exists within the Second Life viewer itself. In the future, it is likely that the compiler will move from the viewer into the Second Life simulators, but where the code is compiled isn't very important. What matters is that the text is converted into a form that can run on the simulators.""

25 of 139 comments (clear)

  1. A Way For Closed Source Scripts? by excelblue · · Score: 5, Interesting

    Is this a way for Linden Labs (and possibly for others) to provide closed source scripts and objects? This seems to be a very possible thing with such technology.

    What if someone only made available a compiled copy of something? It'd be scary if you can't tell what's really going on with all the stuff.

    1. Re:A Way For Closed Source Scripts? by Yetihehe · · Score: 2, Informative

      Yes. No. Well, sort of. You can just sell or give someone an object with compiled script. If he doesn't have rights to modify script, he don't see source code.

      --
      Extreme Programming - Redundant Array of Inexpensive Developers
    2. Re:A Way For Closed Source Scripts? by ajlitt · · Score: 2, Insightful

      Who cares? Linden owns the production systems, so you're not guaranteed that execution on the simulator is one-for-one with the game.

    3. Re:A Way For Closed Source Scripts? by makomk · · Score: 2, Interesting

      Yes. No. Well, sort of. You can just sell or give someone an object with compiled script. If he doesn't have rights to modify script, he don't see source code.

      In fact, he can't even see the object code. (Actually, SL doesn't let you obtain the object code for scripts even if you do have the right to modify them. Combine this with the fact that compilation is currently client-side, and just inspecting the source of a script someone gave you isn't sufficient to ensure it's not malicious - you need to recompile it, and the only people who can tell if anyone's exploiting this are Linden Labs.)

      This also makes Second Life a GPL-violater's paradise (no way to prove it) - and there's a lot of people in there who don't seem to understand or care about open source or the GPL. (A particularly egregarious example - one infamous indifidual, I think it was Prokofy Neva, claimed that if a script or object was set transfer-allowed, this gave anyone the right to set it no-modify, no-resale, and sell it en masse, no matter what the conditions given with it were. There have been many others... such as the "open source" window blind script that forbidded redistribution; in fact, most of the "open source" items I've seen aren't.)

  2. Credit where credit is due by Chairboy · · Score: 5, Funny

    Credit where credit's due, it's important to note that LSL is the first scripting language to have furry specific classes. This is an oft-overlooked aspect of modern languages.

    1. Re:Credit where credit is due by mrcdeckard · · Score: 5, Interesting


      it's funny, i just checked out 2nd life last night -- first time since a year or two ago -- and i was pretty amazed -- the place is one big car lot or sex club. really. i guess there are two kinds of people in 2nd life now -- the people selling "sex", and the people trying to sell their objects to buy the "sex".

      it really was a cool online social experiment -- it only ultimately confirmed what we knew all along -- the internet is good only for porn and consumerism.

      now, think about this for a second. first, it's not real sex that is drawing people. it's not even imagery of real people having sex. it's interaction of poorly-rendered avatars in a virtual world. this is a testament to the power of the sexual drive in humans, and what we decide to do with our best technology..... just a friendly reminder that yes, we are doomed.

      mr c

      --
      "Physics is like sex. Sure, it may give some practical results, but that's not why we do it." - R. Feynman
    2. Re:Credit where credit is due by DaleGlass · · Score: 2, Interesting

      Nah, there are plenty of people in SL which aren't in it for the porn. A significant portion of the grid is PG. There are quite a few people who use it as a chat, or because they like scripting and building.

      I don't have or do anything porn-related in there, and don't spend any significant amounts of money either. So far I'm getting more out of it than I spend.

    3. Re:Credit where credit is due by MilenCent · · Score: 3, Insightful

      But what is real currency? All money is fake, on a basic, fundamental level. Online games simply use faker money than usual, but with real world transactions becoming increasingly virtual, the difference between the two is becoming much more uncertain over time.

      It is in the best interest of any online world to convince the government that their money is fake, since that means they won't have to subject their servers and source code to government oversight, which would ultimately make the game much harder to implement. Most games are content to let it rest at that, since they see their money as play tokens themselves.

      Linden Labs is one of the first companies to realize that there is a value in allowing the public, if not regulators, to think otherwise. All L$ cashouts are probably, technically, at LL's discretion; to give players a true, real-world legal right to convert money would mean the government would ultimately start taking a hard look at them, since from a real-world standpoint they would start looking like a bank at best, and a potential tax dodge at worst.

      It is important to note, though, that Linden Labs' business requires that the illusion be maintained. If they actually did refuse to cash out L$, it would shake user faith in the system. Trading between real-and-virtual money may be ultimately by permission only, but to exercise that authority would be dangerous to their business, and they seem like they're in this some degree of foresight instead of hoping to make a quick buck, so L$ are still, practically, safe to buy and sell. Mostly.

    4. Re:Credit where credit is due by notthepainter · · Score: 4, Informative

      it's funny, i just checked out 2nd life last night -- first time since a year or two ago -- and i was pretty amazed -- the place is one big car lot or sex club. really. i guess there are two kinds of people in 2nd life now -- the people selling "sex", and the people trying to sell their objects to buy the "sex".
      This is why I started my web site http://www.secondseeker.com/. The parent poster is mostly right and completely wrong.

      All that is easy to find is sex.

      There is a lot more out there, it is just hard to find. I've spent a lot of time sailboat racing in SL. I no longer have access to a boat and I really missed it. It it the same? Certainly not. Is it better, than nothing. You bet! When I raced sailboats I was on a big boat with others, now I'm at the helm. I couldn't afford to do that in the real world.

      I hate to sound like spam but if you think sex is all that there is to SecondLife, just check out my web site, you might find something to do there that interests you. (Note, the site is supported by AdSense ads, if that offends you, please don't visit, or at least don't click on the ads!)

      Paul aka Seeker Gray

  3. What happened to Mono? by IL-CSIXTY4 · · Score: 4, Interesting

    There was talk about converting the server-side scripting engine to Mono, with huge (50x) performance gains. There was supposed to be a LSL->CIL compiler at first, then libraries for other .Net languages. Has anyone heard anything about this recently?

    1. Re:What happened to Mono? by Erbo · · Score: 3, Informative

      It's still being worked on, and, in fact, there have been some recent developments that have moved this work forward significantly. See this entry by Babbage Linden on the Official Linden Blog from last month for more details. It involved finding a memory leak in the Mono runtime which would have caused memory usage in the simulator code to grow unacceptably over time. LL personnel like Babbage worked closely with Mono team members to resolve this.

      --
      Be who you are...and be it in style!
  4. As clear as mud by Linker3000 · · Score: 3, Funny

    "A compiler is a piece of software that takes the text version of the script and converts it into something that can actually run."

    Glad that's all cleared up!

    --
    AT&ROFLMAO
    1. Re:As clear as mud by StarfishOne · · Score: 2, Funny

      *Compiles Forrest*

      *Done*

      Run Forrest, Run! :D

  5. what a strange summary by aluser · · Score: 2

    The summary quote uses 108 words to explain that there exists a compiler for this language.

    1. Re:what a strange summary by jfengel · · Score: 5, Informative

      The article isn't much better. It spends a lot of time going over what most Slashdotters already know, like what an "integer" is, and very little on what's novel about a scripting language for an interactive world (or whatever you want to call Second Life.)

    2. Re:what a strange summary by seaturnip · · Score: 2, Insightful

      Yeah, all I'm interested in hearing about is, why is it necessary to have a special-purpose language for Second Life in the first place? Is there a good reason or is it just Not-Invented-Here syndrome? Why not use Lua (a simple, extensible language commonly used to script games) or something instead?

    3. Re:what a strange summary by makomk · · Score: 3, Informative

      The summary quote uses 108 words to explain that there exists a compiler for this language.

      The compiler sucks. For example, when you define a vector, it generates three "float literal" instructions rather than one "vector literal" instruction. This means that 2 instructions and 2 bytes more code than necessary are generated for each vector literal in the code (similarly with quaternons/rotations). (Remember, there's a 16Kb per script limit for code+data.) As a second example, there are two types of instruction for transferring data from the stack to local/global variables - store and pop (which is equivalent to a store, followed by a drop). For one, the compiler only ever seems to use the "pop" variant, whilst for the other it always uses a "store; pop" pair (despite this being inefficient) - I've never seen a lone "store".

      Also, the goto is broken - due to a compiler bug/design error, only the last jump to a particualr label actually does anything. (The code for matching gotos to labels can only track one goto for each label.) This is a long-standing and well-known bug which I doubt would be difficult to fix, yet no-one's bothered.

      There are also other useful instructions which are never used (such as various dups, an instruction for setting the instruction pointer directly - making jump tables/efficient switch statements possible - and an instruction for freeing arbitrary amounts of stack quickly). The compiler never optimises anything, either. It's why I don't hold out much hope for speed improvements from Mono (and indeed, the predicted improvements mostly vanished when they started running actual LSL scripts with it.)

  6. I'm not so sure. by maxwell+demon · · Score: 2, Insightful

    In the future, it is likely that the compiler will move from the viewer into the Second Life simulators, but where the code is compiled isn't very important.

    Well, if it is running on the simulators, the simulated humans might be given access to it, and thus being able to script their own lifes!
    Well, maybe I should try if those scripts already work on our world! :-)
    --
    The Tao of math: The numbers you can count are not the real numbers.
  7. the summary: intro to computers by mrcdeckard · · Score: 4, Funny


    hello class, this is a COM-PU-TER. computers run a set of instructions called a PROOOGRAAAM. programs are nothing but 1's and 0's. heheheh, but we don't program in 1's and 0's, we program in a language, such as linden script. another computer program, called a com-pi-ler, compiles the script into a format the computer can understand. ok, class, this is a DISK DRIVE . . .

    sheesh, i thought this was /.

    (actually, it must be -- even *I* am complaining about the summaries...)

    mr c

    --
    "Physics is like sex. Sure, it may give some practical results, but that's not why we do it." - R. Feynman
  8. Not a very good article... by Cereal+Box · · Score: 4, Funny

    I was expecting a tutorial on how to program an army of flying penises to interrupt a virtual press conference...

  9. I do a pretty good bit of LSL... by FishWithAHammer · · Score: 3, Informative

    ...or have done, really. The language is a bastard child of C, basically. Its major problem is its lack of arrays; you have a strange construct called a list that sort of does the same thing, but I really don't know why it's there instead of arrays. LSL is fairly underpowered. What I've taken to doing is using its HTTP system, though, to ping my web server, do something, and feed it back into the game. To do anything really impressive with LSL, it does seem to take an outside server to do the heavy lifting. It's kind of fun, though...

    --
    "You can either have software quality or you can have pointer arithmetic, but you cannot have both at the same time."
    1. Re:I do a pretty good bit of LSL... by makomk · · Score: 2, Informative

      You crazy fool, they're both linear data structures that have similar interfaces. You lose random access with lists, but you gain the ability to add an arbitrary number of elements.

      Actually, LSL's lists do have efficient random access. The main catches are that they're immutable, which means that every time you want to change anything you have to copy the list (which is, of course, limited by LSL's 16Kb memory limit), and that you can't have lists of lists. (Also, their implementation of lists isn't particularly space efficient - each entry has to have its own heap entry, complete with a 7-byte header, and the list is an array of 4-byte pointers to the heap, giving 13 bytes/entry total overhead.)

  10. Re:Interregional physics by DaleGlass · · Score: 2, Insightful

    So?

    SL has a service based economy. There isn't a shipping industry in SL because it isn't needed. But there are plenty services being offered. If you pay me enough L$ I could script something for you. There are people who will build custom objects, draw graphics, make custom avatars, etc.

    RL physical constraints aren't needed in SL to have an economy. Time still is money. Skill still takes effort to develop.

    The RL constraints gave us the RL economy, the SL constraints result in a slightly different one. There's no reason why the RL world is the only way of having an economy.

  11. Re:Another? by justinchudgar · · Score: 2, Interesting
    Ya know, I was going to mod the parent up; but, I felt the need to express just how much I agree with him or her. I know that Linden is probably an excellent language for its niche; but, the number of languages in fairly common use seems to have exploded. I am all for the freedom of choice; and, I think that having a variety of tools that can be selected based on performance, flexibility or preference is wonderful.

    My perception is that there is a optimal balance between choice and usefulness. If we were living in a world where the only languages were Assembler and BASIC programming would be hugely difficult and software would be suck because the tools were so mismatched to the application. On the other extreme, if there was a language created for every project, programming would be hugely difficult and software would suck because not only would the application have to be written, but the language as well.

    Somewhere in the middle is the perfect balance between endless variety of languages and extreme limitations. My feeling is that if some of the effort by the very intelligent and skilled developers who are creating new languages were instead channeled into improving existing languages, the limitations of current tools would be greatly reduced and the experience of all those who know existing languages would be relevant to solving problems. If a developer has to devote time and effort learning a new language, basic syntax, code conventions, optimal design patterns, etc., then that developer is losing time actually writing useful code.

    I have written "Hello World" or some generic "Music Store" type app learning:
    • BASIC
    • Pascal
    • HyperCard
    • Fortran
    • C
    • C++
    • Java
    • Perl
    • PHP
    • Python
    • DOS/CMD Batchfiles
    • Shell Scripting
    • Kixtart
    • Ruby
    • Visual Basic
    • C#
    • MSH/Monad/Microsoft's new shell
    • Lisp
    Now, I am not a programmer by profession. I've taken courses and I like to write little programs for personal use; so, my knowledge of these languages is minimal. But, I have had to learn what I know so that I could use existing code or frameworks to accomplish what I wanted. The same requirements for redundant learning applies to those who write code on a professional level. If a highly skilled C++ programmer wants to contribute to a project written in MONO/C#, there is a learning curve. If he then wants to work on a project in Python, another learning curve.

    I would be willing to bet that some projects miss out on a lot of contributed code because people who are willing and have the algorithmic skills to assist are simply unwilling to take the time to learn whatever language is used.

    Sorry it this was less than readable. It is late and I am tired and hungry. Off to the kitchen...
    --
    WARNING: Smoking this sig may cause lowered IQ, insanity or short term memory loss. It is also really bad for your monit