- عنوان کتاب: Modern C, Third Edition Covers the C23 standard
- نویسنده: Jens Gustedt
- حوزه: برنامهنویسی C
- سال انتشار: 2025
- تعداد صفحه: 815
- زبان اصلی: انگلیسی
- نوع فایل: pdf
- حجم فایل: 7.34 مگابایت
همانطور که عنوان این کتاب نشان میدهد، زبان C امروزی همان زبانی نیست که در ابتدا توسط خالق آن طراحی شده بود. از همان ابتدا، زبان C در یک فرآیند مداوم تنظیم و بهبود بوده است. معمولاً به زبان C اولیه، K&R C (کرنیگان و ریچی C) گفته میشود که برگرفته از اولین کتابی است که این زبان را محبوب کرد. از آن زمان، این زبان یک فرآیند استانداردسازی و توسعه مهم را پشت سر گذاشته است که اکنون توسط ISO، سازمان بینالمللی استانداردها، هدایت میشود. این امر منجر به انتشار مجموعهای از استانداردهای C در سالهای ۱۹۸۹، ۱۹۹۹، ۲۰۱۱، ۲۰۱۸ و ۲۰۲۴ شد که معمولاً به ترتیب با نامهای C89، C99، C11، C17 و C23 شناخته میشوند. کمیته استانداردهای C تلاش زیادی میکند تا سازگاری با نسخههای قبلی را تضمین کند، به طوری که کد نوشته شده برای نسخههای قبلی زبان، مثلاً C11، باید با کامپایلری که نسخه جدیدتر را پیادهسازی میکند، به یک فایل اجرایی معادل از نظر معنایی کامپایل شود. متأسفانه، این سازگاری با نسخههای قبلی، اثر جانبی ناخواستهای داشته است و آن این است که پروژههایی را که میتوانند از ویژگیهای جدید به میزان زیادی برای بهروزرسانی پایگاه کد خود بهرهمند شوند، ترغیب نمیکند. برای تأکید بر این پیشرفت در ویرایشها، مشخص میکنیم که کدام ویرایش استاندارد، ویژگیهای جدیدتری را معرفی کرده است. این ویرایش، با توجه به آخرین ویرایش، یعنی C23 استاندارد C، یک بازنگری قابل توجه ارائه میدهد. مطالب جدید زیادی اضافه شده است و بسیاری از توضیحات اصلاح شدهاند تا قابلیتهای جدید زبان برنامهنویسی C را منعکس کنند. بنابراین، در این کتاب، ما عمدتاً به C23 اشاره میکنیم، اما در زمان نگارش این متن، کامپایلرها هنوز این استاندارد را به طور کامل پیادهسازی نکرده بودند. اگر میخواهید مثالهای این کتاب را کامپایل کنید، حداقل به کامپایلری نیاز خواهید داشت که بیشتر C17 را پیادهسازی کند. برای نوآوریهایی که C23 معرفی میکند، ما یک سربرگ سازگاری ارائه میدهیم و در مورد چگونگی تولید احتمالی یک کامپایلر C مناسب و پلتفرم کتابخانه C در سیستمهای POSIX به عنوان یک جایگزین در پیوست B بحث میکنیم. توجه: این به عنوان یک ابزار دائمی در نظر گرفته نشده است، بلکه فقط به عنوان یک تکیهگاه در حین تطبیق پلتفرمها در نظر گرفته شده است. برنامهنویسی به یک فعالیت فرهنگی و اقتصادی بسیار مهم تبدیل شده است و زبان C همچنان عنصر مهمی در دنیای برنامهنویسی است. مانند تمام فعالیتهای انسانی، پیشرفت در زبان C نیز تحت تأثیر عوامل زیادی است: منافع شرکتی یا فردی، سیاست، زیبایی، منطق، شانس، جهل، خودخواهی، خودخواهی، فرقهگرایی و غیره (انگیزه اصلی خود را اینجا اضافه کنید). بنابراین، توسعه زبان C ایدهآل نبوده و نمیتواند باشد. این زبان دارای نقصها و مصنوعاتی است که فقط در چارچوب تاریخی و اجتماعی خود قابل درک هستند. بخش مهمی از زمینهای که C در آن توسعه یافت، ظهور اولیه زبان خواهرش، C++، بود. یک تصور غلط رایج این است که C++ با اضافه کردن ویژگیهای خاص خود از C تکامل یافته است. اگرچه این زمینه از نظر تاریخی صحیح است (C++ از یک C بسیار اولیه تکامل یافته است)، اما امروزه اهمیت خاصی ندارد. در واقع، C و C++ بیش از 30 سال پیش از یک جد مشترک جدا شدند و از آن زمان تاکنون به طور جداگانه تکامل یافتهاند. اما این تکامل این دو زبان به صورت جداگانه صورت نگرفته است. آنها در طول سالها مفاهیم یکدیگر را رد و بدل کرده و پذیرفتهاند. برخی از ویژگیهای جدید، مانند اضافه شدن اتمها و رشتهها، با همکاری نزدیک بین کمیتههای استاندارد C و C++ طراحی شدهاند. با این وجود، تفاوتهای زیادی باقی مانده است و به طور کلی، تمام آنچه در این کتاب نوشته شده است در مورد C است، نه C++. بسیاری از نمونههای کد با کامپایلر C++ کامپایل نمیشوند. بنابراین، نباید منابع هر دو زبان را با هم مخلوط کنیم. در مجموع، C و C++ متفاوت هستند: آنها را با هم مخلوط نکنید و با هم قاطی نکنید.
As the title of this book suggests, today’s C is not the same language as the one originally designed by its creator. Right from the start, C has been in a continuous process of adjustment and improvement. Usually, early C is referred to as K&R C (Kernighan and Ritchie C) after the first book that made the language popular. Since then, it has undergone an important standardization and extension process, now driven by ISO, the International Standards Organization. This led to the publication of a series of C standards in 1989, 1999, 2011, 2018, and 2024, commonly referred to as C89, C99, C11, C17, and C23, respectively. The C standards committee puts a lot of effort into guaranteeing backward compatibility such that code written for earlier revisions of the language, say, C11, should compile to a semantically equivalent executable with a compiler that implements a newer revision. Unfortunately, this backward compatibility has had the unwanted side effect of not motivating projects that could benefit greatly from the new features to update their code base. To emphasize this progress of revisions, we indicate which standard revision introduced newer features. This edition presents a considerable rework in view of the latest revision, C23 of the C standard. A lot of new material has been added, and many expositions have been straightened out to reflect the new capabilities of the C programming language. So, in this book, we mainly refer to C23, but at the time of this writing, compilers hadn’t yet implemented this standard completely. If you want to compile the examples in this book, you will need at least a compiler that implements most of C17. For the novelties that C23 introduces, we provide a compatibility header and discuss how to possibly generate a suitable C compiler and C library platform on POSIX systems as a fallback in appendix B. Beware: This is not meant as a permanent tool but only as a crutch while platforms adapt. Programming has become a very important cultural and economic activity, and C remains an important element in the programming world. As in all human activities, progress in C is driven by many factors: corporate or individual interest, politics, beauty, logic, luck, ignorance, selfishness, ego, sectarianism, etc. (add your primary motivation here). Thus, the development of C has not been and cannot be ideal. It has flaws and artifacts that can only be understood within their historical and societal context. An important part of the context in which C developed was the early appearance of its sister language, C++. One common misconception is that C++ evolved from C by adding its particular features. Although this context is historically correct (C++ did evolve from a very early C), it is not particularly relevant today. In fact, C and C++ separated from a common ancestor more than 30 years ago and have evolved separately ever since. But this evolution of the two languages has not taken place in isolation; they have exchanged and adopted each other’s concepts over the years. Some new features, such as the addition of atomics and threads, have been designed in close collaboration between the C and C++ standard committees. Nevertheless, many differences remain, and generally, all that is written in this book is about C, not C++. Many of the code examples will not compile with a C++ compiler. So, we should not mix sources of both languages. In sum, C and C++ are different: don’t mix them and don’t mix them up.
نظرات کاربران