Wartbed:Architecture/Scripting

From Dark Omen Wiki

< Wartbed:Architecture(Difference between revisions)
Jump to: navigation, search
(Created page with 'As of yet, there is no need for '''scripting'''. Options for script languages include {| class="wikitable" ! Script language ! Notes ! Maturity ! Embeddability ! Language comp...')
(io script)
 
(13 intermediate revisions not shown)
Line 2: Line 2:
Options for script languages include  
Options for script languages include  
-
{| class="wikitable"
+
<div style="font-size:tiny;">
 +
{| class="wikitable" style="font-size:6pt;"  
! Script language
! Script language
! Notes
! Notes
! Maturity
! Maturity
! Embeddability
! Embeddability
 +
! Ease of using from C++
! Language complexity
! Language complexity
! Script parsing/execution
! Script parsing/execution
Line 12: Line 14:
! Licence
! Licence
|-
|-
-
| LUA
+
 
-
| ''No notes yet''
+
| [http://www.lua.org LUA]
-
| Well done
+
| Designed for C for maximum portability. Some hoops (local wrappers) must be hopped for C++ integrations.
 +
| Well done: the grand old man of game scripting languages.
| High
| High
-
| Medium
+
| Middle. Binding and calling conventions are C-style. Luabind wrappers are used in C++. Not difficult, not trivial, not elegant, but not too bad.
 +
| Medium. Sparse semantics. Procedural and OO paradigms. Vanilla but not particularly aesthetic syntax.
| Fast
| Fast
| Most
| Most
|-
|-
 +
 +
| [http://www.somedude.net/gamemonkey/ Game Monkey Script]
 +
| Embedded scripting language borrowing concepts from Lua but uses syntax similar to C. Natively supports multithreading and the concept of states. Syntax and semantics is familiar and code turns out clean and aesthetic.
 +
| Rare?
 +
| High?
 +
| Relatively easy but somewhat hairy. Bindings requires manual asserting of parameters etc. Calling scripts require stack-like pushing of parameters.
 +
| Medium. Runtime compilation and debugging, reflection. Linking to precompiled libs of script code. Functions are first-class citizens. Calls are by-reference.
 +
| Middle-range?
 +
| Has been compiled on every platform relevant for games, apparently.
 +
| MIT
 +
|-
 +
| [http://www.angelcode.com/angelscript/ AngelScript]
| [http://www.angelcode.com/angelscript/ AngelScript]
| ''No notes yet''
| ''No notes yet''
| Medium rare
| Medium rare
| High
| High
 +
| ???
| ???
| ???
| Fast?
| Fast?
| ???
| ???
|-
|-
 +
| Ruby
| Ruby
| ''No notes yet''
| ''No notes yet''
| Well done
| Well done
 +
| Cumbersome?
| Lowest
| Lowest
-
| Higher
+
| Higher. Single-paradigm, extreme OO design. CLosures, lambda, mix-ins. Very appealing and human-readable semantics and syntax.
| Slower
| Slower
| All?
| All?
|-
|-
 +
| Python
| Python
| ''No notes yet''
| ''No notes yet''
| Well done
| Well done
 +
| ???
| Low
| Low
-
| High
+
| High. The German of script languages: extremely well equipped libraries, has everything you'll ever need, but can be butt ugly.
| Slow
| Slow
| All
| All
-
|-
+
|-  
-
| [http://git.runtimeterror.com/?p=minimal.git;a=summary Minimal]
+
 
-
| ''No notes yet''
+
| [http://realm.badsectoracula.com/minimal/ Minimal]
 +
| [http://git.runtimeterror.com/?p=minimal.git;a=summary Git download location]  
| Rare
| Rare
 +
| ???
 +
| ???
| ???
| ???
| ???
| ???
Line 52: Line 76:
| ???
| ???
|-
|-
 +
| [http://www.falconpl.org/index.ftd?page_id=Home Falcon Programming Language]
| [http://www.falconpl.org/index.ftd?page_id=Home Falcon Programming Language]
-
| ''No notes yet''
+
| Designed for maximum speed using C++.
| Medium rare
| Medium rare
| High
| High
 +
| ???
 +
| High: Multi-paradigm: supports procedural, object oriented, prototype oriented, tabular, functional and message oriented programming models. Coroutines, multithreading, compile-time metaprogramming, reflection. Virtual file system. Small standard library. Mostly strict and clean style, functional code slightly messy.
| Fast
| Fast
-
| Fast
 
| Win,Linux, OSX
| Win,Linux, OSX
| Dual: Either FPLL (similar to LGPL/MIT), or GPL
| Dual: Either FPLL (similar to LGPL/MIT), or GPL
 +
|-
 +
 +
| [http://www.chaiscript.com/ ChaiScript]
 +
| Designed for C++ integration. Very easy to integrate into application - ca. three lines! Dynamically type scripting language inspired by Ruby and Scala. Type-safe inside C++. Highly dependent on templates == slow compilations.
 +
| Medium rare
 +
| Very high.
 +
| Easy
 +
| High: lambda, everything-is-an-object, closures; OO, functional, procedural and message paradigms.Very appealing syntax. Library is an exposure of C++ methods and STL types.
 +
| ???
 +
| Source for Win, Linux, OSX.
 +
| Liberal and permissive home-cooked licence.
 +
|-
 +
 +
| [http://iolanguage.com/ Io]
 +
| Minimal scripting language. Functional-paradigm and dynamically typed with first-class functions. C++ binding code is somewhat arduous.
 +
|
 +
|
 +
|
 +
|
 +
|
 +
|
 +
|
|}
|}
 +
</div>
==Current favourites===
==Current favourites===
-
1st place: http://www.falconpl.org/images/logo.png <br />
+
{|
-
1st runner up: Angelscript <br />
+
|1st place || ChaiScript
-
2nd runner up: LUA <br />
+
|-
-
<br />
+
|1st runner up || http://www.falconpl.org/images/logo.png <br />
-
Dream language: Ruby, if it would be fast enough
+
|-
 +
|2nd runner up || Angelscript <br />
 +
|-
 +
|3rd runner up || LUA <br />
 +
|}
 +
 
 +
Dream language: Ruby, if it would be fast enough interpreted and embedded
 +
 
 +
== Community Comments ==
 +
 
 +
Seems to me that there would be little point implementing some of these scripting languages, since they aren't really a lot simpler than C++. 
 +
 
 +
If the idea is to facilitate third party editing, then something that is approachable for those with little programming experience would be preferable.
 +
 
 +
If however, it's merely to avoid recompiling then some of the options above start to make more sense, although you'd be adding runtime overhead and code complexity. [[User:Rob|Rob]]
 +
 
 +
:Thanks for the comments, Rob! Yeah, I basically agree with you. Many add scripting to their engines because "it is the thing to do", or "to make it easier for the content developers". But a programming language is always a programming language, and non-programmers will not necessarily have an easier time in a script language than the native one. For those times visual tools are generally better.
 +
:Some things will be better suited to scripting though. For instance translating the DO CTL scripts. ANd for those times we want a language that is easy to use and understand, easy to integrate into the engine(s), fast to parse and execute, and powerful.
 +
:Falcon and ChaiScript are, as you say, as complicated as many "real" languages. But they also have a very appealing syntax: ChaiScript reads more like a nicer Ruby and Scala. Lua, which however is the most common scripting language today, is actually not very good. The syntax is cumbersome and its code is in my experience very bug-prone. You can't easily express advanced constructs without verbose syntax, and you need to know the entire language before you can script. That's especially why I'm extra keen on ChaiScript and FalconPL atm.
 +
:Really, bring on the comments! I really appreciate them!
 +
:[[User:Mikademus|Mikademus]] 17:41, 17 February 2010 (UTC)
 +
 
 +
:: One other thing that I was thinking about, security. Anything with too comprehensive a standard library would probably be a little dodgy.  I know, for example, it's pretty hard to secure Python due to a combination of its design and its dynamic nature.
 +
 
 +
::Lua and Javascript on the other hand, have very little built-in libraries, so the script can only work within your design.  No writing to the filesystem, patching executables etc.
 +
 
 +
::Javascript might be worth consideration and people are already experienced with it. If there is an appropriate C++ library, Google's V8 maybe?
 +
 
 +
::I had a quick look at Chaiscript and it looks pretty good.  Falcon is possibly a little heavyweight, although this is based upon a very quick look. [[User:Rob|Rob]]
 +
 
 +
:::The libraries and security is a good point, one I've considered myself, and among the reasons why Chaiscript and Falcon are my two top candidates atm. Basically, both interpretors only work with functions and classes you've explicitly exported to the script. This is especially important since scripts (as all game business code) is only to run on the server, and we don't want server-side script code gone amok! That's one additional reason I'll probably going to rule out Python.
 +
:::I've never even thought about JavaScript as a scripting language, so I have no ideas if there are libraries for this. But I just have to say, it is one of the ugliest languages I've ever known! ;) Do you have any resources about it? I also don't know anything about Google V8, so I'll take a look at it!
 +
:::[[User:Mikademus|Mikademus]] 22:00, 17 February 2010 (UTC)

Current revision as of 12:44, 26 June 2010

As of yet, there is no need for scripting.

Options for script languages include

Script language Notes Maturity Embeddability Ease of using from C++ Language complexity Script parsing/execution Platforms Licence
LUA Designed for C for maximum portability. Some hoops (local wrappers) must be hopped for C++ integrations. Well done: the grand old man of game scripting languages. High Middle. Binding and calling conventions are C-style. Luabind wrappers are used in C++. Not difficult, not trivial, not elegant, but not too bad. Medium. Sparse semantics. Procedural and OO paradigms. Vanilla but not particularly aesthetic syntax. Fast Most
Game Monkey Script Embedded scripting language borrowing concepts from Lua but uses syntax similar to C. Natively supports multithreading and the concept of states. Syntax and semantics is familiar and code turns out clean and aesthetic. Rare? High? Relatively easy but somewhat hairy. Bindings requires manual asserting of parameters etc. Calling scripts require stack-like pushing of parameters. Medium. Runtime compilation and debugging, reflection. Linking to precompiled libs of script code. Functions are first-class citizens. Calls are by-reference. Middle-range? Has been compiled on every platform relevant for games, apparently. MIT
AngelScript No notes yet Medium rare High  ???  ??? Fast?  ???
Ruby No notes yet Well done Cumbersome? Lowest Higher. Single-paradigm, extreme OO design. CLosures, lambda, mix-ins. Very appealing and human-readable semantics and syntax. Slower All?
Python No notes yet Well done  ??? Low High. The German of script languages: extremely well equipped libraries, has everything you'll ever need, but can be butt ugly. Slow All
Minimal Git download location Rare  ???  ???  ???  ???  ???  ???
Falcon Programming Language Designed for maximum speed using C++. Medium rare High  ??? High: Multi-paradigm: supports procedural, object oriented, prototype oriented, tabular, functional and message oriented programming models. Coroutines, multithreading, compile-time metaprogramming, reflection. Virtual file system. Small standard library. Mostly strict and clean style, functional code slightly messy. Fast Win,Linux, OSX Dual: Either FPLL (similar to LGPL/MIT), or GPL
ChaiScript Designed for C++ integration. Very easy to integrate into application - ca. three lines! Dynamically type scripting language inspired by Ruby and Scala. Type-safe inside C++. Highly dependent on templates == slow compilations. Medium rare Very high. Easy High: lambda, everything-is-an-object, closures; OO, functional, procedural and message paradigms.Very appealing syntax. Library is an exposure of C++ methods and STL types.  ??? Source for Win, Linux, OSX. Liberal and permissive home-cooked licence.
Io Minimal scripting language. Functional-paradigm and dynamically typed with first-class functions. C++ binding code is somewhat arduous.

Current favourites=

1st place ChaiScript
1st runner up logo.png
2nd runner up Angelscript
3rd runner up LUA

Dream language: Ruby, if it would be fast enough interpreted and embedded

Community Comments

Seems to me that there would be little point implementing some of these scripting languages, since they aren't really a lot simpler than C++.

If the idea is to facilitate third party editing, then something that is approachable for those with little programming experience would be preferable.

If however, it's merely to avoid recompiling then some of the options above start to make more sense, although you'd be adding runtime overhead and code complexity. Rob

Thanks for the comments, Rob! Yeah, I basically agree with you. Many add scripting to their engines because "it is the thing to do", or "to make it easier for the content developers". But a programming language is always a programming language, and non-programmers will not necessarily have an easier time in a script language than the native one. For those times visual tools are generally better.
Some things will be better suited to scripting though. For instance translating the DO CTL scripts. ANd for those times we want a language that is easy to use and understand, easy to integrate into the engine(s), fast to parse and execute, and powerful.
Falcon and ChaiScript are, as you say, as complicated as many "real" languages. But they also have a very appealing syntax: ChaiScript reads more like a nicer Ruby and Scala. Lua, which however is the most common scripting language today, is actually not very good. The syntax is cumbersome and its code is in my experience very bug-prone. You can't easily express advanced constructs without verbose syntax, and you need to know the entire language before you can script. That's especially why I'm extra keen on ChaiScript and FalconPL atm.
Really, bring on the comments! I really appreciate them!
Mikademus 17:41, 17 February 2010 (UTC)
One other thing that I was thinking about, security. Anything with too comprehensive a standard library would probably be a little dodgy. I know, for example, it's pretty hard to secure Python due to a combination of its design and its dynamic nature.
Lua and Javascript on the other hand, have very little built-in libraries, so the script can only work within your design. No writing to the filesystem, patching executables etc.
Javascript might be worth consideration and people are already experienced with it. If there is an appropriate C++ library, Google's V8 maybe?
I had a quick look at Chaiscript and it looks pretty good. Falcon is possibly a little heavyweight, although this is based upon a very quick look. Rob
The libraries and security is a good point, one I've considered myself, and among the reasons why Chaiscript and Falcon are my two top candidates atm. Basically, both interpretors only work with functions and classes you've explicitly exported to the script. This is especially important since scripts (as all game business code) is only to run on the server, and we don't want server-side script code gone amok! That's one additional reason I'll probably going to rule out Python.
I've never even thought about JavaScript as a scripting language, so I have no ideas if there are libraries for this. But I just have to say, it is one of the ugliest languages I've ever known! ;) Do you have any resources about it? I also don't know anything about Google V8, so I'll take a look at it!
Mikademus 22:00, 17 February 2010 (UTC)
Personal tools
communication