Interpreters, Scripting

Traditionally:

Source Code  --->  compiler  ---> machine code 

The machine code(or assembly language) runs very quickly, with no overhead.

It is targetted to a particular CPU (e.g intel for pcs) and to a particular Op.Sys

(e.g Windows - it uses OS facilities to access files, keyboard etc).

What a compiler does

What an Interpreter does

-it depends - there are different approaches (but in every case, machine code is not created)

In general, more work is done at run-time (e.g parameter checking)

Often, the source code is obeyed as it is checked:

The speed issue is diminishing over the years.

Moore's law:
processor power (speed, memory) doubles every 18 months approx.

Scripting

Some features of scripting languages

String manipulation eg. - split a string of text into separate words:

input:  the cat sat on the mat.
output: an array of 6 strings - one word per element.

In vb:

dim words () as string
line=textbox1.text   '  or get it from a web form...
words=Split(line, " ")
all scripting languages can do stuff like the above.

Regular expressions

used to check chars within strings against a pattern


e.g check if a room number is of the form:
    A12 , A90, b21
      (e.g letter, digit, digit
in perl:
if room= ~/^[A-Za-z][0-9][0-9]
     print "ok"
Running other programs

in vb:


Dim result As Integer
result = Shell("notepad.exe", 1)  '2nd param: focus option

Examples

Summary- scripting

To Script or not?

The following do not apply in every situation, but
yes if no if