Presentation is loading. Please wait.

Presentation is loading. Please wait.

Compiling vs. Interpreting We write source code that a translating program changes into machine language. There are two kinds of translating programs,

Similar presentations


Presentation on theme: "Compiling vs. Interpreting We write source code that a translating program changes into machine language. There are two kinds of translating programs,"— Presentation transcript:

1 Compiling vs. Interpreting We write source code that a translating program changes into machine language. There are two kinds of translating programs, compilers and interpreters. Compilers take the entire source code program and change it into machine language. Only after the source code is translated in its entirety can the computer execute the program. Interpreters translate and execute each line, one at a time. If an error is encountered, the program stops at that point. Örnekler: –Compiled (C, C++, Pascal) –Interpreted (Basic, Visual Basic, JavaScript, VBScript) –Compiled+Interpreted (Java)

2 Derleme Hakkında Daha Fazlası

3 Benefits of Compiling Protection of Intellectual Property Speed Increased Functionality –Ability to create an advanced interface –File handling –Access to peripheral devices –Ability to be integrated into the operating system –Advanced memory and CPU resource handling –Advanced graphics handling Security –Steal information –Cause damage –Steal system resources Debugging

4 Notice how a few lines of source code translates into many, many lines of instructions in the end application. Five lines of code is translated into hundreds of lines of instructions in the final output. Why? Writing code actually involves a lot of work behind the scenes that really isn’t covered in the few lines of code you typed. So, most of the code that you type just consists of shorthand notation for the compiler to create code and insert it in the application.

5 Are All Compilers the Same? (Örneğin C++ için) Borland C++ Compiler 5.5 Digital Mars C++ Compiler DJGPP C++ Compiler

6 Are All Compilers the Same? (Örneğin C++ için) Borland C++ Compiler 5.5 Kurulum Kullanım bcc32 c_test.cpp c_test.exe Derleme Hızı Der. Boyutu: 113,152 byte (110KB) Makine kodu seviyesinde farklılıklar Hata Mesajları D:\Prog>bcc32 calcerr.cpp Borland C for Win32 Copyright (c) 1993, 2000 Borland calcerr.cpp: Error E2379 calcerr.cpp 23: Statement missing ; in function main() *** 1 errors in Compile *** Digital Mars C++ Compiler Kurulum Kullanım dmc c_test.cpp c_test.exe Derleme Hızı Der. Boyutu: 49,692 byte (49KB) Makine kodu seviyesinde farklılıklar Hata Mesajları D:\dmbin>dmc calcerr.cpp if (op == 83) ^ calcerr.cpp( 23) : Error: ‘;’ expected following declaration of struct member --- errorlevel 1

7 Commenting Code Commenting code is the process of leaving cues as to what the code means within the actual code itself. These comments can be for yourself or for other programmers who will look at your code. Comments are not read by any compiler or interpreter while processing code — they are there entirely for the benefit of humans reading the code. They are also a great way to remove lines of code that are causing trouble or are no longer needed without actually having to physically remove them.

8 Örnekler Basic REM This is a comment. Visual Basic ' This is a comment. REM This is a comment. VBScript ' This line is a comment. JavaScript // Comments go here. C++ // Single line comment /* Multiline comments Look like this */ Pascal {This line is a comment.}

9 Tombstone Comment Appears at the beginning of the code to give a rundown of what the code does. ' Widget ' Author: A. N. Other ' ' ' Code starts below /* C++ Project Widget Author: A. N. Other Code starts below. */

10 Drama Etkinliği 1 Kullanıcı 1 Program Problem: Kullanıcı tarafından girilen 3 sayının toplanarak sonucun kullanıcıya iletilmesi

11 Değişkenler Variables are the cornerstone of most programming because they allow you to work with and manipulate data. A location in memory that can be referenced and accessed. A named placeholder for data that you can reference.

12 An empty, null, variable is like a bucket or basket waiting to be filled —waiting to be given purpose. When you load a value into a variable, this is called initializing the variable

13 The variable can hold data of all kinds Data Type: Text strings Numbers –Floating point –Tam sayı Boolean Örnek: "Metin dizisi" True ya da False

14

15 The great thing about variables is that they are very versatile. You can easily change what the variable holds. There are three main methods of getting values into variables: – Read in a value from a file – Ask the user to type in a value – Assign a value within the program

16 Değişkenlerin Deklarasyonu In some languages when you first use a variable you need to define it explicitly before using it, after which you can use it without doing so.

17 Naming Variables Don’ts –Variable names cannot contain numbers at the beginning –Variable names cannot contain arithmetic operators –Variable names cannot contain punctuation –Variable names cannot consist of a keyword or reserved word that applies to the language –Variable names cannot contain a space

18 Naming Variables Do’s –Variables can contain numbers as long as they aren’t at the beginning –Underscores are allowed in variable names –Variables can contain mixed case

19 Naming Variables – Good Practice Clear Naming z = x * y totalvalue = subtotalprice * taxrate Capitalization totalvalue = subtotalprice - taxrate TotalValue = SubTotalPrice - TaxRate totalValue = subTotalPrice – taxRate Use Underscores totalValueBeforeTax totalValue_ Before_ Tax cpuCoreTempCelsius cpuCore_ Temp_ Celsius minFileSizeMb minFile_ Size_ Mb

20 Naming Variables Naming Notation (Hungarian Notation) –The purpose of Hungarian Notation was to bring order to the chaos of creating and representing variable names. It works by prefixing the name of the variable with letters that identify the type of information the variable holds. stringUser_ Name

21 Strings A string is a sequence of two or more characters. A string can contain –alphanumeric characters (letters and numbers) –Whitespace –symbols (such as punctuation) Örnek: var strTest_ String1 = "Hello, World!" var strTest_ String2 = "123xyz" var strTest_ String3 = "[*^£/"

22 Joining Strings (Concatenation) + operator


Download ppt "Compiling vs. Interpreting We write source code that a translating program changes into machine language. There are two kinds of translating programs,"

Similar presentations


Ads by Google