Title: Delphi
1Delphi
- Jon Krueger
- Matt Merkel
- Jack Neil
2Overview
- Paradigm and problem domains
- Language concepts
- Sample code
- The history of Delphi
- Language Comparison
3Paradigm and problem domains
- Delphi follows a imperative and OO model
- The word Imperative come from Latin and means to
command. - In imperative languages commands update
variables. - Builds directly on what happens at the hardware
level.
4Paradigm and problem domains
- Delphi follows a imperative and OO model
- You can look at data structures in terms of
states. - The program is a means to manipulate the states.
- Variables are used in imperative programming to
hold intermediate results of computation. - Other major imperative languages include
- Fortran, Basic, COBOL, Algol, PL/1, Modula,
- C, Ada, Perl
5Paradigm and problem domains
- Delphi follows a imperative and OO model
- Object-Oriented languages are imperative, but
considered part of a different paradigm. - Delphi is object-oriented
- Inheritance (single)
- Polymorphism
- Encapsulation
6Delphi concepts
- Classes (single inheritance)
- Interfaces (similar to java)
- Exception handling
- Built-in support for Unicode strings and
single-byte ANSI strings - Very fast compiler and optimizer
- Compiles to native x86 code.
7Delphi concepts
- Values and types static, strong, standard
primitives (char, real, integer, boolean),
enumerated, composite (arrays, records, sets)
8Delphi Features
- Delphi and C Builder IDE
- GUI Builder drag and drop
- Source editor
- Debugger
- No runtime environment required to execute Delphi
object code.
9Delphi Structure
- Program Control
- Keywords
- Begin // starts a statement block
- End // terminates a statement block
- Exit // exit abruptly from a function or
procedure - Halt // terminates the program with an optional
dialog - Try // starts code that has error trapping
- Uses // declares a list of units (modules) to be
imported - Var // starts the definition of a section of data
variables
10Delphi Structure
- Some routines provided with DELPHI
- Erase // Erase a file
- FileSearch // Search for a file in numerous
directories - FileSetDate // Set the last modified date and
time of a file - Flush // Flushes buffered text file data to the
file - Truncate // Truncates a file size
- TStringList // A class provided with DELHPI that
has methods for loading and writing a list
of strings from a text file
11Delphi Example
- Reading and writing files
- var
- myFile TextFile
- begin
- AssignFile(myFile, Test.txt)
- ReWrite(myFile) //Opens file as new discards
- existing contents
- Append(myFile) //Opens file for appending new
data - to end
- Reset(myFile) //Opens a file for read and
write - access
12Delphi Example
13Unit Stringy interface type TString Class
private stText String stWordCount
Integer stFindString String
stFindPosition Integer procedure
GetWordCount procedure SetText(const Value
String) published constructor Create(Text
String) function Replace(from, toStr
String) Integer function FindFirst(search
String) Integer function FindNext
Integer property Text String
read stText write SetText property
WordCount Integer read stWordCount end
14//continuation of last slide implementation uses
SysUtils, StrUtils constructuror
TStringy.Create(Text String) begin
stText Text stFindPosition 1
stFindString GetWordCount end
procedure TStringy.SetText(const Value
String) stText Value stFindPosition
1 GetWordCount end //other methods
here
15unit Main uses Windows, Messages, SysUtils,
Variants, Classes, Graphics, Controls, Forms,
Dialogs, Stringy type TForm1 class(TForm)
procedure FormCreate(Sender TObject)
private Private declarations
public Public declarations end var
Form1 TForm1 procedure TForm1.FormCreate(Sender
TObject) var myText TStringy count
integer position integer
16//continuation of last slide begin myText
TStringy.Create(The cat in the hat)
myText.Text There was a cat end end.
17History of Delphi
- Delphis predecessors date back to as early as
1968 - In 1968, a man named Niklaus Wirth began work on
a programming language called Pascal, which he
completed in 1970 with its first working
implementation appearing on a CDC6000 Computer
18The Evolution of Pascal
- In the 1970s, Wirth worked with Jensen on Modula,
the next child of Pascal - In the very early 1980s, Turbo Pascal was born,
and received good press for its excellent
compilation and execution speed
19Delphi Is Born
- In the 1990s, a project began at Borland with the
Greek Mythological code-name Delphi - Borland liked the code-name enough to actually
use it as the product name - 1995, Borlands Delphi was introduced as an
Object-Oriented version of Turbo Pascal
20Delphis Market
- Delphis main asset was its speed, both in
compilation and execution (just like Turbo
Pascal) - Designed specifically for RAD (Rapid Application
Development) - Ideal for anything from Business and Database
applications to intensive application development
21Comparison of Delphi
- Delphi is most closely related to Visual Basic
more than any other programming language - Delphi incorporates Object-Orientation but Visual
Basic is much more like traditional Basic in the
fact that, it is not Object-Oriented
22Comparison of Delphi
- Memory management weighs in Delphis favor
because the programmer has more freedom in
managing objects, such as removing them when they
are no longer needed, instead of waiting on a
garbage collector. - Delphi is also broader in the sense of what types
of applications it can be used for, whereas
Visual Basics main applications include only
business and database applications
23Comparison of Delphi
- Lower (hardware and time) cost of execution than
Visual Basic - Visual Basic tends to be easier to learn for
someone who is not agile or experienced with
programming - Visual Basic is more commonly used
- New programmers are taught Visual Basic
24References
- A comparison between Delphi and Visual Basic
- lthttp//www.latiumsoftware.com/en/articles/00010.
phpgt - Borland History Why the name "Delphi?"
- lthttp//community.borland.com/article/0,1410,203
96,00.htmlgt - Delphi Basics A brief history of Borlands
Delphi - lthttp//www.delphibasics.co.uk/Article.asp?Name
DelphiHistorygt - Delphi Basics
- lthttp//www.delphibasics.co.ukgt