You are on page 1of 20

Algoritma & Pemrograman 2

The Programming
Language Techniques
Indah Permatasari, M.Kom.
2nd meeting
Outline
• Introduction
• Algorithm
• Program vs Programming Language
• Characteristic of algorithms
• Programming language
• Characteristic of programming languages
• Type of Programming language
• Mapping the algorithms to programming languages

Indah Permatasari, M.Kom. 2


Introduction
• Informally, an algorithm is any well-defined computational procedure
that takes some value, or set of values, as input and produces some
value, or set of values, as output.
• An algorithm is thus a sequence of computational steps that
transform the input into the output.
• The algorithm describes a specific computational procedure for
achieving that input/output relationship.
• An algorithm is said to be correct if, for every input instance, it halts
with the correct output. We say that a correct algorithm solves the
given computational problem.
Indah Permatasari, M.Kom. 3
Program vs Programming Language
• An algorithm can be specified in English, as a computer program, or
even as a hardware design.
• The only requirement is that the specification must provide a precise
description of the computational procedure to be followed.
• Computation is the action of mathematical calculation (dictionary).
• Calculation includes both arithmetical and non-arithmetical
• Algorithm that written in a computer is called program
• The activities in creating the program using the programming
languages based on algorithm is called programming

Indah Permatasari, M.Kom. 4


Program
• Words, statements or combinations thereof that are arranged and
assembled into a single procedure in the form of a sequence of steps
to solve a problem implemented using a programming language so
that it can be executed by a computer.
• created with the aim of making it easier for users to provide
instructions or commands into a computer.

Indah Permatasari, M.Kom. 5


Scheme

Model
Problem Limitation Algorithm Solve
Development

• Programming
• Testing
• Documentation

Indah Permatasari, M.Kom. 6


Characteristic of algorithms
• Two characteristics that are common to many interesting algorithmic
problems:
• They have many candidate solutions, the overwhelming majority of which do
not solve the problem at hand. Finding one that does, or one that is “best,”
can present quite a challenge.
• They have practical applications. Of the problems in the above list, finding the
shortest path provides the easiest examples. A transportation firm, such as a
trucking or railroad company, has a financial interest in finding shortest paths
through a road or rail network because taking shorter paths results in lower
labor and fuel costs. Or a routing node on the Internet may need to find the
shortest path through the network in order to route a message quickly.

Indah Permatasari, M.Kom. 7


Programming Language
• Is procedure of writing the program.
• There are two important factor in programming language:
• Syntax → a set of rules for or an analysis of the syntax of a language.
• Semantic → relating to meaning in language or logic. the meaning of a word,
phrase, sentence, or text.
• The function of programming language is as a media to create,
understanding and communication tool among program and
computer

Indah Permatasari, M.Kom. 8


Characteristic of programming languages
• Programming language based on application:
• Specific purpose programming language → Cobol, Assembly, Prolog,
Simscript, etc.
• General purpose programming language → Pascal, Basic, C, C++, Java, etc.
• Programming language based on proximity to human language
• Low level language → the instruction is carried out directly by the computer
• High level language → the instruction can understanding by human easily.

• The limitation of programming language characteristic is not clearly.

Indah Permatasari, M.Kom. 9


Interpretation and Execution
MIPS
(microprocessor
without interlock Machine
pipelined) Language
Assembly

Assembly
Language • C/Java compiler
• Fortran compiler
High Level
language

Indah Permatasari, M.Kom. 10


Interpreter vs Compiler
Interpreter Compiler
Menerjemahkan instruksi per instruksi Menerjemahkan instruksi secara keseluruhan
Source program tidak harus ditulis lengkap Source code ditulis lengkap
Bila terjadi kesalahan kompilasi dapat langsung Bila terjadi kesalahan, source program dibenarkan
dibetulkan secara interaktif ulang dan dilakukan proses kompilasi ulang
Tidak menghasilkan objek program Menghasilkan objek program
Tidak menghasilkan executable program karena Menghasilkan executable program sehingga dapat
dijalankan pada saat program diinterpretasi dijalankan dalam keadaan prompt system
Proses cepat Proses lama
Source program dapat digunakan berulang Source program tidak dapat digunakan untuk
mengerjakan prkgram
Proses pengerjaan lebih lambat Proses pengerjaan cepat karena executable
program sudah dalam Bahasa mesin
Keamanan kurang terjamin Keamanan program terjamin
Indah Permatasari, M.Kom. 11
Procedural programming
• Berisi urutan langkah-langkah penyelesaian masalah
• Pada bagian instruksi terdiri dari runtutan instruksi yang dilaksanakan
satu per satu secara berurutan.
• Alur dapat berubah karena adanya percabangan instruksi/kondisi
• Data yang tersimpan pada memori manipulasi oleh instruksi secara
terurut.
• Contoh Bahasa: Cobol, Basic, Pascal, Fortran, dan C.

Indah Permatasari, M.Kom. 12


Structural Programming
• Bahasa pemrograman yang mendukung pembuatan program sebagai
kumpulan prosedur.
• Setiap prosedur dapat saling memanggil dari manapun dalam program dan
dapat menggunakan parameter yang berbeda-beda untuk setiap
pemanggilan.
• Mendukung abstraksi data, pengkodean terstruktur, dan kontrol program
terstruktur (sequence, section/condition, repetition (loop))
• Mengguakan identasi sehingga jelas struktur dan control
• Memudahkan pembacaan, pemahaman, penelusuran kesalahan, dan
pembuatan koreksi
• Contoh Bahasa: Pascal, Cobol, RPG, ADA, C

Indah Permatasari, M.Kom. 13


Modular Programming
• Program besar dan sulit karena kompleksitas dan banyak bagian
hubungan yang rumit serta detail
• Program dipecah-pecah ke dalam modul-modul
• Setiap modul menunjukan fungsi dan tugas tunggal
• Lebih mudah dipahami karena susunan yang terpisah
• Program memiliki modul utama /program utama yang mengontrol
semua proses
• Menerapkan sub-routine (melakukan perintah proses terbatas)

Indah Permatasari, M.Kom. 14


Functional Programming
• Ekpresi disusun atas fungsi panggilan
• Fungsi adalah perintah yang terkumpul menjadi satu dan dapat menghasilkan
suatu nilai
• Memerlukan proses komputasi sebagai evaluasi fungsi matematika
• Isi dari program fungsional tidak menggandung pernyataan perintah
• Contoh Bahasa: Lisp, Schemes, ML, Haskell, Elang

Indah Permatasari, M.Kom. 15


OOP/Object-Oriented Programming
• Terdapat objek: elemen yang memiliki fungsi, metode, karakteristik,
tertentu yang dapat dibedakan dalam dunia nyata
• Terdapat Class: kumpulan objek-objek yang memiliki kesamaan
karakteristik
• Mampu merefleksikan kebutuhan user sebagai layaknya yang ada di dunia
nyata
• Relatif lebih fleksibel dan mudah beradaptasi terhadap perubahan program
• Memiliki fitur yang memperkuat dan meningkatkan fleksibelitas suatu
objek (class, instance, encapsulation, inheritance, reusability,
polymorphism)
• Contoh Bahasa: C++, SmallTaks, Java

Indah Permatasari, M.Kom. 16


Visual Programming
• Menggunakan ekspresi visual (grafik, gambar, dan ikon)
• Digunakan untuk menyelesaikan masalah komunikasi di dunia
• Berupa himpunan symbol-symbol grafis dan teks yang mempunyai
arti semantic
• Mengacu pada aktivitas yang memungkinkan pengguna untuk
membuat program dalam dua atau lebih dimensi
• Contoh Bahasa: Pictograms, Petri Nets

Indah Permatasari, M.Kom. 17


Even-Driven Programming
• Konsep “jika semua aksi dilakukan terhadap objek, apa yang akan
terjadi oleh objek tersebut”
• Fleksibel dalam pembuatan program karena menggunakan OOP
dimana program dapat dimulai dari objek yang diinginkan tanpa harus
terurut
• Merupakan jenis pemrograman yang memanfaatkan GUI
• Contoh Bahasa: visual basic, visual C++, Delphi, Borland Kilix

Indah Permatasari, M.Kom. 18


Mapping the algorithms to programming
languages
• a : integer
Declaration
• b : integer

•a=1
Initialization
•b=2

The process of problem • a = a+b


solving
•a=3
Finalization

Indah Permatasari, M.Kom. 19


Terima kasih.

Indah Permatasari, M.Kom. 20

You might also like