Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Introduction

CNG 242 Programming Language


Concepts
Lecture - 1

Instructor: Dr. Enver Ever


Introduction (1)

• The first high-level programming languages were designed during


the 1950s.

• Ever since then, programming languages have been a fascinating


and productive area study.

• Programmers endlessly debate the relative merits of their favourite


programming languages

• Ada Lovelace provided the first algorithm on Charles Babbage's


early mechanical general-purpose computer called the Analytical
Engine.
Introduction (2)
• Church-Turing hypothesis say all programming languages and
computational devices have the same power regarding
computability.
• If you can define a computation in one of the universal
programming languages, you can define the same computation in
any other universal programming language.
• Why do we have so many programming languages?
• ``Hello world'' in different languages:
http://www.roesler-ac.de/wolfram/hello.htm–
http://www2.latech.edu/~acm/HelloWorld.shtml
• Is it desirable to know as much distinct P.L. as possible?
Why are there so many programming languages?

• There are thousands!


• Evolution
– Structured languages -> OO programming
• Special purposes
– Lisp for symbols; Snobol for strings; C for systems;
Prolog for relationships
• Personal preference
– Programmers have their own personal tastes
• Expressive power
– Some features allow you to express your ideas better
Why are there so many programming languages? (2)

• Easy to use
– Especially for teaching / learning tasks
• IEEE Spectrum 2017 • IEEE Spectrum 2021
• IEEE Spectrum 2018 • IEEE Spectrum 2022
• IEEE Spectrum 2019 • Introductory Teaching Languages US
• IEEE Spectrum 2020 • Introductory Teaching Languages UK
• Ease of implementation • Business Insider, 2023

– Easy to write a compiler / interpreter for


• Good compilers
– Fortran in the 50’s and 60’s
• Economics, patronage
– CoBOL and Ada, for example
Intro (cnt)

• Programming languages are our MOST basic tools


• We need to understand programming language
concepts when
– learning a new language and how to use them
effectively
– Deciding which programming language is most suitable
for the given problem
• Concepts
– Data and types, variables and storage, binding and
scope, procedural abstraction, data abstraction, type
systems…
Course Objectives

• We will not learn specific programming languages.


• Haskell, C++ and Prolog languages are tools of this
course.
• We will study the common concepts of programming
languages.
• We will study different paradigms and approaches.
• What is the measure of quality in a programming
language?
• Construct a basis for other topics like compiler
design, software engineering, object oriented design,
human computer interaction...
Related Areas

• Human computer interaction


• Operating systems
• Computer Architecture
• Databases and information retrieval
• Software engineering
Programming domains
• Scientific applications
– Using the computer as a large calculator
– Fortran and friends, some Algol, APL
– Using the computer for symbol manipulation
– Mathematica (from Wolfram great tool http://integrals.wolfram.com/index.jsp)
– (Solve [x^2-5x+6==0, x]) (http://www.wolframalpha.com/ )
– https://www.wolframalpha.com/calculators/system-equation-calculator
• Business applications
– Data processing and business procedures
– Cobol, spreadsheets
• Systems programming
– Building operating systems and utilities
– C, PL/S, ESPOL, Bliss, some Algol and derivitaves
Programming domains
• Parallel programming
– Parallel and distributed systems
– Ada, CSP, Modula, DP, Mentat/Legion
– Communicating Sequential Processes (CSP) is a formal language for
describing patterns of interaction in concurrent systems.
• Artificial intelligence
– Uses symbolic rather than numeric computations
– Lists as main data structure
– Lisp in 1959, Prolog in the 1970s
• Scripting languages
– A list of commands to be executed
– UNIX shell programming, awk, tcl, Perl
– Programs are written for a special run-time environment that can interpret instead of
compiling and automate the execution of tasks in environments that such as
software applications, web pages within a web browser, the shells of operating
systems (OS), and embedded systems.
Programming domains
• Education
– Languages designed to facilitate teaching
– Pascal, BASIC, Logo
• Special purpose
– Other than the above…
– Simulation (performance? ease of use? simulators?)
– Specialized equipment control
– String processing
– Visual languages (Users create programs by manipulating
program elements graphically rather than by specifying them
textually.Simulink of Matlab, Labview of NI, Microsoft Visual
Programming Language (VPL) )
– https://scratch.mit.edu/projects/editor/
– https://logic.ly/demo/
Programming Languages vs Natural Languages

• Both programming languages and natural languages have syntax


(form) and semantics (meaning).

• However, natural languages are far broader, more expressive, and


subtler than programming languages.
Programming Languages vs Natural Languages (2)

• Programming languages are Formal (may be constrained by rules


that are specific to it)

• Natural languages can be Informal and refers to languages that has


developed naturally, and hence to actual speech, rather than
prescribed speech.

• Strict rules of well-formedness vs Error tolerant


Programming Languages vs Natural Languages (3)

• Restricted vs Unrestricted domain


– A natural language is just what a human population speaks and writes,
so linguists are restricted to analyzing existing (and dead) natural
languages.

– On the other hand, programming linguists do not only analyze existing


programming languages; they can also design and specify new
programming languages, and they can implement these languages on
computers.
What makes a language programming language?

•Is any formally defined language a programming language? (HTML?)

•Universal: Every problem must have a solution that can be


programmed in the language, if that problem can be solved at all by a
computer.
– Any language in which we can define recursive functions is
universal. On the other hand, a language with neither recursion
nor iteration cannot be universal.
– All computation problems should be expressible.
condition+(loop and/or recursion).
What makes a language programming language?(2)
•Natural:
– natural for solving problems, at least problems within its intended
application area.
– All features required for the application domain.
• Fortran: numerical computation,
• COBOL: file processing,
• LISP tree and list operations.

•Implementable: It is possible to write a compiler or interpreter working on a


computer.
– Mathematics : not implementable, because in this notation it is possible
to formulate problems that cannot be solved by any computer.
– natural language: not implementable imprecise and ambiguous

•Efficient: Works with acceptable amount of CPU and memory


Paradigms
• Just as important as the individual concepts are the ways in which they may be
put together to design complete programming languages.

• There are different selections of key concepts support radically different styles
of programming, which are called paradigms.
• There are six major paradigms.
– Imperative programming : characterized by the use of variables, commands,
and procedures (Fortran, Cobol, Pascal, C, C++, Java,Basic)
– object-oriented programming: by the use of objects, classes, and
inheritance (Smalltalk, C++, Object Pascal, Eifell,Java, Csharp)
– concurrent programming: by the use of concurrent processes, and
various control abstractions; (Ada, Occam, Par-C, Pict, Oz)
– functional programming: by the use of functions; (Lisp, ML, Haskell)
– logic programming: by the use of relations
– scripting languages: by the presence of very high-level features.
Syntax and Semantics
• Syntax =Form.
– Concerned with the form of programs: how expressions, commands, declarations,
and other constructs must be arranged to make a well-formed program.
– How language is structured, how it is expressed.
– Syntax is represented by Context Free Grammars expressed in BNF (Bacus Naur
Form) notation (SeeCNG 280, Formal Languages and Abstract Machines)
• Semantics=Meaning
– Concerned with the meaning of programs: how a well-formed program may be
expected to behave when executed on a computer.
– What does a program mean? How it works.

• Pragmatics is concerned with the way in which the language is intended to


be used in practice.
Language processors
• Compilers (gcc, javac, f77)

• Interpreters (scheme, hugs, sml, bash)

• Beautifiers, pretty printers (a2ps, ident)


• stylistic formatting conventions to text, source code, markup, and other similar kinds of content.
• Mathematica converting x^2 to x2

• Syntax directed editors (vim, anjuta, eclipse,visual studio)

• Validators (vgrind, lint)


• to check the validity or syntactical correctness of a fragment of code or document.

• Verifiers
History

You might also like