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:
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
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.
Are All Compilers the Same? (Örneğin C++ için) Borland C++ Compiler 5.5 Digital Mars C++ Compiler DJGPP C++ Compiler
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++ 5.5 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
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.
Tombstone Comment Appears at the beginning of the code to give a rundown of what the code does. ' Widget 1.0.2 ' Author: A. N. Other ' 22-10-04 ' ' Code starts below /* C++ Project Widget 3.1.9 Author: A. N. Other 22-10-04 Code starts below. */
Drama Etkinliği 1 Kullanıcı 1 Program Problem: Kullanıcı tarafından girilen 3 sayının toplanarak sonucun kullanıcıya iletilmesi
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.
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
The variable can hold data of all kinds Data Type: Text strings Numbers –Floating point –Tam sayı Boolean Örnek: "Metin dizisi" 3.1515 3 True ya da False
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
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.
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
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
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
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
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 = "[*^£/"