1 1.1 Introduction • H. M. Deitel, P. J. Deitel. 2004, Java How to Program, Sixth Edition – Java 2 Standard Edition – Object-oriented programming • Java tutorial: http://download.oracle.com/javase/tutorial/ • Arnold, K., Gosling, J., and Holmes, J. 2005. The Java™ Programming Language, 4th Edition. Addison Wesley Professional. • Zakhour, S., et al. 2005. The Java™ Tutorial Fourth Edition: A Short Course on the Basics. Addison Wesley Professional. 2003 Prentice Hall, Inc. All rights reserved. 2 1.2 What Is a Computer? • Komputer: – Peranti/peralatan yang mampu melaksanakan perhitungan (komputasi) dan membuat keputusan logika • Program Komputer (Computer Program): – Sekumpulan instruksi yang mengontrol pemrosesan data yang dilakukan komputer. • Hardware: – Sekumpulan peralatan yang membentuk komputer. – Misal: keyboard, mouse, CPU, monitor, CD-ROM, Hard Disk, Floppy Disk, DVD-ROM, RAM, printer, scanner dsb. • Software: – Program yang berjalan di atas komputer. 2003 Prentice Hall, Inc. All rights reserved. 3 1.3 • 1. Computer Organization (1) Secara logis komputer dibagi menjadi 6 bagian: Input Unit – Bagian Penerimaan – Receiving Section – Mendapatkan informasi dari peranti masukan seperti: keyboard, mouse, microphone, scanner, networks, … 2003 Prentice Hall, Inc. All rights reserved. 4 1.3 2. Computer Organization (2) Output Unit – Bagian Pengiriman – Shipping Section – Mengambil informasi yang diproses komputer – Menempatkan informasi pada peranti-peranti keluaran (output devices), seperti: monitor, printer, dsb 2003 Prentice Hall, Inc. All rights reserved. 5 1.3 Computer Organization (3) 3. Memory Unit – Akses yang cepat (rapid access) – Warehouse Section yang memiliki kapasitas relatif rendah – Menyimpan informasi dari input unit – secara langsung tersedia bagi proses yang ada – Menyimpan informasi yang telah diproses – sampai selesai ditempatkan pada output unit – Berupa memory (RAM), primary memory (cache memory pada processor) 2003 Prentice Hall, Inc. All rights reserved. 6 1.3 Computer Organization (4) 4. Arithmetic and Logic Unit (ALU) – Bagian Fabrikasi – Manufacturing Section – Melaksanakan proses perhitungan aritmatika dan keputusan logika 5. Central Processing Unit (CPU) – Bagian Administratif / Administrative Section – Mengawasi dan mengkoordinasi bagian-bagian lain di dalam komputer 2003 Prentice Hall, Inc. All rights reserved. 7 1.3 Computer Organization (5) 6. Secondary Storage Unit – “Warehouse Section” yang memiliki kapasitas besar, waktu yang lama. – Sebagai penyimpan – program atau data yang sedang tidak aktif – Peranti penyimpan sekunder – Disks (hard disk, floppy disk, compact disc dsb – Lebih lama waktu aksesnya dan lebih mahal harganya daripada primary memory 2003 Prentice Hall, Inc. All rights reserved. 8 1.4 Evolution of Operating Systems • Batch processing – One job (task) at a time – Operating systems developed • Programs to make computers more convenient to use • Switch jobs easier • Multiprogramming – “Simultaneous” jobs – Timesharing operating systems 2003 Prentice Hall, Inc. All rights reserved. 1.5 Personal, Distributed and Client/Server Computing • Personal computing – Computers for personal use • Distributed computing – Computing performed among several computers • Client/server computing – Servers offer common store of programs and data – Clients access programs and data from server 2003 Prentice Hall, Inc. All rights reserved. 9 1.6 Machine Languages, Assembly Languages and High-Level Languages • Machine language – “Natural language” of computer component – Machine dependent • Assembly language – English-like abbreviations represent computer operations – Translator programs convert to machine language • High-level language – Allows for writing more “English-like” instructions • Contains commonly used mathematical operations – Compiler convert to machine language • Interpreter – Execute high-level language programs without compilation 2003 Prentice Hall, Inc. All rights reserved. 10 11 Bahasa Mesin (Machine Language) • • • • • Bahasa asli komputer – “Native Computer Language”. Ditentukan oleh perancangan hardware dan tergantung pada jenis mesinnya – “machinedependent”. Umumnya terdiri dari deretan angka-angka – hampir keseluruhan adalah 0 dan 1 saja. Menginstruksikan kepada komputer untuk melaksanakan proses-proses dasar - sekali dalam satu waktu. Sulit bagi manusia 2003 Prentice Hall, Inc. All rights reserved. 12 Bahasa Rakitan (Assembly Language) • • • • • Menggunakan singkatan-singkatan dalam bahasa Inggris untuk menggambarkan operasi-operasi komputer dasar Lebih jelas bagi manusia Assembly Language memerlukan beberapa perintah untuk 1 tugas sederhana Tidak dimengerti komputer -> perlu translator (assembler) -> mengkonversi ke bahasa mesin Misal: – MOV DX, 100; 2003 Prentice Hall, Inc. All rights reserved. 13 Bahasa Tingkat Tinggi (High-Level Language) • • • • Menggunakan istilah-istilah dalam bahasa Inggris dan notasi matematis umum Satu pernyataan menyelesaikan tugas-tugas substantial Program translator (compiler) mengkonversi ke bahasa mesin Program interpreter mengeksekusi perintah satu persatu dalam bahasa tingkat tinggi secara langsung 2003 Prentice Hall, Inc. All rights reserved. 14 1.13 Basics of a Typical Java Environment • Java programs normally undergo five phases – Edit • Programmer writes program (and stores program on disk) – Compile • Compiler creates bytecodes from program – Load • Class loader stores bytecodes in memory – Verify • Verifier ensures bytecodes do not violate security requirements – Execute • Interpreter translates bytecodes into machine language 2003 Prentice Hall, Inc. All rights reserved. Phase 1 Editor Disk Phase 2 Compiler Disk Program is created in an editor and stored on disk in a file ending with .java. Compiler creates bytecodes and stores them on disk in a file ending with .class. Primary Memory Phase 3 Class Loader Disk Phase 4 Bytecode Verifier . .. . . . Class loader reads .class files containing bytecodes from disk and puts those bytecodes in memory. Primary Memory Bytecode verifier confirms that all bytecodes are valid and do not violate Java’s security restrictions. . .. . . . Primary Memory Phase 5 Interpreter . .. .. . Fig. 1.1 Typical Java environment. 2003 Prentice Hall, Inc. All rights reserved. Interpreter reads bytecodes and translates them into a language that the computer can understand, possibly storing data values as the program executes. 15