(Ln(x))3

The everyday blog of Richard Bartle.

RSS feeds: v0.91; v1.0 (RDF); v2.0; Atom.

Previous entry. Next entry.


3:55pm on Tuesday, 1st May, 2012:

Code and Data

Comment

What's the difference between code and data?

Code is a partially-ordered set of executable instructions. Data is a partially-ordered set of non-executed values that have meaning to some code. That doesn't mean data can't be executed; it just means it (well, strictly speaking they, as data is plural) isn't executed by the code for which it is data. A Java program is data to a Java compiler; it's code to a Java interpreter. Typically, data which is chiefly interpreted as code is called a script.

When I was designing MUDDLE, the language in which MUD2 is written, I thought I was creating a scripting language. I had a terrible time deciding what to put in MUDDLE and what to put in the MUD2 run-time system. I kept writing high-order functions in C and realising that I could have written them in MUDDLE. Eventually, I reached a tipping point at which I realised that I should be taking functionality out of the MUDDLE run-time system and putting it into MUDDLE; I could then execute MUDDLE directly as code instead of indirectly as data that represents code (ie. as a script).

When I did this, I began to code MUD2 in MUDDLE and found that although the resulting system needed data, it didn't need scripts: MUDDLE was its own scripting language. Although I'd been taught not to hard-code things that were data, that didn't seem to make sense when any soft-coding would have been in the same language as the hard code.

I figured there and then that as a general rule, any program that uses a scripting language for some of its data could be rewritten in a (possibly new) language that doesn't need such a scripting language. You can move both the script and the language that interprets the script so they're the same thing.

Obviously, there are many valid operational reasons to want to use scripting languages (portability, ease of use, run-time dynamics so on); I'm not saying that we don't need scripting languages. However, I nevertheless believe that in terms of expressiveness, the best possible scripting language for a job is going to be one that aligns the script and the code that executes it as one and the same thing.

Why, yes, I have been reading students' final-year project reports.




Latest entries.

Archived entries.

About this blog.

Copyright © 2012 Richard Bartle (richard@mud.co.uk).