...many ugly C idioms with simpler and more advanced C++...

Всичко за програмирането на игри - архитектура, графика, звук, изкуствен интелект, мрежи.
pdimov
gosu
gosu
Мнения: 871
Регистриран: 02 дек 2003 01:04

...many ugly C idioms with simpler and more advanced C++...

Мнение от pdimov » 11 юни 2014 21:52

(Score: -1, Flamebait)

http://blogs.msdn.com/b/vcblog/archive/ ... oring.aspx
So, as part of this great refactoring of the CRT, we have done an enormous amount of work to simplify and improve the quality of the code, so that it is easier to add features and fix bugs in the future. We have converted most of the CRT sources to compile as C++, enabling us to replace many ugly C idioms with simpler and more advanced C++ constructs. The publicly callable functions are still declared as C functions, of course (extern "C" in C++), so they can still be called from C. But internally we now take full advantage of the C++ language and its many useful features.

We have eliminated most of the manual resource management in the code through the introduction of several special-purpose smart pointer and handle types. Enormous functions have been split into smaller, maintainable pieces. We have eliminated 75%(2) of the conditional compilation preprocessor directives (#ifdef, #else, etc.) by converting internal implementation details to use C++ features like templates and overloading. We have converted most of the CRT source files to use a common coding style.

BIGBUGEX
Regular User
Regular User
Мнения: 77
Регистриран: 29 мар 2004 00:42
Местоположение: Nqkyde

Re: ...many ugly C idioms with simpler and more advanced C++

Мнение от BIGBUGEX » 11 юни 2014 23:37

Нормално. Щели да пренаписват и системните драйвери на .нет. Такава им е политиката. Ако изчакат още 1-2 години няма да им остане човек дето да разбере грозните "С" идиоми. Ще гледат сорсовете като асм дебъгера на вс6.

SuryIIID
Power User
Power User
Мнения: 431
Регистриран: 01 яну 2004 21:03
Местоположение: София
Контакти:

Re: ...many ugly C idioms with simpler and more advanced C++

Мнение от SuryIIID » 12 юни 2014 08:06

The "best" example of this maintainability problem could be found in the old implementation of the printf family of functions. The CRT provides 142 different variations of printf, but most of the behavior is the same for all of the functions, so there are a set of common implementation functions that do the bulk of the work. These common implementation functions were all defined in output.c in the CRT sources(1). This 2,696 line file had 223 conditionally compiled regions of code (#ifdef, #else, etc.), over half of which were in a single 1,400 line function. This file was compiled 12 different ways to generate all of the common implementation functions. Even with the large number of tests that we have for these functions, the code was exceedingly brittle and difficult to modify.
.....
.....
Before this refactoring, the sprintf functions, which write formatted data to a character buffer, were implemented by wrapping the result buffer in a temporary FILE object and then deferring to the equivalent fprintf function. This worked and produced the correct result, but it was exceedingly inefficient. When writing characters to a FILE we need to be careful to handle many cases like buffer exhaustion, end-of-line conversions, and character conversions. When writing characters to a string, we should simply be able to write through and increment the result pointer. After the refactoring, we were easily able to identify this performance problem and, more importantly, fix it. The sprintf functions are now up to 8 times faster than they were in previous releases.
Айде, айде...Толкова годинки плувахме щастливи и доволни, сега - "имало лайна във водата". :mrgreen: То и на остров Убунту водата не е кристална, ама

SuryIIID
Power User
Power User
Мнения: 431
Регистриран: 01 яну 2004 21:03
Местоположение: София
Контакти:

Re: ...many ugly C idioms with simpler and more advanced C++

Мнение от SuryIIID » 12 юни 2014 10:01

Symply ?

Потребителски аватар
stoiko
Power User
Power User
Мнения: 617
Регистриран: 04 дек 2003 15:44
Контакти:

Re: ...many ugly C idioms with simpler and more advanced C++

Мнение от stoiko » 12 юни 2014 10:06

SuryIIID написа:Symply ?
meme fail
Изображение

gemicha
Site Admin
Site Admin
Мнения: 2930
Регистриран: 20 ное 2003 22:20
Местоположение: USA

Re: ...many ugly C idioms with simpler and more advanced C++

Мнение от gemicha » 13 юни 2014 07:00

Работят хората... всяка версия е по-добра от предходната.

Stilgar
Power User
Power User
Мнения: 824
Регистриран: 12 яну 2006 22:15
Контакти:

Re: ...many ugly C idioms with simpler and more advanced C++

Мнение от Stilgar » 13 юни 2014 10:56

Един голям лаф от съседния форум:
М$ по нещо ми приличат на БСП! Седнали са на стол с тясна дупка, пъхнали са си топките една по една в дупката и сега стават рязко, ама много рязко! Ние ще гледаме сеира.
http://forums.bgdev.org/index.php?showt ... t&p=338311

Отговори