Session 1b: Background & Preliminaries What is computer programming? The stored-program concept. The procedural paradigm. What is a programming language? The object-oriented paradigm C#: ancestors & origins Why do we have to know all that? The stored program concept (the procedural paradigm) Memory Registers Instructions and data Peripheral devices Addressable main high-speed memory An array of cells that can hold data On most modern computers each cell contains a byte of information. What's that? The cells are consecutively numbered. The number corresponding to a cell is its address. May be volitile or non-volatile. What does that mean? What are bytes? A group of 8 bits (0 or 1) stored together Term originated with the IBM 360 series ~1964. Why 8? What are bits? The simplest unit of data representation in electronic devices: 2 possible values Value can be interpreted as 0 or 1 off or on How many values can a byte represent? How many distinct characters? How many numbers? What if we need more? COMP 170 fall 2013 1-4 copyright 2013 Conrad Weisert
Registers: usual characteristics Temporary volatile storage For a numeric (or other) quantity How many bytes? Higher speed access than main memory Participate in an arithmetic (or other) operation Von Neumann machine architecture The main point is that memory cells or registers can contain a representation of: a. either a data item to be operated upon, interpreted as a number, one or more characters, or individual bits b. or an instruction usually specifying an operation to be performed (such as?), and the location (address) in main memory of a cell containing the data to perform it on An obsolete technique A Von Neumann machine characteristic is that the contents of a memory cell can be treated both as a data item and as an instruction So programs could modify parts of themselves! That's an immensely powerful concept, but It can make programs extremely hard to understand. Fortunately modern machines and modern programming languages eliminate the need (the temptation) for self-modifying programs. We rarely do that any more. Peripheral devices In addition to the central processor and main memory, a computer configuration usually includes attached devices for communicating with the outside world: peripheral devices displays printers modems storage devices disks other mass storage COMP 170 fall 2013 5-8 copyright 2013 Conrad Weisert
Programming languages (simplified overview) Assembly languages Higher-level mainstream languages Pure procedural Object-oriented Examples? Problem-oriented Non-procedural Sometimes called "4th generation" Why are there so many? Where did C# come from? Higher-level programming languages higher than what? Impact of minicomputers, ~1970 need for a smaller language Bell Laboratories and C Kernighan & Ritchie's popular book The object paradigm (OOP) Object-oriented languages as extensions of C Impact of minicomputers Advances in technology made some new machines, compared with $2,000,000 mainframes: physically much smaller much less expensive They could be deployed on submarines, on satellites, in telephone switching centers, etc. But memory was still fairly expensive Affordable size was much too small to run either compilers for powerful programming languages or the typical object programs they produced. What could we do about that? Bell Labs to the rescue! Bell Laboratories, the research part of AT&T, needed to deploy minicomputers: for their own new equipment, such as automated call switching centers for government (defense, etc.) contracts But programming them in assembly languages (each model was different) would be prohibitively expensive. current compilers for PL/I, Ada, or other powerful languages were too big to fit on minicomputers Therefore... COMP 170 fall 2013 9-12 copyright 2013 Conrad Weisert
A new higher-level language was needed It would have to: fit on mini- and micro- computers generate extremely efficient code allow access to machine details It didn't need to support general business or scientific applications Dennis Ritchie and others worked on experimental versions: The first one was called A; it wasn't satisfactory The next one was called B; better but still not good enough. The birth of C They got it right. C was well suited to programming small machines. It allowed low level access to many machine-specific features, without requiring dependence on other details of machine architecture. Kernighan & Ritchie wrote a book describing it. They didn't intend to propose C as a general-purpose language for typical application development But the book was so well written that it became a best seller, and everyone wanted to get C and try it especially on small machines. So, C became a favorite programming language and a candidate for standardization. The C family of O.O programming languages Built upon the syntax and semantics of C Facilitates learning and encourages acceptance Once you know C, then many parts of these languages are familiar. Objective C C++ Java C# To learn them, you focus on the O.O. and other advanced facilities. You already know the rest. Is that an advantage or a handicap? What if you don't know C? Why so many? What does "object oriented" mean? We'll learn the details starting in week 9 It's a way of organizing large programs to minimize interdependencies between data and executable code to facilitate future change with minimum impact It simplifies: both application-domain data and programming constructs What are those? It includes procedural programming, so you have to learn that anyway. COMP 170 fall 2013 13-16 copyright 2013 Conrad Weisert
Includes: C++ Java C# C family of object-oriented programming languages Each of them is built on C C is (almost) a subset of each of them Is that good or bad? What are the main differences? Which one is best? Why C#? Both Java and C++ presented serious shortcomings for large-scale applications: C++ didn't support standard techniques for: web deployment multi-tasking protection against malicious intrusion (viruses) Java did, but making all objects reference data undermined the object paradigm extremely inefficient for many kinds of application-domain object Microsoft origin. Why? It does now! What's that? C# as a better C Bjarne Stroustrup, the principal designer of C++, claimed that one could ignore the object-oriented facilities and use C++ as a purely procedural programming language. That would still be superior to old-fashioned C programming, because C++ had tidied up some other inconsistent, error-prone features. "C++ is a better C" was the argument. That's true also of C# and to a degree Java. That's why the early parts of this course focus on procedural programming. We'll introduce object-oriented concepts later. The downside of C# Although C# corrects many shortcomings of C++ Java, it's still not an ideal language for learning programming: It's too big and complicated It has many features we don't need for typical problems. In this course we shall focus on a useful subset of C#. We shall: ignore features we don't need. choose a sensible subset of the available options. oversimplify or skip over a few troublesome issues. How will that affect our course objectives? COMP 170 fall 2013 17-20 copyright 2013 Conrad Weisert
Our textbook Our own Andrew Harrington and George Thiruvathukal have prepared Introduction to Computer Science in C# You'll find it on web. (no charge) It's unfinished, but it's clear and it provides much of what we'll need. Suggestions for additions and modifications are welcomed. COMP 170 fall 2013 21-24 copyright 2013 Conrad Weisert