2 minute read

Categories:

Tags:

Overview

  1. C++์˜ ํƒ„์ƒ
  2. โ€œThe design and evolution of C++โ€
  3. Will C++20 deliver on the dreams of D&E?
  4. The future

C++์˜ ํƒ„์ƒ

c++๋Š” 1979๋…„ bell ์—ฐ๊ตฌ์†Œ์—์„œ ์‹œ์ž‘๋˜์—ˆ๋‹ค

bell lab

Itโ€™s not enough to have an idea. You have to work hard to make them work

The earlist aims - Day@1

  • ๋ถ„์‚ฐ์‹œ์Šคํƒฌ์„ ์—ฐ๊ตฌํ•˜๋ฉด์„œ ํ•˜๋“œ์›จ์–ด๋ฅผ ํšจ์œจ์ ์œผ๋กœ ํ™œ์šฉํ•˜๊ณ , ๋ณต์žก์„ฑ(class ์™€ strong static type checking์„ ํ†ตํ•œ)์„ ๊ด€๋ฆฌํ•  ํ•„์š”๊ฐ€ ์ƒ๊ฒจ๋‚ฌ๋‹ค. ๊ธฐ์กด์— C์–ธ์–ด๊ฐ€ ์กด์žฌํ•˜์˜€์œผ๋‚˜, ์ด ๋‘ ๋ฌธ์ œ๋ฅผ ๋™์‹œ์— ํ•ด๊ฒฐํ•  ์ˆ˜ ์—†์—ˆ๋‹ค.

์ฒ˜์Œ์—” ์™„๋ฒฝํ•œ ์–ธ์–ด๋ฅผ ๋งŒ๋“œ๋ คํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ๊ฐœ๋ฐœ์ž๋Š” C์— class ๊ฐœ๋…์„ ์ถ”๊ฐ€ํ•˜๊ณ  ์‹ถ์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ํ”„๋กœ์ œํŠธ๋ฅผ ์‹œ์ž‘ํ•˜์˜€๊ณ , C++์„ ์ง„ํ™”ํ•˜๊ธฐ์œ„์— ๋””์ž์ธ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

argument checking -1980

  • C in 1979 aka โ€œClassic Cโ€ ```C double sqrt(); dobule x = sqrt(2);

char * strchr(str, ch) char *str; { โ€ฆ } strlen(str) char *str; { โ€ฆ }

int y = foo(โ€œhopeโ€); /* might link, might crash */

- C with classes in 1980 (C and C++ today)
``` c++

double sqrt(double); //argument type required
double x = sqrt(2);

char* strchr(char* str, int ch) {...} // int not optional 
int strlen(char* str) { ... }

int foo(char*)    //declaration required
int y = foo("hope");

static cheching was first steps towards it

Argument type checking - 1983

๊ธฐ์กด c ์ฝ”๋“œ์™€ ํ˜ธํ™˜๋˜์ง€ ์•Š๋Š” c++ ์ฝ”๋“œ๋“ค์€ ๋งŽ์€ ์‚ฌ๋žŒ๋“ค์— ๋น„ํŒ์„ ์ƒ€์Šต๋‹ˆ๋‹ค. ํ•˜๋ฃจ์— 10000์ค„์˜ ์ฝ”๋“œ๊ฐ€ c์—์„œ c++๋กœ convert๋˜์—ˆ๊ณ  type checking, overloading, adding user-defined types, consistent linking์€ ๋ชจ๋‘ c++์˜ ์ค‘์š”ํ•œ ๋ถ€๋ถ„์ด๋ฉฐ ํ•˜๋‚˜์˜ ๋ถ€๋ถ„์ด๋ผ๋„ ์—†๋‹ค๋ฉด c++์„ ์‹œ์ž‘ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

ํ˜„์ œ์—๋„ ์กด์žฌํ•˜๋Š” c++๋ฌธ์ œ๋“ค

  1. implicit narrowing conversions - char x = 7.9 //truncation //โ€Donโ€™t break the code - char y= 567; //probability truncation // Offer alternatives to โ€œproblem featursโ€ - To compensate, use {} initialization: char x{7.9}; //error:narrowing conversion wonโ€™t compile.

  2. Linkage - global function is by default external - To compensate, use module

  3. Some C/C++ incompatibilites came from C rather then C++ - Scope of consts - Implicit pointer conversion from void* to T* (never C++)

## Key idea: โ€œRepresent concepts in codeโ€

C++ ์„ ์ž˜ ์ž‘์„ฑํ•˜๊ธฐ ์œ„ํ•ด์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ๊ฒƒ์€ ์ปจ์…‰๋“ค์€ ์ฝ”๋“œ์•ˆ์— ๋ณด์—ฌ์ฃผ๋Š”๊ฒƒ ์ž…๋‹ˆ๋‹ค(์ฃผ๋กœ ํด๋ž˜์Šค๋ฅผ ์‚ฌ์šฉํ•ด์„œ).

  1. Direct Representation of ideas in code.
  2. Make code mroe declarative
  3. Make more information available to compilers Early example: Vector, String, file handle, concurrent task, message queue, hash table, grpahical shape, complex number, infinite integer

## RAII - 1979 In 1979: new function creates the run-time environment for member functions, A deleteโ€function is reverse that

Later(1983): โ€œnew functionโ€ -> constructor โ€œdelete functionโ€ -> destructor This is because new and elete were not just for new and delete functions

A Slightly later formulation(1980s) A Constructor establishes a class invariant(if any) for an object A destructor releases all resources owned by the object

1988: โ€œResourece Acquisition is initialization

1981: Needed Control assignment - User defined operation=

- A recurring problem: avoid expensive copying
  - always possible but tricky for users
  - return value optimization from 1982

2011: - Need to control movement of object between scopes - move operation - โ€œMove semanticโ€ completes the object model

2020: Improved an guaranteed copy elision

Leave a comment