
16Ģ2 Abstraction of reality Definition To increase expressivity, programming languages introduce new abstractions of physical concepts. With ultimate goal to describe toughts and instruct machines with a language that is the most natural possible. 14Ģ0 A universal programming language? Why there are so many programming languages? One universal language is not enough? 5 There are more than 1000 programming languages 15Ģ1 A universal programming language? For the same reason why there are multiple natural languages multiple programming languages has been created to introduce new ideas and new ways of thinking.

Strongly typed languages are often termed type-safe or safe. An attempt to perform an operation on the wrong type of value raises an error.

Strong typing: restrictions are applied on conversions between types. Dynamic typing: determines the type-safety of operations at run time in other words, types are associated with run-time values rather than textual expressions 13ġ8 Strong and Weak typing Weak typing: allows a value of one type to be treated as another, e.g. Example of operation where the result depends on the type system of the languageġ7 Static and Dynamic typing Static typing: all expressions have their types before the program is executed, typically at compile-time. For example in Java, the semantic of + between Strings is not addition, but concatenation (In Javascript God only knows) The type system instead tell us what s the expexted behaviour when semantics rules are applied on a type.

Note: the compiler can make changes on the structure (loop -> unroll, switch -> if else) 11ġ6 Type system Semantics give us the meaning of the operations of a Language. 4 In other words, this definition tell us that a program written in C, when compiled into Assembly, the meaning of the program will remain the same. E 0 1 (not E) (E or E) (E and E) (1) Grammars of more complex languages: Grammar of Java 8 Grammar of Javascript A dialect of SQL 7ġ4 Example informal Semantics: Italian gestures 10ġ5 Translational Semantics Definition The semantics of a programming language L can be preserved when the language is translated into another form, called target language L t. 1 Regular ContextFree ContextSensitive Unrestricted 2 The parsing phase of a compiler uses Context-Free grammars to build the Parse Tree 5ĩ Grammars: Expressivity power Can we write a regular expression that match the minimum number in a finite array of integers (represented as string)? 3 Finding the minimum requires the ability to have knowledge of the past (store infos and compare) and this is possible only from Type-2 grammars 6ġ0 Example Grammar: Boolean expressions The follwing an example of grammar that describe the basic boolean expressions. 4Ĩ Grammars: Chomsky Hierarchy Grammar Language Example Type-0 Unrestricted Subset of English Type-1 Context-Sensitive C Type-2 Context-Free Basic SQL Type-3 Regular Regex Languages described by Type-0 grammars are the most expressive, compared to Type-3 which are the less expressive. Different types of grammars generate languages with different expressivity power. These are called generative grammars, formalised by Noam Chomsky in the 50 and he classified them into types now known as the Chomsky hierarchy. Now, how do we specify a formal language? 3ħ Syntax: How is defined Syntax of Formal languages can be defined in terms of Grammars (like natural languages). Language should be interpreted in its broadest sense: there are formal visual languages and natural body languages sounds can be used to define formal languages as well as to compose music.

#C knights an introduction to programming in c pdf free
Contrast this with natural languages used in Nature: Syntax is relatively free and the Semantics depend subjective interpretation. 1Ĥ Example Languages Following examples of languages: All complete sentences occuring in the tragedy of Macbeth Italian gestures 0 * is called Kleene star, from Stephen Kleene who helped formalise regular expressions 2ĥ Formal and Natural Languages Formal means precisely defined, both in term of Syntax and Semantics. Examples: letter and digits, ideograms, gestures, emojis. We call symbol a primitive, abstract not better defined entity. Definition An alphabet Σ is a finite set of symbols. 1 Introduction to Programming Languages Syntax, Semantics and brief history of programming languages Ayoub Ouarrak ģ Languages and Alphabet The concept of language is very general: A language L is a set of strings over an alphabet Σ.
