📜 ⬆️ ⬇️

Wake up, in the courtyard of the XXI century



I would like to start the article with the statement of the fact that right outside the window is 2011 ( pruflink ), mid-April. I remind myself first of all of this, since doubts occasionally visit me. The fact is that both for work and for the sake of a hobby, I often read C ++ code written 10-20 years ago (but still maintained) or code written recently, but by people who learned to program C ++ same 20 years ago. And after that, I have the feeling that there has been no progress over the years, nothing has changed or developed, and mammoths still roam the Earth.


Introduction


From KVN:
-And where are you in Sochi, grandmother, can I rent a room for $ 25 a day?
-And so close here, guys. In the 90th year.
')
The specifics of programming 20 years ago was completely different. The account of the memory and processor resources went to bytes and cycles, many things have not yet been invented and had to get out. But this is not a reason to write code today on the basis of these prerequisites. The world is changing. I feel it in the water. I feel it in the ground. Here, already in the air this smell ... We need to keep up.

Everything that I will write further concerns only C ++ programming and only mainstream compilers (gcc, Intel, Microsoft) - I have worked less with other languages ​​and compilers, and I cannot talk about the state of things in them. Also, I will only talk about application programming for desktop OSes (in clusters, microprocessors and system programming, trends may differ).

TR1


For those who have been in the tank for the last five years, I will tell you a great military secret (Toko tsss!). There is such a thing as TR1 . This may be a revelation, but almost all modern compilers have built-in smart pointers, good random number generators, a lot of special mathematical functions, support for regular expressions, and other interesting things. It works quite well. Use.

C ++ 0x


For those who joined the heavy armored vehicle in a mug just a couple of years ago, I will tell you another good news. There is such a thing as C ++ 0x . Rejoice, brothers! Yes, officially there are not several high signatures on it yet and the ceremony of breaking a bottle of champagne on the side of the standard has not yet taken place, but the release candidate has been approved and compiler support is already there.

Already at your service:

and a bunch of other useful things.
Well, look at least at the following examples:


, ? , , ( \) . . ?

()


— . , . :

. ( ), :

: , + ( ). . , \DVD : «, — ». , ? - , .


:
#define PI 	3.1415926535897932384626433832795
#define PI_DIV_BY_2 	1.5707963267948966192313216916398
#define PI_DIV_BY_4 	0.78539816339744830961566084581988
...
<  180   >
...


- , , . «PI/2» , , , 180 . .


- :

class MySuperVector 
{ //     
...
}


. STL, Boost ( ), . - 3- :

:

, .


:
int a = 10;
a <<= 1;


? , . , 2. , , . :
  1. , .
  2. , .

, ( ) : « ?». ?


, 1-2 .

2 4 . 64- . . , . , , , , , , .. — long, longlong - . byte, short int. - , . , «, ».


. .

Source: https://habr.com/ru/post/117193/


All Articles