what is a programming language?
Asked Answered
E

8

4

Wikipedia says:

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer. Programming languages can be used to create programs that specify the behavior of a machine, to express algorithms precisely, or as a mode of human communication.

But is this true? It occurred to me in the shower this morning that a programming language might just be a set of conventions, something that both a human and an appropriately arranged compiler can interpret. If that's the case, then isn't it this definition of a programming language misleading? If that isn't the case, then what's the difference between a compiler and the language it compiles?

Thanks!

z.

Executrix answered 15/5, 2009 at 17:39 Comment(0)
L
4

I understand what you are saying, and you are right. Describing a programming language as a "machine-readable artificial language designed to express computations that can be performed by a machine" is unnecessarily specific. Programming languages can be more broadly generalized as established descriptions of tasks (or "a set of conventions") that allow one entity to control the behavior of another. What we traditionally identify as programming languages are just a layer of abstraction between machine code and programmers, and are specifically designed for electronic computers.

Programming languages are not limited to traditional computers (see the K'NEX Computer), and aren't even necessarily limited to computational devices at all. For example, when I am pleased with my dog's behavior, he gets a treat. When I am displeased, he gets nothing. Over time the dog learns the treat/no treat programming and I can use the treats to control his behavior (to an extent).

Levitus answered 15/5, 2009 at 17:57 Comment(1)
your dog might argue that he is controlling your behavior. ㅋㅋㅋExecutrix
T
6

A programming language is exactly that set of conventions, but I don't see why that makes the Wikipedia entry misleading, really. If it makes you feel better, you might edit it to read something like:

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer. Programming languages can be used to define programs that specify the behavior of a machine, to express algorithms precisely, or as a mode of human communication.

Tomasine answered 15/5, 2009 at 17:43 Comment(0)
S
4

I don't see what is different between what you are asking...

It occurred to me in the shower this morning that a programming language might just be a set of conventions, something that both a human and an appropriately arranged compiler can interpret.

... and the Wikipedia definition.

The key is that a programming language is just "a machine-readable artificial language".

Shwa answered 15/5, 2009 at 17:43 Comment(3)
what makes it machine readable, I think that's my question. What does machine readable mean. Thanks!Executrix
Well, machines have a built-in programming language that is extremely simple. It's interpreted by the CPU, and consists of instructions that map directly to the CPU's hardware capabilities. So that's the only truly "machine-readable" language on your computer. Other compilers are more or less intermediary tools to translate from more abstract programming languages into this very simple language.Tomasine
And that one's machine-readable because it's built into the hardware. The CPU is hard-wired to look in specific places for the instructions it understands and to respond appropriately. The others, by proxy, are machine-readable since we have created a system to translate between them.Tomasine
R
4

A compiler does indeed act as an effective specification of a language in terms of a reduction to machine code - however, as it's generally difficult to understand a language by reading the compiler's source, one generally considers a programming language in terms of an abstract processing model that the compiler implements. This abstract model is what one means when one refers to the programming language.

That said, there are indeed many languages (Hi there, PHP!) in which the compiler is the only specification of the language in existence. These languages tend to change unpredictably at times as compiler bugs are fixed or introduced.

Role answered 15/5, 2009 at 17:44 Comment(2)
The compiler might also have bugs or purposeful omissions and changes; there's no guarantee that any compiler is actually a 100% faithful representation of a language (assuming that the language designers have created a formal specification elsewhere.)Tomasine
It is, however, a 100% faithful representation of the language that it implements, which may not be equivalent to the language the programmer has in mind.Role
L
4

I understand what you are saying, and you are right. Describing a programming language as a "machine-readable artificial language designed to express computations that can be performed by a machine" is unnecessarily specific. Programming languages can be more broadly generalized as established descriptions of tasks (or "a set of conventions") that allow one entity to control the behavior of another. What we traditionally identify as programming languages are just a layer of abstraction between machine code and programmers, and are specifically designed for electronic computers.

Programming languages are not limited to traditional computers (see the K'NEX Computer), and aren't even necessarily limited to computational devices at all. For example, when I am pleased with my dog's behavior, he gets a treat. When I am displeased, he gets nothing. Over time the dog learns the treat/no treat programming and I can use the treats to control his behavior (to an extent).

Levitus answered 15/5, 2009 at 17:57 Comment(1)
your dog might argue that he is controlling your behavior. ㅋㅋㅋExecutrix
S
2

Programming languages are an abstraction layer that helps insulate the programmer from having to talk in electrical signals to the computer. The creators of the language have done all the hard work in creating a structure (language) or standard (grammar, conjugation, etc.) that then can be interpreted by a compiler in terms that the computer understands.

Shavonda answered 15/5, 2009 at 17:48 Comment(0)
R
1

All programming languages are really nothing more than domain specific languages for machine code or manipulating the registers and memory of a processing entity.

Rimola answered 15/5, 2009 at 18:57 Comment(0)
I
1

This is probably the true explanation of what a programming language really is:

Step 1: Think of a language and its grammar, which is a set of rules for making syntactically valid statements using the language. For example, a language called GRID has tiles {0,1} as its alphabet and grammar rules that make sure every GRID statement has equal length and height.

Step 2 (definition of program): GRID, so far, is useless. I'd dare to think of any valid statement of GRID as just data. We need to add something else to GRID: a successor function. So GRID={Grammar, alphabet, successor function}. To make this clear, lets use the rules of "The Game of Life" as successor function.

Step 3: The Game of Life is actually Turing Complete, so GRID={Grammar, alphabet, successor function = GOL} can perform any computation that is computable.

A programming language is nothing but a language with a successor function. The environment that evaluates a valid statement of the language(program) does nothing but follow those successor functions. Variables, for example, are things whose successor functions = (STAY THE SAME)

Computers are just very fast environments ;)

Involucel answered 16/2, 2016 at 5:23 Comment(0)
U
0

Wikipedia's definition might have been taken out of context. For one thing, only programs written in machine code are machine-readable. Otherwise, you need a compiler to convert C++, Java or even assembly code to machine code so the computer can carry out your instructions. Unless you include comments that are only readable to humans, or unless you are strictly discussing a topic within the realm of your program, programming is insufficient for human communication.

Uncial answered 29/12, 2018 at 23:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.