Pemrograman Dasar Warsun Najib
Perkembangan Bahasa Pemrograman 1. Generasi I : Bahasa Mesin ENIAC (Electronic Numerical Integrator and Calculator) pada tahun 1945 oleh Mauchly and Eckert. menggunakan kode-kode biner (0 dan 1), dengan basis dasar transistor. “On” = 1, dan kondisi “Off” = 0. Rumit, sukar dihafal, dan lama Dikembangkan dg bilangan oktal dan heksadesimal 2. Generasi II : Low Level Language Penyempurnaan dari bahasa mesin Bahasa assembly sudah mulai memasukkan unsur kata bahasa inggris meskipun dalam bentuk singkat. Bersifat machine dependent Penulisan bahasa assembly sudah jauh lebih mudah dibanding dengan bahasa mesin, namun masih terlalu sulit bagi orang awam yang tidak memahami perangkat keras komputer, karena beberapa variabel masih mengacu pada register, alamat memori maupun alamat port I/O. III High Level Lg II Low Level Lg. I Bahasa Mesin V Object-Oriented IV Deklaratif
Perkembangan Bahasa Pemrograman (2) 3. Generasi III : High Level Language 1950, FORTRAN (FORmula TRANslator), yang sudah bersifat machine independent. Diikuti bahasa pemrograman aras tinggi spt : BASIC, COBOL, PL/1, PASCAL, ALGOL, PROLOG, C, dsb. Pemrosesan program oleh komputer dlm bahasa aras tinggi ini meliputi: Compilation, Link, Execution
Perkembangan Bahasa Pemrograman (3) 4. Generasi IV : Bahasa Deklaratif Bahasa pemrograman ini jauh lebih mudah ditulis karena instruksinya sudah sangat mendekati bahasa percakapan sehari-hari. misal : LIST NAMA, ALAMAT, NILAI FOR NILAI > 7 Ex: DBASE, SQL (structured query language) 5. Generasi V : Object-Oriented Language Ex : SIMULA, SmallTalk, Ada, C++, Java Car -Colour -wheel -year Person -name -address -phone
JAVA PROGRAMING LANGUAGE
The Java Programming Language The Java programming language is a high-level language that can be characterized by all of the following buzzwords: Simple Architecture neutral Object oriented Portable Distributed High performance Interpreted Multithreaded Robust Dynamic Secure
Compiler and Interpreter
JAVA Application Write program (create application) in JAVA Create source code Compile to bytecode Run the program in the bytecode
Java Application and Applets The most common Java programs are applications and applets. Applications are standalone programs. Applets are similar to applications, but they don't run standalone. Instead, applets adhere to a set of conventions that lets them run within a Java- compatible browser. An is applet embedded in HTML page.
To Write Java Program The Java 2 Platform Standard Edition (Dulu dikenal dengan nama JDK). Dapat didownload di : A text editor Notepad, Textpad, etc Other tools Java IDE (integrated development environment) Jbuilder, Forte for Java (free download), etc
The Java Platform A platform is the hardware or software environment in which a program runs. We've already mentioned some of the most popular platforms like Windows 2000, Linux, Solaris, and MacOS. Most platforms can be described as a combination of the operating system and hardware. The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other hardware- based platforms. The Java platform has two components: The Java Virtual Machine (Java VM) The Java Application Programming Interface (Java API) The Java API is a large collection of ready-made software components that provide many useful capabilities, such as graphical user interface (GUI) widgets. The Java API is grouped into libraries of related classes and interfaces; these libraries are known as packages.
Java Platform The following figure depicts a program that's running on the Java platform. As the figure shows, the Java API and the virtual machine insulate the program from the hardware. Native code is code that after you compile it, the compiled code runs on a specific hardware platform. As a platform- independent environment, the Java platform can be a bit slower than native code. However, smart compilers, well- tuned interpreters, and just-in-time bytecode compilers can bring performance close to that of native code without threatening portability.
Hello World Source Code /** * The HelloWorldApp class implements an application that * displays "Hello World!" to the standard output. */ public class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); }
Compilation
One more Example public class BasicsDemo { public static void main(String[] args) { int sum = 0; for (int current = 1; current <= 10; current++) { sum += current;} System.out.println("Sum = " + sum); }