Scripting: Difference between revisions
No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
*[[http://www.cp15.org/php/|PHP]] PHP |
*[[http://www.cp15.org/php/|PHP]] PHP |
||
*[[http://python.acorn.de/|Python]] Python |
*[[http://python.acorn.de/|Python]] Python |
||
⚫ | |||
No longer supported? |
|||
⚫ | |||
*[[Tcl]] Ported by C.T.Stretch. |
|||
==What is a scripting language?== |
==What is a scripting language?== |
Revision as of 00:18, 31 March 2007
Scripting could be described as programming for the lazy. Scripting languages are designed to get a lot of useful work done with a small amount of code. This article is a collaborative effort to describe what scripting languages are available for RISC OS, and how they can be used.
No longer supported?
What is a scripting language?
RISC OS is controlled by Obey files. These contain scripts for a command language. It is rather a limited language; its variables we call system variables, and its facilities for conditional or looping structures are rudimentary. For this reason, Basic is often used in situations where Obey files are insufficiently expressive. The OSCLI command allows one to build up Obey commands using Basic variables. In other words, Basic has a useful role to play as a scripting language. However, Basic lacks certain facilities that are often needed for scripting, namely:
- Passing parameters into a Basic program via the command line is not straightforward.
- Basic has no mechanism for iterating over objects in a directory, without recourse to SWIs.
- Basic has only rudimentary facilities for pattern matching.
- Basic strings are limited in size - you cannot load a whole file in as a single string.
- Memory management is not automatic in Basic, so maximum sizes have to be guessed for DIM statements.
The term scripting language is vague, but the languages described by it tend to have the following features:
- Memory management is automatic. The claiming and freeing of memory ceases to be of concern.
- They have powerful string-processing and pattern-matching facilities.
- They can read system variables and execute commands.
- The words on the commandline are available as an array of strings.
- They support arrays or lists in various forms without the need for specifying a maximum number of components.
As scripting languages evolved, these features were found to be useful for expressing command scripts concisely. Of course, many of these languages have also acquired other features, some of them appropriate for writing applications more ambitious than quick and dirty scripts. Almost all of them are interpreted. The interpreters are usually divided into two parts - a compiler that converts the source scripts into bytecodes for a virtual machine, and an emulator and runtime system for the virtual machine.