For declarative languages, specifically (but not limited to) in the field of modelling, it's not obvious to me whether code can be considered to be separate from data. This line of reasoning may only apply to non-turing complete languages such as NeuroML.

Say for instance I had a very domain specific declarative language which I used to described the positions of planets and their velocities, and I described a system of three orbiting bodies:

satellite planet_earth,moon,sun {

planet_earth.position = [6,0,0]

planet_earth.velocity = [0,23,-32]

planet_earth.mass = 1e3

moon.position = [6,0,0.0001]

moon.velocity = [0,0,3]

moon.mass = 1e2

sun.position = [0,0,0]

sun.velocity = [0,0,0]

sun.mass = 1e12 }

This language could be passed to a simulator which then simulated the motion of the planets.

From one perspective this is code - It is describing initial conditions and consequently within the constraints of the language a sequence of steps for a computer to run. From another perspective it is 'data' - it is a description of a physical system.

Is this concept (is something code or data) something which has been studied much? I've looked into it

  • 1
    You've looked into it, and? I'm curious what you've found. Sharing your research helps us all, as well as ensuring we don't post what you already know. To be certain this is an interesting question so I'm curious what you stumbled upon when you looked into it. – Jimmy Hoffa Aug 29 '13 at 1:00
  • Positions and velocities change with time. An orbit and trajectory (a function from time to position and velocity) is a bit better, but still wouldn't allow you to model stellar collisions. What are the invariants in your model? – rwong Aug 29 '13 at 3:10
  • This is just hard-coded constants. Nothing to see here, move along. – Deer Hunter Aug 29 '13 at 7:26

I don't see a difference between declarative and imperative languages within the context of your question, so I'll try answering your question in a more general way.

The distinction between code and data is a conceptual one, there is no clear, objective, definition which is applicable to every situation; there will always be cases where different individuals will come to different conclusions.

Consider the the following C++ code:

std::vector<std::string> names = { "Smith", "Miller", "Watson" };

Are the strings data (because they're just embedded strings) or code (because they're part of the source code)?

There are languages in which the code representation is a first-class type of the programming language. These languages are typically homoiconic (i.e., their syntax is very similar to the abstract syntax tree); the archetypal example is Lisp. In these languages, the distinction between code and data is even more blurred.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.