Language translators and IDEs
Diperkenalkan
19:11
Sistem Operasi
Anda tidak pernah melihatnya, dan Anda tidak akan pernah melihatnya — namun ia selalu ada. Di balik setiap aplikasi yang Anda buka, setiap file yang Anda simpan, setiap sentuhan di layar, ada sesuatu yang tak terlihat…
Narasi bahasa Inggris · takarir bahasa Inggris dan 中文 yang dapat dipilih
Dalam pelajaran ini
| English | Makna |
|---|---|
| compiler/kəmˈpaɪlə/ | kompiler |
| programmer | A person who writes and develops computer programs. |
| machine instructions | Commands in machine code that a processor can execute directly. |
| arithmetic/əˈrɪθmətɪk/ | Calculations with numbers, such as adding and subtracting. |
| source code/sɔːs kəʊd/ | kode sumber |
| translator/trænˈsleɪtə/ | penerjemah |
| machine code/məˈʃiːn kəʊd/ | kode mesin |
| processor/ˈprəʊsesə/ | The component that executes instructions and performs the operations of a computer or similar system. |
| compiling | The process of translating a whole program before it runs. |
| interpreting | The process of translating and executing a program one statement at a time. |
| assembler/əˈsemblə/ | |
| assembly language/əˈsemblɪ ˈlæŋɡwɪdʒ/ | bahasa assembly |
| mnemonic instruction | An assembly language command that uses a short word for an operation. |
| labels/ˈleɪblz/ | Names used to mark positions in a program's code. |
| symbolic addresses | Names used to refer to memory locations instead of their actual addresses. |
| addresses | Numbers that identify specific locations in a computer's memory. |
| hardware/ˈhɑːdweə/ | The physical parts of a computer system that can be touched. |
| device drivers/dɪˈvaɪs ˈdraɪvəz/ | Programs that allow an operating system to control hardware devices. |
| embedded systems | Computers built into larger devices to perform specific tasks. |
| loops | Parts of a program that repeat instructions a number of times or until a condition is met. |
| high-level program | A program written in a language designed to be easier for people to understand. |
| object code/ˈɒbdʒekt kəʊd/ | kode objek |
| executable/ɪɡˈzekjʊtəbl/ | file yang dapat dieksekusi |
| syntax errors | Mistakes that break the rules for writing code in a programming language. |
| run time/rʌn taɪm/ | The period during which a program is running on a computer. |
| operating system/ˈɒpəreɪtɪŋ ˈsɪstəm/ | System software that manages hardware resources and provides services for applications. |
| interpreter/ɪnˈtɜːprɪtə/ | |
| statement/ˈsteɪtmənt/ | A line of code that tells a program what to do. |
| execution speed | The rate at which a computer carries out a program's instructions. |
| portability | The ability of a program to run on different platforms. |
| platform/ˈplætfɔːm/ | The combination of processor and operating system on which a program runs. |
| debugging/ˈdiːbʌɡɪŋ/ | The process of finding and correcting errors in a program. |
| bytecode/ˈbaɪtkəʊd/ | |
| portable/ˈpɔːtəbl/ | portabel |
| virtual machine/ˈvɜːtʃuːəl məˈʃiːn/ | mesin virtual |
| just-in-time compilation/dʒʌst ɪn taɪm ˌkɒmpɪˈleɪʃn/ | pengompilan waktu-nyata |
| native code | Machine code that can run directly on a particular processor. |
| console mode | A way of running a program using text input and output. |
| command line | A place where users type text commands to interact with a computer. |
| integrated development environment/ˈɪntɪɡreɪtɪd dɪˈveləpmənt enˈvaɪrənmənt/ | lingkungan pengembangan terintegrasi |
| context-sensitive prompts/ˈkɒntekst ˈsensɪtɪv prɒmpts/ | prompt peka-konteks |
| identifiers | Names chosen by programmers for parts of a program. |
| keywords/ˈkiːwɜːdz/ | Words with special meanings that are part of a programming language. |
| parameters/pəˈræmɪtəz/ | Values that specify a model or function, or named inputs that a subroutine receives. |
| auto-complete/ˈɔːtəʊ kəmˈpliːt/ | |
| dynamic syntax checks/daɪˈnæmɪk ˈsɪntæks tʃeks/ | pemeriksaan sintaks dinamis |
| prettyprint/ˈpretɪprɪnt/ | |
| strings/strɪŋz/ | Sequences of characters used as text in a program. |
| comments/ˈkɒments/ | Explanatory text in source code or markup that does not execute as a program instruction. |
| indentation/ˌɪndenˈteɪʃn/ | Space placed at the start of a line to show structure, including code blocks in languages that use it syntactically. |
| expand and collapse | A feature that shows or hides sections of code. |
| block/blɒk/ | A group of statements treated as a single section of code. |
| breakpoints/ˈbreɪkpɔɪnts/ | titik henti |
| single stepping/ˈsɪŋɡl ˈstepɪŋ/ | langkah tunggal |
| variables/ˈveərɪəblz/ | A quantity or named value that can change or take different values. |
| expressions | Combinations of values and operations that produce a value. |
| report window/rɪˈpɔːt ˈwɪndəʊ/ | jendela laporan |
| warnings | Messages that point out possible problems in a program. |
| function/ˈfʌŋkʃn/ | A mapping that assigns exactly one output to each allowed input. |
| logic error/ˈlɒdʒɪk ˈerə/ | A mistake in an algorithm or program that produces an incorrect result despite valid syntax. |
| run-time error messages | Messages that report errors occurring while a program is running. |
Tidak seorang pun percaya komputer dapat menulis programnya sendiri
- Pada tahun 1952 Grace Hopper membangun compiler pertama, sebuah program yang mengubah notasi programmer menjadi instruksi mesin. "Tidak ada yang percaya hal itu," katanya kemudian. "Saya memiliki compiler yang berfungsi dan tidak ada yang mau menyentuhnya. Mereka memberi tahu saya bahwa komputer hanya bisa melakukan aritmatika."
- Setiap bahasa yang Anda gunakan sejak itu bertumpu pada ide itu: Anda menulis kode sumber untuk manusia, dan penerjemah menghasilkan kode mesin yang dijalankan prosesor.
- Ada tiga jenis penerjemah dan satu hibrida terkenal, dan ujian menginginkan jawaban mengenai kapan dan mengapa Anda harus menggunakannya.
- Pelajaran ini membahas penerjemah, kompromi antara kompilasi dan interpretasi, campuran Java dari keduanya, serta alat yang disediakan IDE di sekitarnya.
Kode sumber, kode mesin, dan assembler
- Prosesor hanya mengeksekusi kode mesin. Penerjemah mengonversi program yang ditulis untuk manusia menjadi kode tersebut.
- Assembler menerjemahkan bahasa assembly menjadi kode mesin: setiap instruksi mnemonik,
LDD,ADD,JMP, menjadi tepat satu instruksi kode mesin, dan label serta alamat simbolis digantikan dengan alamat riil. - Assembly digunakan di mana programmer membutuhkan kontrol langsung atas perangkat keras: driver perangkat, sistem tertanam, loop terdalam dalam permainan.
Match each translator to what it does.
Kesulitan 2/5 · 140 koin + bonus kecil pada penyelesaian pertama hari ini
Assembler: assembly→machine code; compiler: all-at-once to an executable; interpreter: line by line at run time.
Kompiler
- Kompiler menerjemahkan seluruh program tingkat tinggi menjadi kode mesin, kode objek, sebelum dijalankan. Ia menghasilkan file yang dapat dieksekusi dan melaporkan semua kesalahan sintaks secara bersamaan, sebagai daftar, di akhir penerjemahan.
- Ia tidak menjalankan program. Setelah kode bersih, file yang dapat dieksekusi berjalan tanpa kompiler terpasang, sebanyak yang Anda inginkan.
- Cepat saat waktu eksekusi, karena tidak ada yang diterjemahkan saat berjalan; tetapi kode mesin terkait dengan satu prosesor dan sistem operasi.
The compiler route: source to running program
Step through how a compiler works — translating the whole program once, before it runs. Contrast it with an interpreter, which translates and runs one line at a time.
A compiler differs from an interpreter because it:
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
A compiler translates all at once into an executable that runs without the compiler. An interpreter runs line by line.
Put the compiler route in order, from writing code to running it.
Kesulitan 3/5 · 200 koin + bonus kecil pada penyelesaian pertama hari ini
A compiler translates the whole program once into an executable; that file then runs without the compiler.
Interpreter
- Interpreter menerjemahkan satu pernyataan dari program tingkat tinggi sekaligus dan mengeksekusinya segera sebelum beralih ke berikutnya.
- Tidak ada file yang dapat dieksekusi yang dihasilkan. Ia berhenti pada kesalahan pertama yang ditemui dan melaporkannya, beserta nomornya, sehingga Anda memperbaikinya dan menjalankannya lagi.
- Baik kode sumber maupun interpreter harus hadir setiap kali program dijalankan, dan setiap eksekusi menerjemahkan ulang, sehingga eksekusi lebih lambat; tetapi kode sumber yang sama dapat berjalan di mana pun interpreter tersedia.

Terjemahkan sekali dan kirimkan, atau terjemahkan seiring berjalannya

When does an interpreter report an error?
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
An interpreter runs line by line, so it reports an error at the moment it reaches that line — handy during development.
An interpreter produces no stand-alone executable, so the interpreter itself must be installed to run the program.
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
An interpreter translates and runs line by line each time — there is no separate executable to ship, unlike a compiler.
Manfaat dan kerugian, sesuai dengan skema nilai
| kompiler | interpreter | |
|---|---|---|
| kecepatan eksekusi | cepat, sudah berupa kode mesin | lebih lambat, diterjemahkan setiap kali dijalankan |
| apa yang dibutuhkan pengguna | hanya file yang dapat dieksekusi; kode sumber tetap rahasia | kode sumber dan interpreter |
| menemukan kesalahan | semua terdaftar sekaligus setelah penerjemahan | masing-masing dilaporkan pada barisnya, seiring pengembangan |
| mengubah kode | kompilasi ulang seluruh program | edit dan jalankan kembali segera |
| portabilitas | satu platform; kompilasi ulang untuk masing-masing | berjalan di mana pun interpreter tersedia |

You should choose a compiler when:
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
Compiled executables are fast and stand-alone. Interpreters suit quick development and portable scripts.
Which points favour using an interpreter while developing a program? Select semua that apply.
Kesulitan 2/5 · 140 koin + bonus kecil pada penyelesaian pertama hari ini
Fast edit-run cycles and errors at their line are the interpreter's strengths. Run-time speed is the compiler's.
Contoh kerja: interpreter saat menulis, kompiler saat selesai
- Seorang pengembang menggunakan interpreter saat menulis program dan kompiler saat selesai. Jelaskan bagaimana masing-masing digunakan. [4]
- Selama pengembangan, interpreter menjalankan program yang belum lengkap sekaligus, tanpa menunggu penerjemahan sempurna. Ketika menemui kesalahan, ia melaporkan barisnya, sehingga pengembang memperbaikinya dan menjalankannya kembali segera: siklus edit-jalankan yang cepat yang memudahkan pemecahan masalah.
- Saat program selesai, kompiler menerjemahkan seluruh program menjadi file yang dapat dieksekusi yang berjalan lebih cepat, tidak memerlukan penterjemah di komputer pengguna, dan menjaga kode sumber tetap pribadi.
- Dua poin untuk setiap alat: apa yang dilakukannya, dan mengapa hal itu sesuai dengan tahap tersebut.
Java: sebagian dikompilasi, sebagian ditafsirkan
- Sumber Java dikompilasi menjadi bytecode, bentuk antara yang ringkas dan portabel yang bukan kode mesin untuk prosesor nyata mana pun.
- Sebuah mesin virtual, JVM, kemudian menafsirkan bytecode pada mesin apa pun tempatnya berjalan, atau menggunakan kompilasi tepat-waktu (just-in-time) untuk mengubah bagian paling sibuk menjadi kode asli selama program berjalan.
- Tahap kompilasi menangkap kesalahan sintaks lebih awal; tahap interpretasi memungkinkan satu file bytecode berjalan di mana pun JVM tersedia. Java dalam mode konsol, program teks yang dijalankan dari baris perintah, adalah contoh dalam silabus.

Tulis sekali, jalankan di mana saja: satu file bytecode, satu JVM per platform

Java compiles to bytecode that runs on a JVM. The main benefit is:
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
Bytecode is platform-independent; any JVM can run it (with JIT giving near-native speed for hot code).
Java's compiler produces platform-independent ____, which a virtual machine then interprets.
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
Bytecode is an intermediate form: compiled once, then run by the JVM on any platform. That is what makes Java partially compiled and partially interpreted.
Kartu ini telah diperbaiki, jadi ditampilkan dalam bahasa Inggris sampai terjemahannya diperbarui.
Worked example: why compile to bytecode and then interpret?
- Explain why Java is compiled to bytecode rather than straight to machine code.
- A compiler produces machine code for a particular processor and operating system, so the program will not necessarily run on a machine with a different platform.
- Java's compiler targets a virtual machine instead, so the bytecode is identical everywhere. Each platform supplies its own JVM to interpret it.
- The cost is speed: interpreting bytecode is slower than running native code, which is why the JVM adds just-in-time compilation 即时编译 for the hot parts.
IDE dan empat kelompok fiturnya
- Lingkungan pengembangan terintegrasi (IDE) adalah satu aplikasi untuk menulis, menerjemahkan, menjalankan, dan memecahkan masalah program. Silabus mengelompokkan fiturnya menjadi empat.
- Untuk pemrograman: prompt peka konteks muncul menampilkan pengenal, kata kunci, atau parameter yang sesuai pada titik itu; auto-complete menyelesaikan nama.
- Untuk deteksi kesalahan awal: pemeriksaan sintaks dinamis memberi garis bawah pada kesalahan saat Anda mengetik, sebelum penerjemahan. Untuk presentasi: prettyprint menampilkan kata kunci, pengenal, string, dan komentar dalam warna berbeda dengan indentasi konsisten; perluas dan lipatkan menyembunyikan badan blok agar Anda melihat kerangka utamanya.
- Untuk pemecahan masalah: titik henti menghentikan program di baris yang ditandai; langkah tunggal menjalankan satu baris sekaligus; jendela menampilkan nilai variabel dan ekspresi; jendela laporan mencantumkan kesalahan, peringatan, dan output.

Pemrograman, deteksi kesalahan, presentasi, pemecahan masalah

Which feature is part of an IDE's debugger?
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
A debugger lets you set breakpoints, step through code line by line, and inspect variable values.
Match each IDE feature to its syllabus group.
Kesulitan 2/5 · 140 koin + bonus kecil pada penyelesaian pertama hari ini
Coding, initial error detection, presentation, debugging: the four groups the syllabus names, one feature each here.
Contoh kerja: menemukan bug di Calculate()
- Fungsi
Calculate()mengembalikan nilai yang tidak diharapkan. Jelaskan bagaimana fitur pemecahan masalah IDE membantu menemukan penyebabnya. [4] - Tetapkan titik henti pada baris pertama
Calculate(), agar program berhenti di sana alih-alih melanjutkan eksekusi. - Langkah tunggal melalui fungsi tersebut satu baris sekaligus. Setelah setiap langkah, baca nilai variabel dan ekspresi apa pun yang telah Anda minta untuk dipantau oleh IDE, dan bandingkan dengan yang Anda harapkan.
- Baris pertama setelah nilai menjadi salah adalah tempat terjadinya kesalahan logika. Jendela laporan menampilkan pesan kesalahan waktu berjalan dan output sepanjang proses.

Jeda, langkah demi langkah, periksa
Put the steps of finding a logic error with a debugger in order.
Kesulitan 3/5 · 200 koin + bonus kecil pada penyelesaian pertama hari ini
Pause, step, inspect, compare, locate. Each is one of the debugging features the syllabus lists.
Nilai yang mudah terlewat
- A compiler does not run the program. It translates the whole of it and produces an executable.
- An interpreter stops at the first error; a compiler lists them all. Do not swap these.
- "Faster" needs "at run time", and "portable" needs "the same source runs wherever an interpreter exists".
- Sort IDE features into the syllabus's four groups: a breakpoint is debugging, prettyprint is presentation, a context-sensitive prompt is coding. Bytecode is not machine code.
Anda telah memahaminya
- assembler: one assembly instruction to one machine-code instruction · compiler: the whole program, before it runs, an executable, all errors listed · interpreter: one statement at a time, executed at once, stops at the first error, no executable
- compiler for speed, distribution and privacy of the source; interpreter for a fast edit-run cycle, portability and beginners
- Java compiles to portable bytecode that a JVM interprets or JIT-compiles: partially compiled, partially interpreted
- IDE features in four groups: coding (context-sensitive prompts), initial error detection (dynamic syntax checks), presentation (prettyprint, expand and collapse), debugging (breakpoints, single stepping, variables, report window)
Apa yang salah? Hanya tim situs yang dapat melihatnya.