Introduction to C CS 2022 Introduction to C Instructor Hussam Abu Libdeh Presented by Renato Paes Leme Cornell University Fall 2009 Lecture 1 Introduction to C CS 2022 Fall 2009 Lecture 1 Administrivia I I I I I I I Instructor Hussam Abu Libdeh 4139 Upson Email hussam cs cornell edu Lectures MWF 12 20 1 10p THR 205 Lab Upson B7 when announced Office Hours To Be Determined www cs cornell edu courses cs2022 CMS http cms csuglab cornell edu Introduction to C CS 2022 Fall 2009 Lecture 1 C is a language Introduction to C CS 2022 Fall 2009 Lecture 1 C is a language like English What are languages for Introduction to C CS 2022 Fall 2009 Lecture 1 C is a language like English What are languages for I I I I I I communicate ideas convince someone express feelings and beliefs vehicle for art state ideas Introduction to C CS 2022 Fall 2009 Lecture 1 Visual art Introduction to C CS 2022 Fall 2009 Lecture 1 Computer generated poetry Imagine now a tree in white sails still whirled About the leaves will be of silences Calm and angels Introduction to C CS 2022 Fall 2009 Lecture 1 Social Sciences Zachary s karate club Introduction to C CS 2022 Fall 2009 Lecture 1 Communicate mathematical ideas 1 2 3 4 Simulations e g Monty Hall Problem Solve large systems of equations Automatic provers Introduction to C CS 2022 Fall 2009 Lecture 1 Design useful tools Introduction to C CS 2022 Fall 2009 Lecture 1 How to learn a foreign language 1 2 3 4 5 be able to express yourself have someone to correct your grammar develop some style communicate efficiently say original and interesting things Introduction to C CS 2022 Fall 2009 Lecture 1 How to learn a programming language 1 2 3 4 5 express what you want in C let the compiler correct you know good coding practices optimize your code write beautiful code Introduction to C CS 2022 Fall 2009 Lecture 1 Pre requisites I I Basic programming knowledge variables functions loops Lots of composure I I I I I Your programs won t compile Your programs won t run Your programs will crash You ll have no idea what happened but at least it ll happen fast Introduction to C CS 2022 Fall 2009 Lecture 1 Programming Languages Genealogy Introduction to C CS 2022 Fall 2009 Lecture 1 Programming Languages Genealogy Introduction to C CS 2022 Fall 2009 Lecture 1 History of C I Writing code in an assembler gets real old real fast I I I BCPL by Martin Richards Grandparent of C I I I Really low level no loops functions if then else Not portable different for each architecture Close to the machine Procedures Expressions Statements Pointers B by Ken Thompson Parent of C I I Simplified BCPL Some types int char Introduction to C CS 2022 Fall 2009 Lecture 1 History of C I C by Kernighan and Ritchie I I I I I Much faster than B Arrays Structures more types Standardization Portability enhanced Parent of Objective C Concurrent C C C Introduction to C CS 2022 Fall 2009 Lecture 1 When to use C I Working close to hardware I I I Need to violate type safety I I I Operating System Device Drivers Pack and unpack bytes Inline assembly Cannot tolerate overheads I I I I No No No No garbage collector array bounds check memory initialization exceptions Introduction to C CS 2022 Fall 2009 Lecture 1 When not to use C Use JAVA or C for I Quick prototype I Compile once Run Everywhere I Reliability is critical and performance is secondary I I C can be very reliable but requires tremendous programmer discipline For many programs JAVA can match C performance but not always Introduction to C CS 2022 Fall 2009 Lecture 1 How to be good programmer Introduction to C CS 2022 Fall 2009 Lecture 1 How to be good programmer I Practice practice practice Introduction to C CS 2022 Fall 2009 Lecture 1 How to be good programmer I I Practice practice practice Code for fun Introduction to C CS 2022 Fall 2009 Lecture 1 How to be good programmer I I I Practice practice practice Code for fun Don t wait Google for it Introduction to C CS 2022 Fall 2009 Lecture 1 How to be good programmer I I I I Practice practice practice Code for fun Don t wait Google for it Coding competitions 1 USACO train usaco org 2 Topcoder www topcoder com tc 3 UVA uva onlinejudge org Introduction to C CS 2022 Fall 2009 Lecture 1 Questions Introduction to C CS 2022 Fall 2009 Lecture 1
View Full Document
Unlocking...