Building Interpreters, Art, Emulators, and ML in Python
David Kopec

#Computer_Science
#Python
#ML
🐍 شما بلدید چطور پایتون بنویسید. حالا وقتشه در علوم کامپیوتری که باعث کارکردن اون میشه، استاد بشید.
🤔 اگر مدتیه که برنامهنویسی میکنید، شاید برای شما هم این سوال پیش اومده باشه که چه اصول عمیقتری پشت این کدها وجود داره.
❓ زبانهای برنامهنویسی چطور پیادهسازی میشن؟ یک مفسر (interpreter) واقعاً چه کاری انجام میده؟ ریزپردازنده (microprocessor) چطور دستورالعملها رو در سطح بنیادی اجرا میکنه؟ یک الگوریتم یادگیری ماشین چطور تصمیم میگیره؟
📖 کتاب «علوم کامپیوتر از پایه» برای برنامهنویسان باتجربهی پایتونه که میخوان این شکافهای دانشی رو پر کنن—نه با سخنرانیهای تئوری و انتزاعی، بلکه با پروژههایی که با دقت طراحی شدن تا مفاهیم اصلی علوم کامپیوتر رو زنده کنن.
💪 درک این بلوکهای سازندهی بنیادی، شما رو به یک برنامهنویس همهفنحریفتر و مؤثرتر تبدیل میکنه.
🎯 هر فصل یک پروژهی متمرکز و عملی ارائه میده که یک ایدهی بنیادی در علوم کامپیوتر رو به شما یاد میده:
⌨️ مفسرها (INTERPRETERS): با نوشتن یک مفسر برای زبان BASIC، مفاهیم نحو (syntax)، تجزیه (parsing) و ارزیابی (evaluation) رو درک کنید.
🎮 شبیهسازها (EMULATORS): با ساختن یک شبیهساز کنسول NES از صفر، معماری کامپیوتر رو یاد بگیرید.
🎨 گرافیک (GRAPHICS): از طریق پروژههای گرافیک کامپیوتری، دستکاری تصویر و هنر الگوریتمی رو کشف کنید.
🤖 یادگیری ماشین (MACHINE LEARNING): با پیادهسازی یک مدل ساده و خوانای KNN، از رمز و راز طبقهبندی (classification) پردهبرداری کنید.
🏗️ این پروژهها صرفاً برای ساختن ابزار نیستن—بلکه درسهای ساختاریافتهای هستن که از کد استفاده میکنن تا نشون بدن محاسبات کامپیوتری چطور کار میکنه.
🌍 هر فصل با ارائهی زمینههای کاربردی در دنیای واقعی، ایدههایی برای توسعهی پروژه و تمرینهایی برای عمیقتر کردن درک شما به پایان میرسه.
👨🏫 این کتاب که توسط دیوید کوپک (David Kopec)، استاد علوم کامپیوتر و نویسندهی سری محبوب «مسائل کلاسیک علوم کامپیوتر» نوشته شده، یک کتاب برای مبتدیان نیست و یک متن آکادمیک سنگین و پر از تئوری هم به حساب نمیاد.
🚀 این کتاب یک مقدمهی عملی و کد-محور بر ایدهها و مکانیزمهای ضروری علوم کامپیوتره—که برای برنامهنویسهایی نوشته شده که چیزی فراتر از سینتکس و قواعد خشک میخوان.
🗺️ اگر پایتون مینویسید و آمادهاید تا پایههای محاسبات کامپیوتری رو کشف کنید، این کتاب شما رو با وضوح، عمق و هدفمندی به مقصد میرسونه.
بخش اول: مفسرها
فصل ۱: کوچکترین زبان برنامهنویسی ممکن
فصل ۲: نوشتن یک مفسر برای زبان بیسیک (BASIC)
بخش دوم: هنر محاسباتی
فصل ۳: پردازش تصویر به سبک رترو (Retro)
فصل ۴: یک الگوریتم نقاشی تصادفی (Stochastic)
بخش سوم: شبیهسازها
فصل ۵: ساخت یک ماشین مجازی Chip-8
فصل ۶: شبیهسازی کنسول بازی NES
بخش چهارم: یادگیری ماشین فوقالعاده ساده
فصل ۷: طبقهبندی (Classification) با K-نزدیکترین همسایه (KNN)
فصل ۸: رگرسیون (Regression) با K-نزدیکترین همسایه (KNN)
دیوید کوپک دانشیار علوم کامپیوتر در کالج آلبرایت (Albright College) است. او نویسندهی پنج کتاب برنامهنویسی، از جمله سری «مسائل کلاسیک علوم کامپیوتر» است و چندین سال به عنوان توسعهدهندهی iOS برای استارتاپها کار کرده است. دیوید علاوه بر تدریس، یک پادکستر مشتاق و توسعهدهندهی مستقل اپلیکیشن است که دارای مدرک کارشناسی ارشد علوم کامپیوتر از دارتموث (Dartmouth) و مدرک EMBA از کوانتیک (Quantic) است.
You know how to write Python. Now master the computer science that makes it work.
If you’ve been programming for a while, you may have found yourself wondering about the deeper principles behind the code. How are programming languages implemented? What does an interpreter really do? How does the microprocessor execute instructions at a fundamental level? How does a machine learning algorithm make decisions?
Computer Science from Scratch is for experienced Python programmers who want to fill in those gaps—not through abstract lectures, but through carefully designed projects that bring core CS concepts to life. Understanding these fundamental building blocks will make you a more versatile and effective programmer.
Each chapter presents a focused, hands-on project that teaches a fundamental idea in computer science:
These projects aren’t about building tools—they’re structured lessons that use code to reveal how computing works. Each chapter concludes with real-world context, thoughtful extensions, and exercises to deepen your understanding.
Authored by David Kopec, a computer science professor and author of the popular Classic Computer Science Problems series, this is not a beginner’s book, and it’s not a theory-heavy academic text. It’s a practical, code-driven introduction to the essential ideas and mechanisms of computer science—written for programmers who want more than syntax.
If you’ve been writing Python and are ready to explore the foundations behind computing, this book will guide you there—with clarity, depth, and purpose.
Table of Contents
Part I: Interpreters
Chapter 1: The Smallest Possible Programming Language
Chapter 2: Writing a Basic Interpreter
Part II: Computational Art
Chapter 3: Retro Image Processing
Chapter 4: A Stochastic Painting Algorithm
Part III: Emulators
Chapter 5: Building a Chip-8 Virtual Machine
Chapter 6: Emulating the NES Game Console
Part IV: Super-Simple Machine Learning
Chapter 7: Classification with K-Nearest Neighbors
Chapter 8: Regression with K-Nearest Neighbors
About the Author
David Kopec is an associate professor of computer science at Albright College. He is the author of five programming books, including the Classic Computer Science Problems series, and spent several years as an iOS developer for startups. In addition to his teaching work, David is an avid podcaster and indie app developer with an MS in computer science from Dartmouth and an EMBA from Quantic.









