1 The C Language An International Standard CIS2450 Professional Aspect of Software Engineering.

Slides:



Advertisements
Similar presentations
C language was developed in early 1970s by Dennis Ritchie at Bell Laboratories to implement the UNIX operating system on the PDP-11 manufactured by DEC.
Advertisements

Chapter 8 Technicalities: Functions, etc. Bjarne Stroustrup
Chapter 7 Constructors and Other Tools. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 7-2 Learning Objectives Constructors Definitions.
CSE 105 Structured Programming Language (C)
Introduction to C Programming
A C++ Crash Course Part II UW Association for Computing Machinery Questions & Feedback.
11-Jun-14 The assert statement. 2 About the assert statement The purpose of the assert statement is to give you a way to catch program errors early The.
Cs205: engineering software university of virginia fall 2006 Specifying Procedures David Evans
1.A computer game is an example of A.system software; B.a compiler; C.application software; D.hardware; E.none of the above. 2.JVM stands for: A.Java Virtual.
Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
You can do more than what you think ……… If you believe you can.
C Language.
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
CS 1 Introduction CS 1 Part 11. Hardware 1.Central Processing Unit (CPU) 2.Main Memory 3.Secondary Memory / Storage 4.Input Devices 5.Output Devices CS.
Introduction to Programming G51PRG University of Nottingham Revision 1
User Defined Functions Lesson 1 CS1313 Fall User Defined Functions 1 Outline 1.User Defined Functions 1 Outline 2.Standard Library Not Enough #1.
Today’s lecture Review of Chapter 1 Go over homework exercises for chapter 1.
 Both System.out and System.err are streams—a sequence of bytes.  System.out (the standard output stream) displays output  System.err (the standard.
Introduction to C Programming
Introduction to Computing Lecture 01: Introduction to C Introduction to Computing Lecture 01: Introduction to C Assist.Prof.Dr. Nükhet ÖZBEK Ege University.
Inline Assembly Section 1: Recitation 7. In the early days of computing, most programs were written in assembly code. –Unmanageable because No type checking,
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Classes and Objects Systems Programming.
CS1061 C Programming Lecture 2: A Few Simple Programs A. O’Riordan, 2004.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Introduction to Classes and Objects CS-2303, C-Term Introduction to Classes and Objects CS-2303 System Programming Concepts (Slides include materials.
VB .NET Programming Fundamentals
Chapter 11: Testing The dynamic verification of the behavior of a program on a finite set of test cases, suitable selected from the usually infinite execution.
Examining the Code [Reading assignment: Chapter 6, pp ]
C++ Functions. 2 Agenda What is a function? What is a function? Types of C++ functions: Types of C++ functions: Standard functions Standard functions.
“C” Programming Language CIS 218. Description C is a procedural languages designed to provide lowlevel access to computer system resources, provide language.
Week 3 Part I Kyle Dewey. Overview Odds & Ends Constants Errors Functions Expressions versus statements.
Windows Programming Lecture 05. Preprocessor Preprocessor Directives Preprocessor directives are instructions for compiler.
Functions Part I (Syntax). What is a function? A function is a set of statements which is split off into a separate entity that can be used like a “new.
Chapter 9 Defining New Types. Objectives Explore the use of member functions when creating a struct. Introduce some of the concepts behind object-oriented.
C for Java Programmers Tomasz Müldner Copyright:  Addison-Wesley Publishing Company, 2000 Introduction to C Muldner, Chapters 1, 2.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
C Programming language Basic Concepts Prepared By The Smartpath Information systems
Fundamentals of C and C++ Programming. EEL 3801 – Lotzi Bölöni Sub-Topics  Basic Program Structure  Variables - Types and Declarations  Basic Program.
CPS120: Introduction to Computer Science Functions.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
Computer Engineering Rabie A. Ramadan Lecture 5.
Topic 3: C Basics CSE 30: Computer Organization and Systems Programming Winter 2011 Prof. Ryan Kastner Dept. of Computer Science and Engineering University.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
C++ for Java Programmers Chapter 2. Fundamental Daty Types Timothy Budd.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
MAHENDRAN. Session Objectives Session Objectives  Discuss the Origin of C  Features of C  Characteristics of C  Current Uses of C  “C” Programming.
BASIC C PROGRAMMING LANGUAGE TUTORIAL infobizzs.com.
Chapter 1 slides1 What is C? A high-level language that is extremely useful for engineering computations. A computer language that has endured for almost.
Defining Data Types in C++ Part 2: classes. Quick review of OOP Object: combination of: –data structures (describe object attributes) –functions (describe.
13 C Preprocessor.
Secure Coding Rules for C++ Copyright © 2016 Curt Hill
The Machine Model Memory
C# Operator Overloading and Type Conversions
History of ‘C’ Root of the morden language is ALGOL It’s first
Overview of C.
C Basics.
Introduction to C Programming Language
' C ' PROGRAMMING SRM-MCA.
Secure Coding Rules for C++ Copyright © Curt Hill
Arithmetic Expressions
Chapter 4: Control Structures I (Selection)
Introduction to Classes and Objects
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
2. Second Step for Learning C++ Programming • Data Type • Char • Float
C – Programming Language
C Language B. DHIVYA 17PCA140 II MCA.
Classes and Objects Systems Programming.
Presentation transcript:

1 The C Language An International Standard CIS2450 Professional Aspect of Software Engineering

2 ANSI C The C language appeared in the early 1970s and was originally cryptic, small, and tolerant. For the next ten years C evolved in the UNIX environment. The resultant language was first described in the paper “Portability of C Programs and the UNIX System,” by S.C. Johnson and Dennis Ritchie in This style of C was commonly called UNIX C.

3 ANSI C In 1989 the American National Standards Institute (ANSI) standardized C as standard X In December of that year the International Standards Organization ISO adopted the ANSI C standard making minor changes. In 1990 ANSI then re-adopted ISO standard C. This version of C is known as either ANSI C or Standard C.

4 Implementation Characteristics The ANSI standard defines several terms which describe the characteristics of an implementation. They are useful to describe what is and is not acceptable in the language. Implementation defined code means that the compiler writer chooses what happens and has to document it. –Example: whether the sign bit is propagated when shifting a bit right.

5 Implementation Characteristics Unspecified behavior for something correct which the standard does not impose any requirements. –Example: the order of argument evaluation. Undefined behavior is something incorrect which the standard does not impose any requirements. Anything may happen, from nothing, to a warning message, to program termination. –Example: what happens when a signed integer overflows.

6 Implementation Characteristics A constraint is a restriction or requirement which must be obeyed. If you do not then your program will become undefined. –Example: the operands of the % operator must be of integral type or a diagnostic will result. An interesting problem with the definition of constraints is that compilers only have to produce an error message if a program violates both syntax and constraints.

7 Implementation Characteristics Semantic rules which are not explicitly stated can be broken and because this behavior is undefined the compiler does not have to issue a warning. –Example: the C standard header files have a function called malloc, but redefining this function is not a constraint so the compiler does not have to warn if this happens.

8 Implementation Characteristics Strictly conforming code is one which: –uses only specified features –doesn't exceed any implementation-defined limit –has no output that depends on implementation defined, unspecified, or undefined features This is not a very interesting class because there are so few programs which meet the criteria.

9 Implementation Characteristics Conforming programs can depend on non- portable features. A conforming program is considered with respect to a specific implementation and may be non-conforming using a different compiler. It can have extensions, but not ones which alter the behavior of a strictly conforming program.

10 ANSI Changes to (older) C A variety of minimum sizes were defined by the standard including: –31 parameters in a function definition –31 arguments in a function call –509 characters in a source line –32 levels of nested parentheses in an expression –long ints are at least 32 bits

11 Differences between ANSI and K&R Prototype change –parameters must be written in the function declaration, not just the definition. Keyword changes –several new keywords were added including enum, const, volatile, signed, and void.

12 Differences between ANSI and K&R Quiet changes –which are mostly minor changes which cause code to still compile but perhaps operate in a different manner. Everything else –these changes will have almost no effect and will almost never be encountered in practice, e.g. trigraphs can be used to represent a single character by using three characters, so ??< represents {

13 New Features of C99 Coding –end-of-line (//) comments like C++ –Mix declarations and code –Remove implicit function declaration Data types –long long int (minimum 64bit Integer) –Variable length arrays –Flexible array members of structures Library –snprintf family of functions in stdio.h

14 Why Do We Care about Older C? For new development, we don’t, but… Huge installed code base is “old” –Many jobs involve maintenance of legacy code –Avoid misunderstanding legacy code Based on your new-C habits –Avoid introducing bugs into legacy code Keep to legacy coding style for consistency Choices: retain older C compiler or try to upgrade to new compiler standard (exposes “code rot”)

15 What is “code rot”? Aka “software rot” “bit rot” When program hasn’t been changed, yet stops working/compiling –Earlier assumptions no longer valid (e.g., famous Y2K bug → 2 bytes no longer enough) –Compiler, libraries, or operating system “upgraded,” features discontinued or incompatible

16 Holding Code Rot at Bay Recognize assumptions that won’t stand test of time –“Users will never need more than records, so 16- bit index is fine!” (+1 looks <0) → Comair fiasco Write strictly-conforming software, not relying on extensions or “tricks” –E.g., intentionally accessing outside array bounds Recompile when language spec revised, system upgraded, etc. –May discover small problems, easily fixed –Or BIG problems needing major reexamination