Download presentation
Presentation is loading. Please wait.
Published byElinor Harrell Modified over 9 years ago
1
159.331Prog Lang & Alg1 159.331 Programming Languages & Algorithms Lecture 02 - Aspects of Programming Languages - Part 1 (Figures from Bal & Grune)
2
159.331Prog Lang & Alg2 What is a Programming Language? A vehicle for the user to tell the computer what to do to solve the user’s problem Enables the user to bridge the gap between problem domain and machine domain –Problem domain is all about the application –Machine domain is about memory and cpu, peripherals and the computer’s capabilities
3
159.331Prog Lang & Alg3 Which Programming Language? There are lots of programming languages (estimates vary but probably over 4000 in existence!) Not all languages equally important Are grouped in families based around key ideas So we don’t need to know them all (luckily!) Some support some ideas and algorithms better than others (“better” might mean in terms of speed or cost) Its important to know which is best for a particular sort of problem
4
159.331Prog Lang & Alg4 Who is the Language For? The human - needs to be readable and in language that is memorable and understandable to the human who wrote it and the (possibly different) humans who have to read it The computer - just needs a compiler that understands the particular language –Sometimes it does not even need a compiler!
5
159.331Prog Lang & Alg5 Machine Code Machine code is about as low a level language as we can get - maybe not even a “language” at all - just a list of numbers Specifies hardware machine instructions like: –Move the number in register X to memory location Y –Add two registers together leaving answer in another –Branch two instructions forward if register X is zero Often in hexadecimal - base 16 - translates into values that control the hardware - the voltages on the wires! (hex 0123456789ABCDEF) Rare that we need to work at this level - tools to help us
6
159.331Prog Lang & Alg6 A Reminder - What is a Computer? Generally (although not necessarily) a von Neumann machine (after John von Neumann) Machine has a state (of the registers etc) An instruction pointer (IP) telling it which to do next Flow of control is to march through its program code Program acts on memory (and devices which might be memory-mapped) Can modify its program data and maybe even its program code too
7
159.331Prog Lang & Alg7 Assembly Language A set of textual macros and mnemonics for the numbers used in machine codes Often manufacturer supplies quite elaborate tools for developing in assembler for their CPU Still hard for humans to work with Often only needed at lowest bootstrap level when developing a new computer Maybe needed to optimise speed of some very important code eg for a device driver
8
159.331Prog Lang & Alg8 Example is for Motorola 68000 Processor
9
159.331Prog Lang & Alg9 Assembly language A step forward from machine code Macros can do some of the tedious address calculations Still machine (CPU product) specific Only very primitive concepts supported: –Arithmetic and Logic –Conditionals –Loops –Branches –Memory addressing
10
159.331Prog Lang & Alg10 Higher-Level Languages All programming languages are attempts to map a problem to the machine To link the user’s problem specific language to the nuts and bolts of the machine. But we can do better than assembler! Some early “High” level languages - Fortran and Cobol and C use ideas (and syntax) that still exist in modern languages such as Ada and build on assembler ideas
11
159.331Prog Lang & Alg11 More readable for Humans than Assembler - and the Compiler can do the loop address calculations for us! Modern Fortran allows us to Use END DO instead of the Numbered continue statement
12
159.331Prog Lang & Alg12 Loop that does nothing except change the loop counter There might be a NOP no operation (a “do-nothing” instruction code)
13
159.331Prog Lang & Alg13 Reminder - What is a Compiler? Compiler is the tool (program) that we run to convert our high level language into machine code Turns our text (that we understand) into numbers (that the computer can use) So who is our programming language text for? Compilers ignore comments - they are for us!
14
159.331Prog Lang & Alg14 Some History Remember Computer Science is still quite a young discipline The oldest material we are discussing is only late 1940s Only around 60 years and much in the last 40 We can look at the decades as an approximate guide:
15
159.331Prog Lang & Alg15 1940s- Pre-lingual Stage Programming early computers in machine code - toggle switches and punch cards Programs were necessarily very small Still useful to make machine do very tedious tasks Before this your “computer” was a human
16
159.331Prog Lang & Alg16 1950s - Exploiting Machine Power Assembler Language used Lots of numerical analysis and number crunching applications Scientific (weather and bomb simulations) IBM Mathematical FORmula TRANslating System - function library for maths
17
159.331Prog Lang & Alg17 1960s - Increasing Expressive Power FORTRAN developed further - Fortran 66 FORTRAN became a non-vendor specific as other companies started competing with IBM COBOL, Lisp, algol 60, BASIC, PL/I… “Serious” programming still done in assembler - machine cycles still (much) more expensive than programmer time!
18
159.331Prog Lang & Alg18 1970s Portability & Correctness Beginnings of the “software crisis” “Structured Programming” and other tools/approaches Pascal, Algol 68, C, Fortran 77 Still lots of assembler Continuation of the night hacker culture - use the machine at unfriendly times when cycles are cheaper
19
159.331Prog Lang & Alg19 1980s Reducing Complexity Start of a continuing problem Large complex codes Ada, Modula-2 Smalltalk (Object oriented) Miranda (Functional) Lots of tools (Make) and Environments NASA and other still use assembler
20
159.331Prog Lang & Alg20 1990s - Parallel and Distributed Massive Parallelism - Special purpose languages for expensive new computers Data-Parallel (High Performance Fortran) Message-Passing Support in languages: Hermes, Linda, Orca, SR, Ada 9X Support in special libraries for eg C++ Reduced Instruction Set Chip architectures (RISC) - too hard for humans to write good assembler
21
159.331Prog Lang & Alg21 2000’s - Virtual Machines Already happening in late 1990s Java Virtual Machine and Verification technologies Copied elsewhere Problem Solving - Very High level languages like Matlab, Mathematica are effectively virtual machines
22
159.331Prog Lang & Alg22 Maybe the 2000’s were the era of “the virtual machine” eg Java, Matlab, Mathematica,…
23
159.331Prog Lang & Alg23 Reminder - What is a VM? A compiler makes code from program text - eg C or C++ - and stores it in a file (of code) An interpreter reads the program text line by line and executes as it goes (usually very slow) - eg Perl or Python interpreters A Virtual Machine is a software machine that executes instructions in some language eg Java Bytecode, or Matlab Language –Combines compiling and interpreter ideas
24
159.331Prog Lang & Alg24 Summary Aspects of Programming Languages - Part 1 –What is a Programming language? –What/Who is it For? –Machines, Code, Assembler –Higher Level languages –A Brief history Bal & Grune Chapter 1; Sebesta Chapters 1&2 See Mashey’s article in ACM Queue (Jan 05) Next - Programming Paradigms
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.