bahan bacaan
DESCRIPTION
bahan bacaTRANSCRIPT
Mempelajari Pemrograman Komputer
PemrogramanKomputer…? Sulit..?
LatihanSabar
internal-combustion
enginehow to drive a car
“Mengapa harus merepotkan diri untukbelajar pemrograman komputer?”
Tergantung
pada tujuanutama
• Untuk kesenangan.
• Untuk memenuhi kebutuhan.
• Untuk mengejar karier atau karir
yang kedua.
• Sebagai tantangan
“Meskipun anda dapat hidup dari bekerja sebagai seorang programmer, anda juga dapat
hidup layak dengan menjadi seorang pedagang emas, pegawai negeri, atau membuka
restoran. Akan tetapi jika anda tidak menikmati apa yang anda kerjakan, seluruh uang di
dunia tidak akan membuat hidup anda menjadi lebih baik. Pilihlah apa yang ingin anda
kerjakan karena memang anda menginginkannya – bukan hanya karena hal tersebut dapat
membuat anda menjadi kaya.”
Bagaimana Cara Bekerja Program Komputer?
Komputer tidak
melakukan apa-
apa tanpa
seseorang
memerintahkan
apa yang perludilakukan.
Intruksi
Write a program, which tells a computer what to do,
step-by-step, much as you write out a recipe.
Buy a program that someone else has already written
that tells the computer what to do.
write a program
A program does
nothing more than
tell the computer
how to accept
some type of input,
manipulate that
input, and spit it
back out again in
some form that
humans find useful.
Programming is problem-solving
world is
full of problems
a program tells the
computer how to solve a specific problem
Programs
is endless
Big problem,
Little problems
Determine how far to move a cartoon figure on-screen as the user moves a
joystick.
Detect whether the cartoon figure bumps into a wall, falls off a cliff, or runs
into another cartoon figure on-screen.
Make sure that the cartoon figure doesn’t make any illegal moves.
Draw the terrain surrounding.
Determine whether bullets that another cartoon figure fires are hitting the
player’s cartoon figure. If so, determine the amount of damage, how it
affects the movement of the damaged cartoon figure, and how the damage
appears on-screen.
The simpler that the problem is that you need
to solve, the more easily you can write a program that tells the computer how to work.
'Bapak' Video Game Meninggal Dunia
sebagai bapak video game.
Magnavox Odyssey dipamerkan pada April 1972, dandirilis empat bulan setelahnya setelah perusahaanMagnavox mengantongi sejumlah lisensi. Menurutcatatan New York Times, konsol tersebut terjualsebanyak 130 ribu unit di tahun pertama, dan tumbuh330 ribu pada akhir 1975.
Karena temuannya itu, dan sejumlah paten yang iakantongi, Baer pernah dianugrahi mendali bidangteknologi oleh mantan Presiden Amerika Serikat GeorgeW. Bush pada Februari 2006.
Baer kini berpulang dengan meninggalkan dua putra,James dan Mark, serta seorang putri bernama NancyBaer. Ia juga meninggalkan empat orang cucunya. IstriBaer, Dena Whinston sudah meninggal lebih dulu pada2006 silam.
Berikut adalah video kenangan Baer saat ia berbicaramengenai sejarah video game dan keinginanterbesarnya terhadap industri tersebut.
Manchester, CNN Indonesia -- Ralph Baer, penemukonsol game komersial meninggal dunia pada usia 92tahun.
Baer menghembuskan nafas terakhir di rumahnya diManchester, New Hampshire. Kakek ini dikenal lantarankonsol ciptaanya yang bernama Magnavox Odyssey,konsol game komersil pertama di dunia. Temuan inimembuatnya dijuluki
Programming isn’t difficult;
it’s just time-consuming
The hardest part:
“identifying all the
little problems that
make up the big
problem”
1.Where do I start and exactly how far
south do I drive down Highway I-5?
2.How do I recognize the Sweetwater
Road exit, and how do I get off at this
exit?
3.After I turn right at the light, how far to
the right do I turn, and do you mean the
traffic light or the street light on the
corner?
4.After I turn into the second driveway on
the left, what do I do next? Park the car?
Honk the horn? Gun the engine andaccelerate through your garage door?
1. Go south on Highway I-5.
2. Get off at the Sweetwater Road
exit.
3. Turn right at the light.
4. Turn into the second driveway
on the left.
What Do I Need to Know to Program a Computer?
Desire
Curiosity
Imagination
All about Programming Languages
Programming is
nothing more than
writing step-by-step
instructions telling the
computer.
Makes programming time consuming.
Computers don’t
understand
language that human
beings
programming language
• A collection of instructions that tell the computer what to
do is known as a program.
• The instructions, written in a specific programming language, is known as the source code.
Why So Many Different Programming Languages?
Each language serves a specific purpose, and people
are always creating new languages to solve different types of problems.
Computers really understand only one language machine language
Machine language has the following two major drawbacks:
You can easily type a 0 or 1 by mistake, thereby
preventing you from giving the computer the correct
instructions.
Machine language takes a long time to write (and an
even longer time to understand what the language is
actually telling the computer to do).
assembly language
The joy of assembly language
To write programs faster and
easier than using machine language.
Assembly language uses short,
easy-to-remember (to
programmers, that is) phrases.
Ex: JMP, MOV, and ADD
makes the code easier to read
and modify later
Making programs easy to read and modify is crucialbecause most programs never work right the first time
you use them. And if you want to add new features to a
program later, you need to understand how the currentprogram works so that you know how to modify it.
Assemblers
Special programs that translate
assembly language into machine language.
Assembly language machine code,
Language for their convenience only
Assembly language programs are
easier to read than machine language
programs.
Assembly language programs are
easier to write (and modify) thanmachine language programs.
Disadvantages:
Programs that you create by using assembly
language run slower and gobble up more space
(both physical disk space and memory) than
equivalent programs that you may create with
machine language.
You can’t easily transfer (or, to use programming
lingo, port) a program that you write in assembly
language for one computer to another computer.
Writing a program in assembly language can
prove extremely tedious, time-consuming, and
complicated. That’s why few people bother towrite large programs in assembly language.
In general, the easier the programming language
is to read and write, the slower and larger are the
programs it creates. The Holy Grail of computer
programming is to create programs that are easy
to write, run as fast as possible, and take up aslittle space as possible.
C: The portable
assembler
COBOL andFORTRAN
Programmers felt that they needed a
language that offers the power to
access hardware (as does assembly
language) but is easier to read, write,
and modify (as are COBOL and
FORTRAN). Eventually, they
invented a programming language
known simply as C.
C programs
assemblylanguage code
machine
language code
less efficient
easier to
read, write & modify
readability
for speed and size
To create a language that’s easier to
read and write than assembly
language.
To offer programmers the capability to
access all the parts of the computer
just as they can by using assembly
language.
To provide a small, simple language
that you can easily port from one
computer to another. Programs that
you write in C can run on different
computers without massive rewriting,
which is the main drawback with
assembly- and machine-languageprograms.
C programming language
three main goals Computer C
assembly language
ConvertC program
compilers
Machine Language
Special Program
Write C program for the Macintosh,
copy it to a computer running Windows
XP, recompile it, and run the program
with little or no modification.
C portability one of the most popular
programming languages in
the world
C++
Windows
95/98/Me/NT/2000/XP,
Unix, and Linux
Quicken, Netscape
Navigator, and
Microsoft Word.
C creates larger and slower programs than
equivalent assembly or machine-language
programs.
The C language gives programmers access to all
parts of a computer, including the capability to
manipulate the computer’s memory.
Unfortunately, all this power can prove as
dangerous as giving a hyperactive monkey a
chainsaw and a hand grenade. If you don’t write
your C programs carefully, they can accidentally
wreck your computer’s memory, causing your program to crash your computer.
C / C++ Flaws
Object-Orientation Programming
C++, Java, Perl, Python, and C#. reliableC-derived languages add
a special feature knownas object-orientation
to write small programs that they can easily reuse and modify
protect programmers from writing
programs that can mess up the
computer’s memory, as C programs
can do, which decreases the chance
of writing a program that crashes an
entire computer.
High-level programming languages
writing machine-
or assembly-
language programs
Difficult
confusing
FORTRAN, COBOL,
BASIC, Pascal, andAda
ordinary
human languages
FORTRAN FORmula TRANslatorCOBOL COmmon Business Oriented
Language
BASIC Beginner’s All-purpose Symbolic
Instruction Code
was designed to teach complete novices how to program
Pascal (named after the French philosopher,
Blaise Pascal)
to help beginners learn how to programEncourages programmers to write wellstructured
programs that you can easily read, understand, and
modify at a later date.
Pascal Basic
More structured. Less structured.
Forces you to plan
your program before
you write.
Easy but makes
reading and
understanding more
difficult.
May take longer. Right away.
• Liberty BASIC
• Visual BASIC• etc
• High-level programming languages create larger
and slower programs than equivalent C,
assembly language, or machine-language programs.
• High-level programming languages shield you
from accessing all the parts of the
computer, preventing you from using the power
available in C, assembly language, or machine-
language programs. As a result, writing certain types of
programs, such as operating systems or disk utility
programs (such as the Norton Utilities), is more difficult
(but not impossible) in high-level languages.
• High-level programming languages more closely
resemble human languages, so writing a
compiler for a high-level language is more difficult. If
your computer doesn’t have a compiler for your favorite
high-level language (such as Ada), you can’t write a
program for your computer in that particular
programming language.
• You can write programs much faster in a high-level
programming language than you can in assembly language or
machine language. (You can write a program in C in roughly
the same amount of time as in a highlevel language such as
Pascal.)
• Learning and mastering a high-level programming language
takes less time than learning and mastering machine
language, assembly language, or C programming.
• Because high-level programming languages shield you from
accessing all parts of a computer, they protect you from
writing programs that accidentally mess up the computer,
causing it to crash.
• Reading and modifying a program written in a high-level
language is much easier than reading and modifying an
equivalent program written in C, assembly language, or
machine language.
• Programs written in high-level languages can run on a
variety of computers. If you write a program in a high-level
language, you can (theoretically) port that program to run on a
different computer.
Rapid Application Development (RAD) programming languages
RAD languages enable programmers to design
the way that they want their program to look
(the user interface) and then write source code
to make that user interface actually do
something useful, such as display informationin a window
Some popular RAD languages are Visual Basic
and Real Basic (based on BASIC), Delphi and
Kylix (based on Pascal), Visual C# (based onC++), and JBuilder (based on Java).
Rapid Application Development (RAD) programming languages
Benefits: You can write programs with graphical user
interfaces much faster by using RAD than
you can by using ordinary C++, BASIC, or
Pascal.
Figure: shows StoryCraft, a story-creating
program that two professional fiction writers
developed to help people create original
stories for novels, short stories, plays, or
screenplays.
Benefits: RAD languages simplify the process of creating user interfaces so that you can focus on
getting the rest of your program to work. Without a RAD language, you’d need to write
instructions to make the user interface work and then write additional instructions to make the
rest of the program work as well, essentially doubling your work and the chance of making a
mistake.
Because RAD languages derive from existing high-level languages (C++, BASIC, and Pascal),
you can learn and start programming in a RAD language right away if you already know C++,
BASIC, or Pascal.
Rapid Application Development (RAD) programming languages
“nothing involving computers is ever perfect”
Rapid Application Development (RAD) programming languages
Drawbacks: Programs that you write in RAD languages are rarely portable between
different computers. Visual Basic runs only on Microsoft Windows
98/Me/NT/2000/XP, for example, so if you write a program in Visual Basic, you
can never run it on a Macintosh, Linux, or other computer operating system
without extensive modification.
RAD languages create larger and slower programs than the equivalent
programs written in pure C++, BASIC, or Pascal. A RAD language may help
you create programs faster, but you sacrifice speed and program size.
Database programming languages
C++, BASIC, and Pascal etc
general-purpose languages
Ex:
• Flight simulator.
• Accounting program.
• Voice-recognition
program.
• Word processor.• Database
storing and retrieving
information, such as names,
addresses, phone numbers,
prison records, credit history,and past job experience
Database
Database programming languages
Programming language General-purpose language
Create custom databases. Making anything else.
Faster. Slower.
Instructions only to manipulate the
database information
Instructions to store information
and then write additional
instructions to manipulate that
information.
FileMaker, Microsoft Access, SQL
(Structured Query
Language)
C++, BASIC
SQL Language:
If you’re writing a program that stores huge
chunks of information, you can write a
program much faster by using a database
programming language than by using a
general-purpose language such as C++ or
Pascal.
Database programming is a lucrative field. If
you know how to create customizeddatabases, you almost never need
Database programs are often tied to a specific
computer. If you write a custom database using
FileMaker, for example, you can run your
program only on a computer that can also run
the FileMaker program. Because FileMaker is
currently limited to the Macintosh and Windows
operating systems, you can’t run a FileMaker
program on a computer that uses Linux.
Database programming languages are great at
making custom databases but lousy at making
anything else, such as video games, word
processors, or utility programs (such as anti-
virus utilities). If you need to create a variety of
programs, you can’t rely on a database
programming language by itself.
Database programming languages
Scripting programming languages
Writing a
program
• Flexibility
• Long time
• Nuts in the process
General-purposeLanguage (C++ / Pascal)
Scripting language
Word processor
• Write instructions that create a
simple word processor.
• Write additional instructions for
screenplays.
• Focus on the task that you
want to accomplish without
worrying about irrelevant
details.
Ex: scripting language
Scripting programming languages
• A scripting language enables you to
modify an existing program, such as a
word processor or spreadsheet. That way,
you can create sophisticated programs
quickly with very little programming.
• Scripting languages are generally easier
to learn than more powerful
programming languages, such as C++. As a
result, you can learn and start writing
programs faster.
• Scripting languages are tied to a specific program. If
you customize a word processor by using a scripting
language, your program runs only on computers that
run that particular word processor. If you customize
Microsoft Word, your program works only on computers
that can run Microsoft Word, such as Windows and
Macintosh computers.
• Selling and distributing your programs is much more
difficult. To use your program, people must buy or
already own the program (word processor, spreadsheet,
and so on) that you customize. So if you create a
custom program for WordPerfect, Microsoft Word users
can’t use it.
• A scripting language provides much less flexibility than does a generalpurpose programming language
such as C++. Make sure that the tradeoff of
convenience and ease of programming is worth the
limitations of using a scripting language.
Web-page programming languages
(HTML) Hyper Text Markup Language
the graphical
appearance of Web
pages.
(HTML) Hyper Text Markup Language
the graphical
appearance of Web
pages.
Web-page programming languages
To make Web pages capable of interacting with the
user (for playing games, filling out forms, and so on),
programmers created special Web-page programming
languages such as Java, JavaScript, and VBScript.
(HTML) Hyper Text Markup Language
Web-page programming languages
Java can create two types of programs:
stand-alone applications (such as games or
word processors) and smaller applets,
which can run off a Web page.
Web-page programming languages
• You can create interactive Web
pages to make your site more interesting
to look at and to encourage viewers to
stay on your site longer.
• The language is easy to learn and
enables you to create programs that
anyone around the world with Internet
access can use.
• Not all browsers support all features of Web page
languages such as JavaScript or VBScript. As a result,
users of older browsers can’t run programs that you
create by using Web-page languages.
• For Internet users saddled with slow access (such as through a 28.8 baud modem), programs that
you create in a Web-page language (such as VBScript)
can run slowly, discouraging visitors from visiting your
Web site.
• Only people with Internet access can run
programs that you create with a Web-page language
(except for Java). If you want to sell a program to
others, you don’t want to use a Web-page language.
The Best Programming Language to Learn?
1. No single “best” programming language exists.
• Write programs you need at least one high level language (C++), one database
programming language (SQL).
2. For those planning to work for themselves, one of the most lucrative markets is writing
custom databases for other companies (SQL or VBA,). If you want to know web pages
you need to know HTML and gain some familiarity with Java, JavaScript, VBScript
Internet programming languages
“Ultimately, the best programming language to
know is the one that enables you to accomplish
the task that you want as quickly and easily aspossible”
Menulis Bahasa Pemrograman
Sebelum anda membuat / menulis
sebuah program ada beberapa hal yang
perlu dipertimbangkan:1. Pengguna: Siapa yang akan menggunakan.
2. Komputer Target: Komputer dengan spesifikasi
seperti apa yang diperlukan pengguna untuk
menjalankan program anda.
3. Anda: Apakah anda akan membuat program
secara mandiri atau dengan bantuan orang
lain?, jika dengan bantuan orang lain maka
bagian mana yang akan dikerjakan anda dan
mana yang akan dikerjakan orang lain.
Portable
Yaitu jika anda dapat
mengkopi dan
menjalankan program
komputer pada komputer
lainnya dengan sedikit
atau tanpa modifikasi.
C/C++
“cross-platform”
compilerprogram
Pengguna program komputer
Jika hanya anda yang menggunakan program buatan
anda, maka anda dapat membuat tampilan program
sesuai dengan yang anda inginkan, yang terpenting anda
dapat membuatnya bekerja. Akan tetapi jika program
buatan anda akan diberikan atau dijual pada orang lain
maka anda perlu tahu siapa yang akan menggunakanprogram anda.
Target Komputer
Tipe komputer yang akan digunakan dapat sebagai penentu
bahasa pemrograman yang dapat digunakan, perangkat
keras yang akan digunakan program dan ukuran maksimaldari program.
Keahlian dalam membuat program (Programming Skill)
Experienced programmers C or C++
Novices BASIC C or C++
Programming skillTarget yang utama adalah untuk
menyelesaikan program anda sehingga anda
dapat mulai menggunakannya dan jika
mungkin menjualnya pada orang lain.
Detai teknis dari menulis bahasa pemrograman
Membuat purwa-rupa (Prototyping)
Memilih bahasa pemrograman.
Menentukan bagaimana program akan bekerja.
Purwa-Rupa
Arsitek
Sebuah model
pesawat dalam
skala di
terowongan udara
saat akan diuji.
Memilih bahasa pemrograman
PrototypingMemilih sebuah
bahasa
pemrograman.
Pilihan bahasa pemrograman yang akan
digunakan antara satu orang dengan orang lain
dapat berbeda. Meskipun anda tidak dapat
menemukan sebuah bahasa pemrogrman yang
“sempurna” untuk segala keperluan, tetapi anda
dapat menggunakan bahasa pemrograman lainnya
yang beredar. Dan pastinya tidak akan ada yang
peduli bahasa apa yang akan anda gunakan
selama program anda bekerja dengan baik.
Seorang pembuat program tidak hanya membuat prototype dari tampilan antar muka
dari progrmanya, akan tetapi juga membuat prototype intruksi yang menjelaskanbagaimana sebuah program bekerja, berikut contohnya:
Menentukan bagaiman program akan berjalan.
Detect Flaws
Pseudocode:
Detect Flaws
Top-Down Design: Yaitu jika seorang pembuat program menentukan langkah-langkah
umum yang diperlukan program untuk dijalankan dan kemudian memperbaiki tiap langkah
secara detil.
Pseudocode: Merupakan sebuah metode yang dapat anda gunakan sebagai garis besar
dari struktur program anda. Fungsi dari metode ini adalah untuk melihat segala
kemungkinan data yang dibutuhkan program dalam rangka menyelesaikan tugasnya.
Cara kerjanya yaitu dengan menjelaskan langkah demi langkah sehingga anda
dapat mengetahui alur dari program anda sebelum ditulis dalam bahasa
pemrograman dan bisa menggunakan bahasa apapun.
Menetukan bagai mana sebuah program bekerja
1. Muncul sebagai gagasan untuk sebuah program.
2. Menentukan kemungkinan pengguna sebuah program tersebut.
3. Menentukan komputer yang akan digunakan.
4. Menggunakan satu atau beberapa bahasa pemrograman.
5. Mendesain program dengan menggunakan pseudocode atau metode lainnya
untuk menghasilkan garis besar dari struktur program.
6. Menulis program.
7. Menguji program
Langkah ini dikenal sebagai uji alfa (alpha testing).
8. Memperbaiki segala permasalahan yang ditemukan saat uji alfa.
Mengulang langkah ke 7 dan 8 sesuai kebutuhan.
9. Menggandakan program untuk dicoba oleh orang lain.
Langkah ini dikenal sebagai uji beta (beta testing).
10. Memperbaiki segala permasalahan yang ditemukan saat uji beta.
Ulang langkah 9 dan 10 sesuai kebutuhan.
11. Terbitkan program anda pada pengguna yang objektif dan berharap agar
tersebar seperti iklan.
Siklus Hidup (Life Cycle) dari sebuah program
Proses pengembangan:
Menjaga siklus
1. Periksa segala laporan permasalahan (bugs)yang diterima dan tentukan bagian
dari program mana yang harus diperbaiki.
2. Perbaiki bug.
3. Uji program tersebut untuk memastikan bug benar-benar sudah hilang dan
pastikan juga perubahan yang sudah dibuat tidak menghasilkan bug baru
4. Perbaiki segala permasalahan yang muncul saat pengujian.
5. Ulangi langkah 1 sampai 4 untuk tiap bug yang sudah dilaporkan pengguna
program.
6. Terbitkan software patch, yang dapat digunakan pengguna untuk memperbaiki
versi perangkat lunak yang lama.
Siklus peningkatan (upgrade cycle)
Kebanyakan perusahaan tidak menghasilkan uang dari memperbaiki perangkat lunak
yang sudah ada dan membuatnya lebih stabil, handal, dan kokoh. Akan tetapi
perusahaan menghasilkan uang dengan menjual versi baru dari program yang
menawarkan menu tambahan.
1. Menentukan menu baru yang ingin ditambahkan pada program.
2. Merencanakan bagaimana menu baru tersebut bekerja (dengan pseudocode
atau metode lain untuk menstrukturkan gagasan anda)
3. Ubah program agar dapat menerima menu baru tersebut.
4. Uji menu baru tersebut (dengan uji alfa) untuk memastikan dapat berjalan dan
tidak menghasilkan bugs baru didalam program.
5. Perbaiki segala permasalahan yang muncul saat uji alfa.
6. Lakukan uji beta.
7. Perbaiki segala permasalahan saat uji Beta.
8. Ulangi langkah 1 sampai 7 untuk tiap menu baru yang anda terbitkan untuk
program anda.
9. Terbitkan program sebagai versi baru dan tunggu reaksi masyarakat untuk
mengetahui bugs yang mengganggu kinerja program sehingga dapat dilakukan
maintenance cycle lagi.
“Despite all the university courses and such important-sounding titles as “software
engineer,” programming is still less of a science and more of an art. Writing, modifying,
and updating software doesn’t require a high IQ or an advanced mathematics degree as
much as it requires creativity, determination, and plenty of imagination. You can write a
program any way that you want, but the best way to prevent possible problems later on is
to be organized and methodical in your approach.”
The Tools of a Computer ProgrammerYou need the following two crucial tools to write a program:
An editor (so that you can write your instructions to the computer).
A compiler which converts your instructions into machine language so that the
computer knows what you want it to do. Instead of using a compiler, many
programming languages use an interpreter. The main difference between the two is
that an interpreter converts your instructions into machine language and stores them
in memory each time you run the program, whereas a compiler converts your
instructions into machine language once and saves those instructions in a file often
called an EXE or executable file.
A debugger (which helps identify problems or bugs in your program).
A Help file authoring program (so that your program can provide Help on-screen instead of
needing to supply the user with a decent manual).
An installation program (to copy your program to the user’s computer).
If you buy a specific programming language, such as Visual Basic, Delphi, or Real Basic,
you usually get an editor, compiler, and a debugger, which means you just need to buy a
separate Help file authoring program and an installation program.
Writing Programs in an Editor
text (or ASCII) file
An ASCII file consists of nothing but characters that you can type from a keyboard. ASCII
stands for American Standard Code for Information Interchange, which is simply a
universal file format that any computer can use.
Rather than struggle with a word processor, programmers created special programs for
writing, editing, and printing the source code of a program. Almost no one writes a
program correctly the first time, so the majority of a programmer’s time is spent editing the
source code. As a result, the program that enables you to write, edit, and print a program
is known as an editor.
Using a Compiler or an Interpreter
A compiler takes your source code, converts the entire thing into machine language, and
then stores these equivalent machine language instructions in a separate file, often known
as an executable file. The process is like having a translator study an entire novel written in
Spanish and then translate it into Arabic.
Whenever a compiler converts source code into machine language, it’s compiling a
program.
A second, but less popular, way to convert source code into machine language is to use an
interpreter. An interpreter converts each line of your source code into machine language,
one line at a time. The process is like giving a speech in English and having someone
translate your sentences, one at a time, into another language (such as French).
You can actually decompile any program, including programs that you compile into machine
language. But unlike with decompiling p-code programs,decompiling a machine-language version
of a program never gets you theoriginal high-level language source code that the programmer
used to write the program. If you compile a program into machine language, the original source
code can be written in C++, COBOL, FORTRAN, BASIC, Ada, LISP, Pascal, or any other
programming language in the world. Because the decompiler has no idea what language the
original source code was written in, it can only decompile a machine-language version of a
program into equivalent assembly
language. After you decompile a program into assembly language source code, you can rewrite or
modify that source code. Decompiling effectively allows you to steal the ideas of others.
Bugs & Debugger
A problem that keeps a program from working correctly is known as a bug.
A debugger is a special program (which may also contain bugs) that can help you track down and
wipe out bugs in programs that you write.
A debugger provides several ways to track down bugs in your program:
• Stepping
• Breakpoints
• Watching
A debugger essentially shows you exactly how a computer is going to interpret the instructions in
your program. Of course, if you fix one bug, you may introduce several new ones. That’s why
writing bug-free programs is impossible.
Similarly, the problem with computer programs is that programs are too complex to use at first
glance. If you can make a program that’s actually easy to use, people can actually use it.
Help File
A Help file provides instructions and explanations on-screen. Theoretically, if the user
experiences trouble with the program, he can browse through the Help file, find an
explanation or step-by-step instructions, and continue using the program.
After you write your program, test it, debug it, and write a Help file for it, the final step is to
give or sell copies of your program to others. Although you can copy your program onto a
floppy disk or CD and force buyers to manually copy your program to their hard drive, doing
so can cause problems. Users may not copy all the files correctly, for example. And forcing
users to manually copy your program to their hard drive may prove such a nuisance that most
people don’t bother even trying to use your program.
Creating an Installation Program
Installation programs offer the following features for distributing programs to others:
File compression: Most programs are fairly large, which means that they can’t fit on a single
floppy disk. Rather than force users to insert a series of floppy disks or compact discs (CDs)
into their computer to install your program, an installation program smashes your files so that
they can fit on as few floppy disks or compact discs as possible.
Display graphics and play sounds: Installing a program usually takes a few minutes while
the computer copies files from the floppy or CD to its hard drive. Rather than force the user to
stare into space, an installation program can display advertisements or messages to make the
installation process mildly interesting. Other uses for graphics include displaying an hourglass
icon or a status bar that shows how far the installation is complete, such as 54 percent
complete. That way, users know how much longer they need to wait.
Simplify the copying process: Most important, an installation program simplifies copying
your program to the user’s hard drive, making the entire process accurate, fast, and foolproof.
The first impression that people get from your program is through its installation
process, so an installation program helps give your program a professional appearance.
Of course, you need to make sure that your installation program installs your program correctly
or the first impression that users get from your program will be a highly negative one.
Mengolah Number dan String
Penjumlahan, Pengurangan, Pembagian dan Perkalian
2.)
Menggunakan Variabel:
1.)
3.)
Precedence
Exponentiation (^)
Multiplication (*) and (^); division (/)
Addition (+) and subtraction (–)
Parentheses
Mathematical Functions
Memanipulasi Strings
String adalah apa yang anda bisa ketik dari papan ketik, termasuk huruf, simbol (seperti #, &,
and +), dan angka.
Mendeklarasikan variables sebagai strings
Memasukkan spasi:
Repeating Yourself with Loops
programmerscomputer to do
as much as possible
do as little as possible
• small programs are
easier to debug and
modify
• smaller programs require less typing.
loops
“Loops make the computer do more without forcing you to typeadditional instructions.”
make sure that you write
a comment in the
program to
explain exactly what you
expect the loop to do.
• a condition• Boolean expression
WHILE-WEND Loop
Endless
loopfreeze on-screen
WHILE-WEND
To repeat one or more
instructions, you just
sandwich them
between the WHILE and WEND commands
1. The first line creates the variable I and sets its value to 1.
2. The second line tells the computer that a loop is starting and that the computer is to run the instructions
between the WHILE and WEND commands as long as the Boolean expression I < 5 is true.
3. The third line tells the computer to print The square of 1 is 1 the first time that the WHILE-WEND loops runs
and The square of 2 is 4 the second time that the WHILE-WEND loop runs, and so on.
4. The fourth line tells the computer to add one to the value of the variable I, so now I represents the number 1
+ 1, or 2.
5. The fifth line tells the computer to check whether the Boolean expression I < 5 is true. If it’s true, the
program skips to the sixth line. If it’s not true (if I represents the number 1, 2, 3, or 4), the program returns to
the top of the loop on the second line. The computer repeats the loop four times.
1
2
1
2 In this example, the value of variable I is
always set to one (1) at the beginning of the
WHILE-WEND loop and then gets
incremented to two (2) at the end of the
WHILE-WEND loop. But each time the
WHILE-WEND loop runs, the value of I is
reset to one (1) so the Boolean expression I
< 5 always remains true, and thus the loop
never ends.
This loop never stops because the value of I
never changes. Thus the Boolean
expression I < 5 always remains true, so the
WHILE-WEND loop keeps running the
instructions between the WHILE and WEND
commands. In this case, the program just
keeps printing, This loop never ends.
1
2
AdvancedProgramming
Writing Large Programs by Using Subprograms
Programming is not so much a hard science as it is a
creative art form. The ultimate goal of programming is to
write the smallest possible program that uses the least
amount of computer resources (memory, hard drive space,and so on) while accomplishing as much as possible.
spaghetti coding
spaghetti coding
Structured Programmingto write programs well organized
The main idea is to
organize your program by
using only three types of instructions
Sequential instructions
Branching instructions Looping instructions
Sequential instructions
The simplest way to organize instructions in a program is to place them sequentially, or one after another, as in the following example:
“Branch”
Branching instructions
Provide two or more different instructions for the computer to follow, based on a certain condition.
Looping instructions
Sometimes the computer may need to repeat certain instructions. Rather than type the same instructions over and over, you can use a loop,
The reason for organizing your program in chunks of sequential,
branching, and looping instructions is to make how your program
works easier for others to understand. If they can understand howyour program works, they can modify and improve on it later.
Writing programs that are easy to understand is crucial for your own
benefit and for the benefit of any other programmer whose job is to fix ormodify programs that you write.
Modular Programs
In the computer world, little programs that make up part of a larger program are
known as subprograms. Subprograms are also known as modules, hence theterm modular programming.
Every modular program contains at least one subprogram, known as the main
program. The main program usually does nothing more than tell the computerwhich subprograms to use next to accomplish a specific task.
Modular Programs
Programmers use subprograms for the following two reasons:
To make writing large programs easier
To store repetitive instructions in a single location
The main advantage of breaking a large program into subprograms is so that you can
easily modify a large program just by modifying one or more of its smaller
subprograms. Because small programs are easier to understand and modify thanlarge ones, subprograms can help make your program more reliable.
Modular Programs
Modular Programs
Modular Programs
Subroutines
Exiting prematurely from a subroutine
Functions
Exiting prematurely from a function
Functions
Passing Data by Value or by Reference
By Value
Passing Data by Value or by Reference
By Ref
Algorithms
Algorithms Telling the Computer What to Do?
A program is nothing more
than a list of instructions, but
you can create instructions in
various ways to tell the
computer how to perform the same task.
In the world of computer
programming, a specific
way to accomplish a task is
known as an algorithm.
By choosing the fastest set
of instructions (the
algorithm), you can make
your program faster and
more efficient
There are several
common algorithms for
accomplishing different
tasks
Sorting
Searching
Optimizing Code
Data
A database is fairly useless if it
enables you to store information
without enabling you to do
anything to rearrange that
information. To sort the
information as
quickly as possible
Part of computer science centers
on studying and developing the
most efficient sorting methods
known as sorting algorithms.
sorting algorithms
sorting algorithms
The insertion-sort algorithms
The bubble-sort algorithms
The shell-sort algorithms
The quicksort algorithms
The variety of methods that
programs can use to sort data
Insertion sort is best for small
lists.
Bubble sort is best for lists that
are already almost sorted.
Quicksort is usually fastest for
everyday use.
To speed up either insertion sort or
bubble sort, consider combining the
shell-sort algorithm with either
insertion sort or bubble sort.
Searching for data is the second
most common activity (after sorting
data) necessary for creating many
types of programs.
SearchingTo make searching easier,
programs usually sort the data
first before trying to search it.
For more information about
sorting,
Sequential searching for small lists or unsorted lists.
Binary searching for larger, sorted lists.
Hashing for large amounts of data, but it’s more complicated to
implement because you need to calculate a hash function.
Binary search
Hashing
Much faster than sequential
and binary searching,
especially for long lists of
data.
A sequential search examines every
possible item in a data structure (such as an array or
linked list) until it finds what it’s looking for. This type of
search is like looking for your car keys in your apartment
by going through room by room, looking in every
conceivable location until you find your car keys
Data Structure
a heap
a library
“To help organize the computer’s memory, programs storedata in something known as a data structure”
“A more complicated data structure comprisesarrays, records, linked lists, and objects”
Data structures play a central role in modern computerscience. You interact with data structures even more oftenthan with algorithms (think Google, your mail server, and evenyour network routers). In addition, data structures areessential building blocks in obtaining efficient algorithms.-http://ocw.mit.edu/
Arrays?
Store data temporarily
Variable name Type of data
clumsy
Arrays Solution
A name.
A data type that defines the only type of data that the array can hold, such as strings or
numbers.
A number that defines how many elements the array can hold. (A single element can hold one chunk of data.) This number is sometimes known as the array index.
Arrays
Multidimensional Array
Dynamic Arrays Static Array
A static array is a fixed size and poses the following two potential problems: After you define the array size, you can’t
change the array size later to make it smaller (if you make the array too big) or larger (if you make the array too small).
A static array always requires a certain amount of memory, regardless of whether the array contains any data or is empty.
Resize
Completely erase
Specific commands
Struktur Dasar Algoritma
AlgoritmaMerupakan deskripsi langkah-langkah pelaksanaan suatu proses. Pernyataan (statement) Aksi (action)Contoh: Tulis “Hello World”
Menggambarkan pernyataan aksi untuk menulis pesan “Hello World” Kalikan a dengan 3
Menggambarkan aksi mengalikan a dengan 3 dan biasanya hasil perkalian disimpan di dalam peubah a lagi.
Jika bulan = ‘Januari’ maka tulis “jumlah hari = 31”Menggambarkan dua aksi, membandingkan nilai variable bulan dengan ‘januari’, danaksi tulis pesan ‘jumlah hari = 31’ jika perbandingan itu benar.
AlgoritmaKontruksi Dasar: Langkah-langkah penyelesaian masalah:
Runtunan Aksi Pemilihan Aksi Pengulangan Aksi.
Struktur Dasar: Runtunan (sequence) Pemilihan (selection) Pengulangan (repetition).
AlgoritmaRuntunan (sequence): Terdiri satu atau lebih pernyataan. Tiap pernyataan ditulis dalam satu baris atau
dipisahkan dengan titik koma. Tiap pernyataan dikerjakan secara berurutan. Urutan intruksi menentukan keadaan akhir
algoritma. Runtunan satu atau lebih pernyataan
dinamakan pernyataan-gabungan (compound statements).
Contoh:Algoritma mempertukarkan isi dua buah ember, A dan B:1. Tuangkan air dari ember A ke dalam ember C.2. Tuangkan air dari ember B ke dalam ember A.3. Tuangkan air dari ember C ke dalam ember B.
Contoh:Masukkan nilai A ke dalam BMasukkan nilai B ke dalam A
Masukkan nilai A ke dalam CMasukkan nilai B ke dalam AMasukkan nilai C ke dalam B
AlgoritmaPemilihan:Contoh
Jika lampu traffic light berwarna merah, maka berhenti.
Dapat ditulis dalam pernyataan-pemilihan(selection statement)
Pernyataan-kondisional.If kondisi then
aksi
Menentukan nilai terbesar dari dua buahbilangan bulat, x dan y:If x > y then
tulis nilai xElse
tulis nilai yMenentukan bilangan x adalah bilangan genapatau ganjil:If x habis dibagi 2 then
tulis “genap”Else
tulis “ganjil”
AlgoritmaPengulangan: Kelebihan komputer adalah kemampuanmengerjakan pekerjaan yang sama berulang kali tanpa kenal lelah.
Repeat N Times Aksi
Contoh:Algoritma tulis kalimat 100 kali:
repeat 100 times
Tulis “Saya berjanji
akan mengerjakan
tugas dan tidak malas
lagi”
For i from 1 to N doAksi
Contoh:Algoritma tulis kalimat 100 kali:For i dari 1 sampai 100 do
Tulis “Saya berjanji akan
mengerjakan tugas dan tidak
malas lagi”
Repeat aksi
Until kondisiContoh:Algoritma tulis kalimat 100 kali:repeat
Tulis “Saya berjanji akan
mengerjakan tugas dan tidak
malas lagi”
Until sudah 500 kali
Algoritma
NIM Nama Alamat Telepon
125060207111011 Rizky Ahmad Jl. MT Haryono 3 879967
125060207111023 Roni Siahaan Jl. Veteran 4 345676
… … … …
125060207111035 Budi Prayitno Jl. Kenanga 14 876435
AlgoritmaTinjau entry pertama di dalam tabelIf NIM pada entry tabel sama dengan NIM yang dicari then
ambil Alamat dan Telepon dari NIM tersebutelse
tinjau entry berikutnya di dalam tabelIf NIM pada entry tabel sama dengan NIM yang dicari then
ambil Alamat dan Telepon dari NIM tersebutelse
tinjau entry berikutnya di dalam tabelIf NIM pada entry tabel sama dengan NIM yang dicari then
ambil Alamat dan Telepon dari NIM tersebutelse
tinjau entry berikutnya di dalam tabel…..
Algoritma
ALGORITMA pencarian data di dalam tabel:baca NIM yang dicari {misalkan NIM = X}tinjau entry pertama tabelrepeat
if NIM pada entry tabel sama dengan X then tulis Alamat dan Telepon dari NIM X tersebut
elsetinjau entry berikutnya di dalam tabel
until NIM yang dicari sudah ditemukan atau akhir tabel sudah terlampaui
Repeat - Until
Algoritma
ALGORITMA pencarian data di dalam tabel:baca NIM yang dicari {misalkan NIM = X}tinjau entry pertama tabelwhile NIM yang dicari belum ditemukan dan akhir tabel belum terlampaui do
if NIM pada entry tabel sama dengan X then Ambil Alamat dan Telepon dari NIM tersebut
elsetinjau entry berikutnya di dalam tabel
While kondisi doaksi
Assembly language
Why So Many Different Programming Languages?
Each language serves a specific purpose, and people
are always creating new languages to solve different types of problems.
Computers really understand only one language machine language
Machine language has the following two major drawbacks:
You can easily type a 0 or 1 by mistake, thereby
preventing you from giving the computer the correct
instructions.
Machine language takes a long time to write (and an
even longer time to understand what the language is
actually telling the computer to do).
assembly language
The joy of assembly language
To write programs faster and
easier than using machine language.
Assembly language uses short,
easy-to-remember (to
programmers, that is) phrases.
Ex: JMP, MOV, and ADD
makes the code easier to read
and modify later
Making programs easy to read and modify is crucialbecause most programs never work right the first time
you use them. And if you want to add new features to a
program later, you need to understand how the currentprogram works so that you know how to modify it.
Assemblers
Special programs that translate
assembly language into machine language.
Assembly language machine code,
Language for their convenience only
Assembly language programs are
easier to read than machine language
programs.
Assembly language programs are
easier to write (and modify) thanmachine language programs.
Disadvantages:
Programs that you create by using assembly
language run slower and gobble up more space
(both physical disk space and memory) than
equivalent programs that you may create with
machine language.
You can’t easily transfer (or, to use programming
lingo, port) a program that you write in assembly
language for one computer to another computer.
Writing a program in assembly language can
prove extremely tedious, time-consuming, and
complicated. That’s why few people bother towrite large programs in assembly language.
In general, the easier the programming language
is to read and write, the slower and larger are the
programs it creates. The Holy Grail of computer
programming is to create programs that are easy
to write, run as fast as possible, and take up aslittle space as possible.
C: The portable
assembler
COBOL andFORTRAN
Programmers felt that they needed a
language that offers the power to
access hardware (as does assembly
language) but is easier to read, write,
and modify (as are COBOL and
FORTRAN). Eventually, they
invented a programming language
known simply as C.
C programs
assemblylanguage code
machine
language code
less efficient
easier to
read, write & modify
readability
for speed and size
To create a language that’s easier to
read and write than assembly
language.
To offer programmers the capability to
access all the parts of the computer
just as they can by using assembly
language.
To provide a small, simple language
that you can easily port from one
computer to another. Programs that
you write in C can run on different
computers without massive rewriting,
which is the main drawback with
assembly- and machine-languageprograms.
C programming language
three main goals Computer C
assembly language
ConvertC program
compilers
Machine Language
Special Program
Write C program for the Macintosh,
copy it to a computer running Windows
XP, recompile it, and run the program
with little or no modification.
C portability one of the most popular
programming languages in
the world
C++
Windows
95/98/Me/NT/2000/XP,
Unix, and Linux
Quicken, Netscape
Navigator, and
Microsoft Word.
C creates larger and slower programs than
equivalent assembly or machine-language
programs.
The C language gives programmers access to all
parts of a computer, including the capability to
manipulate the computer’s memory.
Unfortunately, all this power can prove as
dangerous as giving a hyperactive monkey a
chainsaw and a hand grenade. If you don’t write
your C programs carefully, they can accidentally
wreck your computer’s memory, causing your program to crash your computer.
C / C++ Flaws
Assembly language
Motorola MC6800 Assembly listing, showing original
assembly language and the assembled form
http://www.tutorialspoint.com/assembly_programming/ http://www.swansontec.com/sprogram.html http://www.computerhope.com/jargon/a/al.htm http://www.techopedia.com/definition/3903/assembly-language etc.
Assembly language
http://www.webopedia.com/TERM/A/assembly_language.html
Assembly language
www.edsim51.com/