What would your ideal scripting language look like?

Discussion in 'Game Development (Technical)' started by Adrian Lopez, Mar 11, 2011.

  1. Adrian Lopez

    Original Member

    Joined:
    Sep 7, 2004
    Messages:
    489
    Likes Received:
    0
    I'm looking to implement my own embeddable scripting language and would like to know what each of you would consider an ideal scripting language. What kinds of features would you like it to have? What would the code look like?
     
  2. inverse

    Original Member

    Joined:
    Mar 3, 2005
    Messages:
    42
    Likes Received:
    0
    To some extent, that probably depends on what you intend to do with it.

    I like C syntax, but that seems too low level...
    I like Python syntax, but the runtime seems a bit heavy...
    I like Lua, but I don't like the syntax as much as Python or C...

    For one of my own implementations, because it was mostly intended for animation, it had built-in operators that understood concepts of global/local time and interpolation.

    I think that ideally a scripting language would:
    1. Let you specify what you want to do in the smallest amount of code possible / reasonable
    2. Glue bits of C++ code together as efficiently as possible

    If you're trying to manage piles of dynamic data, you may want something different than if you mostly want to do expression parsing and function calling.

    Personally I'm kind of liking Lua - it's free, fast, extensible and already written. :)
     
  3. Adrian Lopez

    Original Member

    Joined:
    Sep 7, 2004
    Messages:
    489
    Likes Received:
    0
    I like Lua's syntax (though it's perhaps a little too flexible) and ease of integration, but I don't like how Lua requires that a copy of its license and copyright notice be included with any product that links to it. Depending on the platform (e.g. mobile games), a big block of licenses and copyright notices is not what you want the user to see.

    I want to make something I can license under the zlib license (which requires no credit other than in source distributions) and want to start on the right foot. I have a preliminary syntax in mind already but would like to hear other people's ideas before I commit to it.
     
  4. Jack Norton

    Indie Author

    Joined:
    Jul 28, 2004
    Messages:
    5,130
    Likes Received:
    0
    python. it IS the best scripting language - ask google ;)
     
  5. inverse

    Original Member

    Joined:
    Mar 3, 2005
    Messages:
    42
    Likes Received:
    0
    • I would stick with C operators wherever possible.
    • Zero-based arrays :)
    • Despite initially balking at Python's whitespace-delimited code, it can make code a lot more compact

    Regarding the license, depending on the specific game, presumably a Credits screen off a menu would be sufficient, not something you need to put on the main flow.
     
  6. Mattias Gustavsson

    Original Member

    Joined:
    Aug 10, 2005
    Messages:
    669
    Likes Received:
    0
    There's some interesting points in this one: http://www.cs.princeton.edu/~dpw/popl/06/Tim-POPL.ppt
    dependent types, concurrency... A language specifically designed to enable catching of as many errors as possible at compile time: if the code compiles, it will run without crashing. That's a pretty interesting idea...
     
  7. Bad Sector

    Original Member

    Joined:
    May 28, 2005
    Messages:
    2,742
    Likes Received:
    5
    Different people ask for different things. Moreover, different languages are better suited for different tasks. To make things even more interesting, your execution environment might limit your choices.

    You can't have one language to rule them all :)

    I have implemented a bunch of languages, from a Java-like to a shell-like, dynamically typed, statically typed and typeless (or actually, monotyped) and not one of them was suited for every task.

    These days i'm mostly using LIL. LIL is a very compact and dynamic scripting language inspired by Tcl and the UNIX shell, where everything is represented a string, including source code (until the time it is to be executed the source code is considered as a plain string, you can get -and modify- the source code of a function, etc) and works with string substitutions, everything is a function (including structures like if, for, while, func, etc - in fact you can rename the originals and define your own which call the originals as an aid in debugging) and has a simple C interface. Here is a small presentation.

    Generally speaking, LIL is a good candidate for scripting in many cases. There are some cases, however, where LIL doesn't fit and needs another language (such as my Minimal language): LIL is inherently slow (due to string substitutions) so if your scripts are going to executed very often (think tens or hundreds of thousands per second), it isn't a good choice (Minimal uses a very static bytecode-based VM and if needed can be compiled to native code since the bytecode maps well to CPU). Two other cases where LIL wouldn't work is when you need to use lots of expressions (LIL uses an "expr" function to parse expressions and with the dollar prefix needed for variables it makes things awkward) or a very basic but rigid syntax is required (where a more BASIC-like language would be better).

    Also i don't think that LIL is good for big systems. I wouldn't write, say, a full 3D world editor with it (however i would use LIL in a full 3D world editor for scripts - in fact i would make the world editor's functionality be fully exposed via LIL and have the GUI call LIL commands where possible).

    Still, i'm using LIL as my Alithia Engine's scripting language. I said above that it is slow and, relatively speaking, yes it is. But with the way the engine uses the language, that speed doesn't matter. When i made a test with many interacting physics entities bouncing and moving around and calling script callbacks, i profiled the engine and only about 0.4% was spent in script code. Generally i believe that in a game, a scripting language should be used for just that: scripting. Anything computationally intensive or low level (building blocks for AI, such as pathfinding or vision checks are good candidates) does not belong to a script and must be written in native code.
     
  8. richtaur

    Indie Author

    Joined:
    Apr 19, 2009
    Messages:
    262
    Likes Received:
    0
    Short answer: JavaScript ;)

    I sincerely like the language despite its flaws. I'm surprised it's not being used more as a games scripting language considering how powerful and pluggable it is (especially interpreters like V8).
     
  9. lennard

    Moderator Original Member Indie Author

    Joined:
    Jan 12, 2006
    Messages:
    2,390
    Likes Received:
    12
    Something that let me reuse my code on both server and client.
     
  10. Adrian Lopez

    Original Member

    Joined:
    Sep 7, 2004
    Messages:
    489
    Likes Received:
    0
    Seems like I've asked the wrong question. What I want to know is:

    1. Which particular features do you think are important to have in a game scripting language?
    2. What kind of syntax would you prefer such a language to have?
     
  11. HairyTroll

    Original Member

    Joined:
    Jul 29, 2004
    Messages:
    582
    Likes Received:
    0
    A REPL

    A syntax that doesn't get in the way.
     
  12. lennard

    Moderator Original Member Indie Author

    Joined:
    Jan 12, 2006
    Messages:
    2,390
    Likes Received:
    12
    REPL is a good one although I must admit I had never heard the term before. The command line interpreter in Applesoft was a huge part of why I became a programmer. Just typing the word Applesoft makes me happy.
     
  13. PoV

    PoV
    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    2,132
    Likes Received:
    0
    Like Squirrel or Pawn.

    Seriously, scripting languages are done to death. Just comply, you'll be happier and more efficient.
     
  14. Adrian Lopez

    Original Member

    Joined:
    Sep 7, 2004
    Messages:
    489
    Likes Received:
    0
    I'll be happier to have a scripting language I can use without restriction.
     
  15. mooflu

    mooflu New Member

    Joined:
    Oct 23, 2007
    Messages:
    21
    Likes Received:
    0
    Lua's license doesn't say anything about displaying it to a user. Include != display.

    If the syntax is readable and there's a good code editor (along the lines of Resharper or VAX), debugger, and easy integration with other languages, you'd have a winner. :cool:

    In the meantime I'll stick with lua or python.
     
  16. Adrian Lopez

    Original Member

    Joined:
    Sep 7, 2004
    Messages:
    489
    Likes Received:
    0
    It's important to consider the licensor's intent. I doubt that embedding a copy of the license in such a way that nobody can see it would satisfy the terms of the license.
     
  17. PoV

    PoV
    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    2,132
    Likes Received:
    0
    It's not like you have to give it top billing on your credit screen. Many libraries ask for attribution, font's too. It's not like they're asking for a "Licensed By Nintendo" style screen that must precede all other screens - They simply ask as a courtesy to say "hey, we used this", and only where it's appropriate (credits, manual, etc).

    Do you not take credit for your own work?

    It's not like it's a source code disease, as the GPL is.
     
  18. Adrian Lopez

    Original Member

    Joined:
    Sep 7, 2004
    Messages:
    489
    Likes Received:
    0
    The license requires more than simple credit, but ultimately it doesn't matter. I've decided to make my own and to license it in such a manner that credit is not required outside of the source code.
     
  19. Olofson

    Original Member

    Joined:
    Dec 11, 2005
    Messages:
    270
    Likes Received:
    0
    Right; one size does not fit all, and a lot of this comes down to programming style and personal preferences.

    And some weirdos roll their own just for the hell of it. :D (Or because of special requirements, and someone else paying for it anyway.)

    Either way, the dead horse is still moving, apparently...! ;)
     
  20. PoV

    PoV
    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    2,132
    Likes Received:
    0
    Fine, I realize you won't bite, but all you need is one of these in the case of something MIT.
    I'd go one step further and add a URL at the bottom for anyone looking to exercise that. No need to make clicking actually work though.

    And that's as complicated as they get. Append that to the end, or explicitly link to a licenses page from your credits. Done. Paid in full.


    If you're using any 3rd party libs: SDL, boost, etc, you're obligated to do this anyways.
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer