+ All Categories
Home > Documents > W2- Introucing C

W2- Introucing C

Date post: 20-Mar-2022
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
27
Introducing C Program Design (I) 2021 Fall Fu-Yin Cherng Dept. CSIE, National Chung Cheng University
Transcript

Introducing CProgram Design (I)

2021 Fall Fu-Yin Cherng

Dept. CSIE, National Chung Cheng University

Please finish the programming literacy test before next week & check announcements frequently

2

Outline

● History of C● Why Learning C?● Philosophy of C● Strengths and weaknesses of C● Effective Use of C

3

Like we need to know a super hero’s original stories to fully understand why the super hero becomes what h/she is, understanding the origins of C can help us understand why C is designed in certain ways and how to use it.

4

C was born around 1972...

5

C is a by-product of the UNIX operating system

6

Ken Thompson Dennis Ritchie

● Thompson used assembly language to write UNIX

● assembly langugage is hard to debug and enhance

UNIX

C is a by-product of the UNIX operating system

7

Ken Thompson Dennis Ritchie

● So Thompson designed B● Then, Ritchie joined the UNIX project● Ritchie developed an extended version of B, called NB (“New B”)● As development continued, Ritchie renamed it to C● Then, UNIX could be rewritten in C

Higher-level Language!!😭

Hi here is C 😎

C was designed for UNIX

UNIX

Standardization of C

8

Unified several variations by the American National Standard Institute and the International Organization for Standardiztion (C89/C90)

More significant changes in the new standard

2008

Less significant changeshttps://en.wikipedia.org/wiki/C11_(C_standard_revision)https://en.wikipedia.org/wiki/C17_(C_standard_revision)

Why Learning C?

Huge influence on modern programming languages, many of which borrow heavily from C.

9

C-based programming languages (Wiki)

10

11

https://www.guru99.com/c-programming-language.html

IEEE - the best 10 top programming language in 2018

Still popular!

Uses of C programming

12https://www.indeed.com/career-advice/career-development/c-programming

Why Learning C?

● As the popularity of these newer languages increases, logical to learn C● C gives you greater insights into the basic features of these languages● Many C programs exist; may need to read and maintain them in the future

● Learning C can help you learn other languages easier and deeper.● C is simple and low-level enough to learn lots of basic features and concpets

hidden by many modern languages

13

Philosophy of C

After knowing the origins and why C was designed for, you will understand the philosophy of C

● C is a low-level language● C is a small langugae● C is a permissive langugage

14

Philosophy of C - C is a low-level language

● Was designed for UNIX (operating system)● So provide access to machine-level concepts that other languages try to hide● C programs can be fast, because C provides operations closely

corresponding to a computer’s built-in instructions.

15

Philosophy of C - C is a small langugae

● Limited set of features compared to many other languages ● Relies heavily on a library of standard functions (e.g., <stdio.h> & <stdlib.h>)

16

Philosophy of C - C is a permissive langugage

● C assumes that you know what you’re doing● doesn’t provide the detailed error-checking found in other languages

17

18

Strengths Weaknesses

Following the philosophy of C, there are some strengths and weakenesses...

Strengths - Efficiency

19Pereira, Rui, et al. "Ranking programming languages by energy efficiency." Science of Computer Programming 205 (2021): 102609.

C-based

● C was intended for applications where assembly language had been used● So it’s important that C can run as fast as the assembly language in limited

amounts of memory

Strengths - Flexibility

● Although C is designed for systems operating, there are no restrictions that limit to this application

● Moreover, C has very few restrictions on use of C’s features● For example, allow: 1 + A (= ?)● This flexibility can make programming easier, but it may also allow some bugs

and errors, which lead to its weakness

20

Weakness - Can be error-prone

● Because of the high flexibility, programmers often make errors easily when programming in C

● Many compilers of other languages can catch programming mistakes, but most errors of C aren’t detected until the program is run

● For example, an extra semicolon (;) can cause an infinite loop or a missing symbol can cause a program crash

21

Weakness - Can be hard to read

● Lack of the features such as classes and packages that support the division of a large program

● Programmers without maintenance in mind (not limited to C)● The International Obfuscated C Code Contest (https://www.ioccc.org/)

○ Burton - the best one-liner of 2020

22

int main(int b,char**i){long long n=B,a=I^n,r=(a/b&a)>>4,y=atoi(*++i),_=(((a^n/b)*(y>>T)|y>>S)&r)|(a^r);printf("%.8s\n",(char*)&_);}

Effective Use of C

● Although C has all these strengths and weaknesses, we can still use C effectively by○ Learning how to avoid C pitfalls○ Use software tools to make programs more reliable ○ Adopt a sensible set of coding conventions (good coding style)

● Let’s learn these things through each topic of this course!

23

Introducing VS code and Github (classroom)

Program Design (I)2021 Fall

Fu-Yin CherngDept. CSIE, National Chung Cheng University

25

https://www.youtube.com/watch?v=S320N3sxinE&feature=emb_title

Other Resources

● https://www.youtube.com/watch?v=V3o57MU5eoE&t=767s● https://hackmd.io/@liaojason2/vscodecppwindows● https://www.youtube.com/watch?v=77v-Poud_io● https://code.visualstudio.com/docs/cpp/config-mingw● https://www.javatpoint.com/how-to-run-a-c-program-in-visual-studio-code● During the quiz section, TAs will help you install and set up the VS code step

by step

26

Introduction to Github and Github Classroom

27


Recommended