what is a language specification?

  softwareengineering

Either I am being a total n00b or just not with it today but I have been reading a few blogs lately and they talk about language specs. What actually is a language spec? Is php.net a language spec? The best article so far I have read is Grokbase on the PHP Language Specification.

A specification is a document in human language describing how a system is supposed to work. In the case of a programming language, it describes how the compiler or interpreter is to react to various inputs – which are valid/invalid, and what happens when they are executed.

A reference implementation such as “this specific compiler” is not a specification. It also defines a function from inputs to outputs, but it cannot be read by humans, you can only experiment with it. Of course you can write a trivial doc saying “everything that implementation XY does is by definition expected”, but that goes completely against the point of having a spec in the first place – the implementation almost certainly contains errors, does undefined things on certain inputs that you can’t distinguish from defined but complex things, conversely it behaves consistently in some way where there is really no reason to prescribe one way over the other, etc.

When you need reassurance what a program is supposed to do, when you need to stay correct even across upgrades of a runtime system, when you have to formally prove that a solution is correct, when you want to write code that must run on alternate implementations – in other words, whenever a basic “It works for me” test isn’t good enough – then you need a specification, not just a running program.

2

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website Kho Theme wordpress Kho Theme WP Theme WP

what is a language specification?

Either I am being a total n00b or just not with it today but I have been reading a few blogs lately and they talk about language specs. What actually is a language spec? Is php.net a language spec? The best article so far I have read is Grokbase on the PHP Language Specification.

A specification is a document in human language describing how a system is supposed to work. In the case of a programming language, it describes how the compiler or interpreter is to react to various inputs – which are valid/invalid, and what happens when they are executed.

A reference implementation such as “this specific compiler” is not a specification. It also defines a function from inputs to outputs, but it cannot be read by humans, you can only experiment with it. Of course you can write a trivial doc saying “everything that implementation XY does is by definition expected”, but that goes completely against the point of having a spec in the first place – the implementation almost certainly contains errors, does undefined things on certain inputs that you can’t distinguish from defined but complex things, conversely it behaves consistently in some way where there is really no reason to prescribe one way over the other, etc.

When you need reassurance what a program is supposed to do, when you need to stay correct even across upgrades of a runtime system, when you have to formally prove that a solution is correct, when you want to write code that must run on alternate implementations – in other words, whenever a basic “It works for me” test isn’t good enough – then you need a specification, not just a running program.

2

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website Kho Theme wordpress Kho Theme WP Theme WP

LEAVE A COMMENT