Theory
3 tools, एक confusion
आपका marks program कागज़ पर है। अब practical सवाल: उसे कहाँ type करें? machine code में क्या बदलेगा? और Python सीख रही आपकी दोस्त क्यों कहती है कि वह "कभी compile नहीं करती"?
3 tools इनके जवाब हैं: editor, compiler, interpreter। Students तीनों को मिलाकर एक "coding वाला software" बना देते हैं, और examiners हर साल उसी घालमेल की दावत उड़ाते हैं।
Theory
Notebook, किताब का अनुवादक, live दुभाषिया
Editor एक notebook है: जो लिखो वह रखता है, न कुछ जांचता है, न translate करता है। Compiler किताब का अनुवादक है: आपकी पूरी manuscript लेता है, पूरी translate करता है, और तैयार किताब लौटाता है जिसे कोई भी पूरी रफ्तार से पढ़े। Interpreter वक्ता के बगल वाला live दुभाषिया है: sentence-by-sentence, तुरंत, पर हर बातचीत में उसका होना ज़रूरी, इसलिए कुल मिलाकर धीमा।
At a glance
तीनों tools आमने-सामने
| Tool | काम | उदाहरण |
|---|---|---|
| Editor | Source text लिखना और edit करना | Notepad, VS Code, Turbo C editor |
| Compiler | पूरा program translate, फिर run | C, C++ toolchains |
| Interpreter | Line-by-line translate और run | Python, पुरानी BASIC |
Theory
Compiler बनाम interpreter: exam वाली तुलना
- Translation कब होता है: compiler चलने से पहले सब कुछ translate करता है; interpreter चलते समय, line-by-line।
- Errors का अंदाज़: compiler पूरी file जांचकर सारे errors एक साथ बताता है; interpreter पहली error वाली line पर रुक जाता है।
- रफ्तार: compiled programs तेज़ चलते हैं (translation की कीमत पहले चुक चुकी); interpreted lines हर run पर translation की कीमत देती हैं।
- C compiled है। इसीलिए पिछले lesson की pipeline बनी: .c → .obj → .exe।
Quiz
आपके C program में line 5 और 12 पर errors हैं। आपकी दोस्त के Python program में भी उन्हीं lines पर। दोनों errors के बारे में पहले किसे पता चलेगा?
- आपको: compiler पूरी file जांचकर दोनों errors एक साथ list करता है
- दोस्त को: interpreters errors जल्दी ढूंढते हैं
- दोनों को एक साथ दोनों errors दिखेंगे
- किसी को नहीं: errors सिर्फ program चलते समय दिखते हैं
Show the answer
आपको: compiler पूरी file जांचकर दोनों errors एक साथ list करता है
Compiler चलने से पहले पूरा source पढ़ता है, इसलिए उसकी error report पूरी file की होती है, line 5 और 12 साथ-साथ। Interpreter line-by-line चलता है और line 5 पर ठप: line 12 की error तब तक छिपी रहती है जब तक 5 ठीक करके दोबारा run न हो। यही scenario compiler-vs-interpreter का classic exam सवाल है।
Think first
सोचकर देखिए
एक weather app हर second लाखों बार भारी calculations करता है। Analogy से reason कीजिए: compiled या interpreted, कौन सा suit करेगा, और क्यों?
Show the answer
Compiled। Translation पहले, एक बार हो चुका, तो run time पर CPU खालिस machine code पूरी रफ्तार से खाता है। Interpreter वही गर्म lines लाखों बार दोबारा translate करता, हर चक्कर पर अनुवादक की फीस। Quote करने लायक rule: speed चाहिए तो compile, सहूलियत चाहिए तो interpret, मोटे तौर पर इसीलिए system software C पर और फटाफट scripts Python पर टिकी हैं।
Watch out
Marks कहाँ कटते हैं
यह लिखना कि editor translate या run करता है: वह text का tool है, बस। Interpreter को "तेज़" कहना: वह तुरंत-सा LAGTA है (compile step नहीं) पर execute धीमा करता है; दोनों रफ्तारें अलग रखिए। और जब आप Turbo C या VS Code use करते हैं, आप एक IDE के अंदर हैं: editor + compiler + runner एक window में, एक छत, फिर भी exam के answer में tools 3 ही।
Theory
अपना kitchen set कीजिए
इसी हफ्ते एक C setup install करके पिछले lesson का marks program compile कीजिए: शुरुआत के लिए कोई भी online C compiler चलेगा, और local IDE (Code::Blocks, VS Code + GCC) असली practice देगा। अपनी ही .c file को .exe बनते देखना 2 lessons एक साथ पक्के कर देता है। आगे: उसी छोटे program की line-by-line anatomy।
Summary
Key takeaways
- Editor: source text लिखता है; कुछ translate नहीं करता (Notepad, VS Code)।
- Compiler: चलने से पहले पूरा program translate; सारे errors एक साथ; C का तरीका।
- Interpreter: line-by-line translate-और-run; पहली error पर रुकता है; Python का तरीका।
- Compiled programs तेज़ चलते हैं; interpreted में feedback जल्दी मिलता है।
- IDE एक window में editor + compiler + tools bundle करता है।
- Memory hook: notebook, किताब का अनुवादक, live दुभाषिया।