
A programming language is a formal constructed language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs to control the behavior of a machine or to express algorithms.The description of a programming language is usually split into the two components of syntax (form) and semantics(meaning). Some languages are defined by a specification document (for example, the C programming language is specified by an ISO Standard), while other languages (such as Perl) have a dominant implementation that is treated as a reference.
A programming language is a notation for writing programs, which are specifications of a computation or algorithm. Some, but not all, authors restrict the term "programming language" to those languages that can express all possible algorithms. Traits often considered important for what constitutes a programming language include:
Function and target :
A computer programming language is a language used to write computer programs, which involve a computer performing some kind of computation[4] or algorithm and possibly control external devices such as printers, disk drives, robots.
Abstraction :
Programming languages usually contain abstractions for defining and manipulating data structures or controlling the flow of execution. Expressive power.The theory of computation classifies languages by the computations they are capable of expressing. All Turing complete languages can implement the same set of algorithms.
Elements :
Syntax :Main article: Syntax (programming languages)A programming language's surface form is known as its syntax. Most programming languages are purely textual; they use sequences of text including words, numbers, and punctuation, much like written natural languages.
Semantics :The term Semantics refers to the meaning of languages, as opposed to their form (syntax).
Static semantics : The static semantics defines restrictions on the structure of valid texts that are hard or impossible to express in standard syntactic formalism. For compiled languages, static semantics essentially include those semantic rules that can be checked at compile time.
Dynamic semantics : Main article: Semantics of programming languages,Once data has been specified, the machine must be instructed to perform operations on the data. For example, the semantics may define the strategy by which expressions are evaluated to values, or the manner in which control structures conditionally execute statements.
Static versus dynamic typing :
In static typing, all expressions have their types determined prior to when the program is executed, typically at compile-time. For example, 1 and (2+2) are integer expressions; they cannot be passed to a function that expects a string, or stored in a variable that is defined to hold dates.Statically typed languages can be either manifestly typed or type-inferred. In the first case, the programmer must explicitly write types at certain textual positions (for example, at variable declarations). In the second case, the compiler infers the types of expressions and declarations based on context. Most mainstream statically typed languages, such as C++, C# and Java, are manifestly typed.
Dynamic typing, also called latent typing, determines the type-safety of operations at run time; in other words, types are associated with run-time values rather than textual expressions.Weak and strong typing Weak typing allows a value of one type to be treated as another, for example treating a string as a number. This can occasionally be useful, but it can also allow some kinds of program faults to go undetected at compile time and even at run time.
Strong typing prevents the above. An attempt to perform an operation on the wrong type of value raises an error. Strongly typed languages are often termed type-safe or safe.
No comments:
Post a Comment