0

https://en.wikipedia.org/wiki/Execution_model says

A programming language consists of a grammar/syntax plus an execution model. The execution model specifies the behavior of elements of the language. By applying the execution model, one can derive the behavior of a program that was written in terms of that programming language. For example, when a programmer "reads" code, in their mind, they walk through what each line of code does. In effect they simulate the behavior inside their mind. What the programmer is doing is applying the execution model to the code, which results in the behavior of the code.

Each and every programming language has an execution model, which determines the manner in which the units of work (that are indicated by program syntax) are scheduled for execution.

Operational Semantics is one method of specifying a language's execution model. The observed behavior of a running program must match the behavior derived from the operational semantics (which define the execution model of the language).

An execution model covers things such as what is an indivisible unit of work, and what are the constraints on the order in which those units of work may take place. For example, the addition operation is an indivisible unit of work in many languages, and in sequential languages such units of work are constrained to take place one after the other.

Are the operational semantics of a programming language and the execution model of the language exactly the same thing? https://en.wikipedia.org/wiki/Operational_semantics seems to me yes:

Operational semantics is a category of formal programming language semantics in which certain desired properties of a program, such as correctness, safety or security, are verified by constructing proofs from logical statements about its execution and procedures

What are other methods of specifying a language's execution model, besides operational semantics?

https://en.wikipedia.org/wiki/Programming_model says

A programming model refers to the style of programming where execution is invoked by making what appear to be library calls. Examples include the POSIX Threads library and Hadoop's MapReduce.[1] In both cases, the execution model is different from that of the base language in which the code is written. For example, the C programming language has no execution model for input/output or thread behavior. But such behavior can be invoked from C syntax, by making what appears to be a call to a normal C library.

What distinguishes a programming model from a normal library is that the behavior of the call cannot be understood in terms of the language the program is written in. For example, the behavior of calls to the POSIX thread library cannot be understood in terms of the C language. The reason is that the call invokes an execution model that is different from the execution model of the language. This invocation of an outside execution model is the defining characteristic of a programming model, in contrast to a programming language.

How can I tell if a library's execution model is the same as or different from the execution model of its base language? I.e. how can I tell if a library is a programming model or a normal library?

Thanks.

2
  • 3
    By reading its documentation? Commented Feb 3, 2021 at 19:26
  • All libraries are both. The C language doesn't specify what happens when you call decode_jpeg. And pthreads is also just a library. Commented Feb 3, 2021 at 20:56

1 Answer 1

2

Are the operational semantics of a programming language and the execution model of the language exactly the same thing?

No. It says as much in the text you quoted. The operational semantics define the execution model for the language. One follows from the other.

What's the difference? The execution model of a language describes the behavior that will occur when you execute certain instructions in the language. The operational semantics describe the proof. Categorically, the execution model of the language is within the province of Software Engineering and is described by language specifications, while the operational semantics fall squarely within the Computer Science domain and are described by math.

As a software engineer, will you ever need to know anything about the operational semantics of a language? Probably not, unless perhaps you are designing a programming language.

What are other methods of specifying a language's execution model, besides operational semantics?

A language specification: a detailed representation of precisely what each and every instruction in the language does.

How can I tell if a library's execution model is the same as or different from the execution model of its base language?

Read the source code, if it is available. This will tell you things like how POSIX threads are implemented, even though the C language doesn't support them directly.

If a library, operating system or instruction set is well-architected, you should be able to use it successfully without knowing its execution model or reading the source code. You ought to be able to treat that library like a black box. Abstractions are just that; they're supposed to shield you from the underlying details. In practice, this doesn't always happen, and then you have what we call a "leaky abstraction."

Of course, these are all academic distinctions. For the most part, you won't need to know whether or not a library happens to have the same execution model as the programming language that uses it. It simply doesn't matter. Let's say that you have a C program that uses a part of the standard library that happens to conform to the execution model of the C language itself. What happens if you call that library using Python's C API? Does it make a difference that the calling language is not C anymore?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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