150 likes | 172 Views
This document provides an overview of programming languages, including their syntax, data types, and generations. It also covers imperative and declarative programming languages, domain-specific languages, and parallel languages.
E N D
Taxonomy of Programming Languages CSCI 432 Computer Science Theory
Misc Notes • We have been studying languages all semester. • Languages defined by Finite Automata • Regular Languages • etc
Importance of Types The syntax of a language is governed by the constraints that define its data types. For example: • everything in Java is a class • most scripting languages use weak type checking
High Level v. Low Level Low Level Language: • eg, Assembly • every instruction is done by a piece of hardware • faster than compiled or interpreted High Level Language High Level Language: • easier to code, manage, test, etc.
Compiled v. Interpreted Advantages of Compiled • the machine code in the .exe file runs fast • compiler probably optimizes your code Advantages of Interpreted • portable
Imperative Programming Languages English definition of "Imperative" - essential, authoritative command statements that change the machine's state • this is the majority of programming languages • some imperative languages have declarative properties • two subtypes • procedural • object-oriented
Components of Imperative Langs • Sequence • how to control program flow from one statement to the next • eg blocks of code, procedures, functions, recursion • Selection • making decisions • eg ifstatements and case statements • Iteration • repeating instructions • eg for loops and while loops
Declarative Programming Languages specify what is to be done, not how to do it • does not specify control flow or order of operations • examples • HTML • SQL
Generations • 2nd Generation Languages (2GL) • Assembly • 3rd Generation Languages (3GL) • Higher level than 2GL, like C and C++ • some 3GLs, like Python, have libraries of routines that give them 4GL characteristics
Generations • 4th Generation Language (4GL) • Operating on large collections of data • for example: SQL, report writers • 5th Generation Language (5GL) • Problem solving based on constraints instead of algorithms • Artificial Intelligence programming • area of research for past 20 years, without significant progress • given a set of constraints, finding an algorithm to solve the problem is usually very difficult, thus usually requires a programmer (3GL or 4GL)
Domain Specific Languages as opposed to a General Purpose Language Examples: • HTML • statistical modeling languages • OpenGL shading language • software engineering - eg requirements specifications • shells - ls, ps, grep, sort, head, wc, …
Parallel Languages non-parallel a[]=b[]+c[] : for (i=0; i<size; i++) a[i] = b[i] + c[i]; Compiler and OS: forall(i=0; i<size; i++) a[i] = b[i] + c[i]; Programmer: function add (start, stop) { for (i=start; i<stop; i++) a[i] = b[i] + c[i]; } for (processor=0;processor<8;processor++) clone (processor, add(processor*size/8,(processor+1)*size/8));
FORTRAN and COBOL Example FORTRAN Code PROGRAM DEMO PRINT *, 'Enter number?' READ *, X IF (X.LE.0) THEN PRINT *, 'That is negative.' STOP END IF PRINT *, 'That is positive.' STOP END
LISP • List Processing • Everything is a list • ((Jimmy Carter), (Ronald Reagan), (George Bush), …….) • >(defunfactorial (N) • (if (= N 1) • 1 • (* N (factorial (- N 1))))) • >(eval factorial(5)) • (120)
CLIPS • known facts and rules that work on facts • logic programming language (assert (person (name Steve Dannelly) (occupation Professor) (home Rock Hill))) (facts) (defrulefire-emergency (emergency (type fire)) => (assert (response (action sprinkler-on))) )