Download presentation
Presentation is loading. Please wait.
Published byRosalyn Russell Modified over 9 years ago
1
Gary MarsdenSlide 1University of Cape Town Principles of programming language design Gary Marsden Semester 2 – 2001
2
Gary MarsdenSlide 2University of Cape Town Efficiency Efficiency is a complex term It is tempting to think about machine efficiency, and producing a program which runs as quickly as possible Stop and think about hardware and programmer efficiency Also think about the ‘how’ and ‘why’ we use computers may have changed in the last 50 years
3
Gary MarsdenSlide 3University of Cape Town In the beginning… … computers were slow. They ran one program at a time in batch mode It was essential that the computer’s time was used as efficiently as possible Programmers therefore spent a long time writing machine code programs which would run as efficiently as possible
4
Gary MarsdenSlide 4University of Cape Town High level languages HLL’s recognise that programmer time needs to be used efficiently in response to a decreasing cost of computer equipment. So HLL’s must be efficient We understand the notion of efficient executable code, but are there other sorts of efficiency
5
Gary MarsdenSlide 5University of Cape Town Translation Efficency One area of efficiency concerns how quickly the source language can be changed in to machine code Pascal, for example, forces declaration of variables before use – resulting in a one pass compiler There is often a trade off, meaning faster compilation results in less reliable code
6
Gary MarsdenSlide 6University of Cape Town Implement-ability This is concerned with the efficiency with which a compiler can be written Some languages are so complex that compilers take a long time (possibly never) to implement –Algol68 was never properly implemented –Ada is large and has few compilers –ML had to wait for algorithms to be created to support its (then) unique type inference scheme
7
Gary MarsdenSlide 7University of Cape Town Programming efficiency How efficiently does allow a programmer to specify ideas? Reducing unnecessary details, like explicit typing, plays a part in this Functional languages are particularly concise, but at what cost? –maintainability –readability –execution efficiency
8
Gary MarsdenSlide 8University of Cape Town Generality Generality is achieved in languages by removing special cases and several similar concepts into a single, more general, one. Examples include –Fixed length arrays in Pascal –C allows ‘=‘ operator on all basic types, but not arrays or records However, generality can reduce simplicity, readability and reliability (C pointers are a good example of this)
9
Gary MarsdenSlide 9University of Cape Town Orthogonality Language constructs should not behave differently in different contexts Examples include –in C functions can return any data type except arrays –all function parameters in C are passed by value, except arrays, which are passed by value Orthogonality was the design goal of Algol68, which allows any combination of meaningful constructs
10
Gary MarsdenSlide 10University of Cape Town Uniformity Uniformity is interested in things which –are similar but do not behave, or look similar –behave and look similar, but are not similar Examples –Pascal has no “Begin..End” statements in “Repeat” loops, but does have in “While” and “If” and “For” –‘;’ used a conjunction in Pascal, but terminator in C –Case statement used for variant records in Pascal
11
Gary MarsdenSlide 11University of Cape Town General good design Simplicity – “things should be as simple as possible, but not simpler” Einstein Expressiveness – what does this mean? –while( *s++ = *t++) Independence – The language should be separate from particular hardware (Java) Security – Protecting programmers from themselves –type declarations – catching as much at compile time
12
Gary MarsdenSlide 12University of Cape Town General good design - II Consistency with accepted design – reuse concepts Extensibility – adding features, operator overloading Restrictability – allowing the programmer to create useful programs without the need to learn the whole language
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.