{"base":{"id":"cs10-19","subject":"Programming","title":"Translators and IDEs","scene":"mix","steps":[{"use":"sys10","mode":"levels","eyebrow":"Language levels","title":"High, low and machine code","body":"High-level languages are easy for people to read. Assembly uses short codes for each processor instruction. Machine code is binary, the only thing a CPU runs. Compare the three.","actions":[{"id":"h","label":"High-level"},{"id":"a","label":"Assembly"},{"id":"m","label":"Machine code"}]},{"use":"sys9","mode":"translate","eyebrow":"Translators","title":"Compiler or interpreter?","body":"A compiler translates the whole program into machine code before it runs. An interpreter translates and runs one line at a time. Watch both handle the same program.","actions":[{"id":"comp","label":"Compiler"},{"id":"interp","label":"Interpreter"},{"id":"step","label":"Step"}]},{"use":"py9","mode":"syntax","eyebrow":"Syntax errors","title":"Breaking the language rules","body":"A syntax error breaks the grammar of the language, so the program can't be translated at all. An IDE highlights it for you. Run it, then fix it.","actions":[{"id":"run","label":"Run"},{"id":"fix","label":"Fix it"}]},{"use":"py9","mode":"logic","eyebrow":"Logic errors","title":"Runs, but wrong","body":"A logic error lets the program run but gives the wrong result. IDE tools such as breakpoints and variable watches help you trace where it goes wrong.","actions":[{"id":"run","label":"Run"},{"id":"fix","label":"Fix it"}]},{"use":"sys9","mode":"quiz","look":"translate","eyebrow":"Check yourself","title":"Choose a translator","body":"A software company wants to sell its game without giving away its source code.","question":"Which translator should it use?","options":["An interpreter","A compiler","An assembler"],"answer":1,"right":"Correct. A compiler produces an executable file, so customers never see the source code.","wrong":"Not quite. Which translator produces a separate machine-code file?"}],"more":[{"type":"cards","id":"worked","eyebrow":"Worked examples","title":"Step by step","items":[{"tag":"Errors","title":"Classify each","body":"print(\"Hi\"      → syntax (missing bracket)\nx = 10 / 0       → runtime (crashes)\narea = l + w     → logic (should be l * w)","code":true},{"tag":"Debugging","title":"Using a breakpoint","body":"set a breakpoint on the suspect line\nrun: program pauses there\nwatch variable values\nstep one line at a time to find the change","code":true}]},{"type":"cards","id":"detail","eyebrow":"The ideas in detail","title":"The ideas in detail","items":[{"tag":"Compiler","title":"Whole program at once","body":"Produces an executable; runs fast; reports all errors at the end; source code stays hidden."},{"tag":"Interpreter","title":"Line by line","body":"No executable; stops at the first error, making debugging easy; needs the interpreter every time it runs."},{"tag":"Assembler","title":"Assembly → machine code","body":"Each mnemonic becomes one machine instruction."},{"tag":"IDE features","title":"Tools for programmers","body":"Code editor with colours and auto-complete, run-time environment, error diagnostics, breakpoints, stepping and variable watches, translator built in."}]},{"type":"cards","id":"mistakes","eyebrow":"Common mistakes","title":"Watch out for these","items":[{"tag":"Mistake","title":"\"Interpreters make faster programs\"","body":"Compiled programs usually run faster because translation is already done."},{"tag":"Mistake","title":"\"Assembly is a high-level language\"","body":"It is low-level: one line per processor instruction."},{"tag":"Mistake","title":"\"Syntax errors appear while running\"","body":"They stop translation before the program can run. Runtime errors happen while it runs."},{"tag":"Mistake","title":"\"Logic errors produce error messages\"","body":"They don't: the program runs, but the answer is wrong."}]},{"type":"cards","id":"deeper","eyebrow":"Go deeper","title":"More than the lesson","items":[{"tag":"History","title":"Grace Hopper's compiler","body":"In the 1950s Grace Hopper built one of the first compilers and argued that programs should be written in English-like words. Her ideas led to the COBOL language."},{"tag":"Real world","title":"Python is both","body":"Python is usually interpreted, but first compiles to \"bytecode\" behind the scenes; Java compiles to bytecode that a virtual machine then runs."},{"tag":"Careers","title":"Who builds these tools?","body":"Compiler engineers, IDE developers and language designers create the tools every programmer uses."},{"tag":"Coming next","title":"Where this leads","body":"Next: putting Term 2 together by following a file's journey through a whole computer system."}]},{"type":"cards","id":"challenge","eyebrow":"Challenge yourself","title":"Stretch your brain","intro":"Try each one on paper before opening the card.","items":[{"tag":"Challenge","title":"Give one reason to use assembly language today.","body":"For very small or fast code that controls hardware directly, such as parts of an operating system, device drivers or a tiny embedded chip."},{"tag":"Challenge","title":"A program crashes only when a user enters 0. What kind of error is it, and which IDE tool would help?","body":"A runtime error (probably division by zero). A breakpoint with a variable watch would show the 0 reaching the division, so you can add validation."}]},{"type":"activities","id":"try","eyebrow":"Try it at home","title":"Try it yourself","items":[{"title":"Spot the error type","time":"15 minutes","need":["Python or an online editor"],"steps":["Type print(\"hello\" and run it: what happens?","Type print(10/0) and run it.","Write a program to average 3 numbers but forget the brackets: (a + b + c) / 3.","Classify each error."],"why":"You will meet a syntax error, a runtime error and a logic error, and see how each one shows itself.","safety":"No safety risks."},{"title":"Debugger tour","time":"15 minutes","need":["An IDE such as Thonny (free)"],"steps":["Write a 5-line loop program.","Click \"Debug\" and step through it.","Watch the variables panel change.","Set a breakpoint and run to it."],"why":"Stepping through code shows exactly what the computer does, line by line: an automatic trace table.","safety":"Download software only with permission."}]},{"type":"quiz","id":"quiz","eyebrow":"Quiz","title":"Eight more questions","questions":[{"question":"Which translator converts a whole program before it runs?","options":["Interpreter","Browser","Compiler"],"answer":2,"right":"Correct.","wrong":"Not quite."},{"question":"Which language is easiest for humans to read?","options":["High-level","Machine code","Assembly"],"answer":0,"right":"Correct.","wrong":"Not quite."},{"question":"An assembler translates…","options":["Python into Java","assembly into machine code","English into French"],"answer":1,"right":"Correct.","wrong":"Not quite."},{"question":"Which error stops a program from being translated?","options":["Logic error","Runtime error","Syntax error"],"answer":2,"right":"Correct.","wrong":"Not quite."},{"question":"Which tool pauses a program at a chosen line?","options":["A breakpoint","A compiler","A router"],"answer":0,"right":"Correct.","wrong":"Not quite."},{"question":"An advantage of an interpreter is…","options":["it hides source code","it stops at the first error, helping debugging","it creates an .exe file"],"answer":1,"right":"Correct.","wrong":"Not quite."},{"question":"Machine code is written in…","options":["English","pseudocode","binary"],"answer":2,"right":"Correct.","wrong":"Not quite."},{"question":"A program runs but adds instead of multiplies. This is…","options":["a logic error","a syntax error","a hardware fault"],"answer":0,"right":"Correct.","wrong":"Not quite."}]},{"type":"checklist","id":"check","eyebrow":"Self-check","title":"I can…","items":["compare high-level and low-level languages","explain what machine code and assembly are","compare compilers and interpreters","describe what an assembler does","tell syntax, runtime and logic errors apart","describe the main features of an IDE","use breakpoints and stepping to debug","choose a translator for a scenario"]},{"type":"keywords","id":"words","eyebrow":"Key words","title":"Words to know","items":[{"word":"high-level language","meaning":"Close to English; works on many computers."},{"word":"low-level language","meaning":"Close to the hardware: assembly and machine code."},{"word":"machine code","meaning":"Binary instructions the CPU runs."},{"word":"assembly language","meaning":"Mnemonics, one per machine instruction."},{"word":"compiler","meaning":"Translates the whole program at once."},{"word":"interpreter","meaning":"Translates and runs one line at a time."},{"word":"assembler","meaning":"Translates assembly into machine code."},{"word":"IDE","meaning":"Integrated development environment."},{"word":"breakpoint","meaning":"A point where a program pauses for debugging."},{"word":"executable","meaning":"A machine-code file that can run on its own."}]},{"type":"sources","id":"sources","title":"Sources","items":["BBC Bitesize, GCSE Computer Science: Translators","Isaac Computer Science: Programming languages","Computer History Museum: Grace Hopper","Thonny IDE documentation"]}]},"overlay":null}