1. Trang chủ
  2. » Công Nghệ Thông Tin

programming language fortran

31 177 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 31
Dung lượng 275 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Programming Languages• Machine code can be represented as as series of binary digits or bits.. machine code, assembley language – High level... • Three steps: – Compile – translate to o

Trang 1

Programming language Portran

• Programming skills are not essential, but they are useful for:

– Special data processing;

– Customisation

Trang 2

• The processor (or CPU) can be thought of as the ‘heart’ of

the computer as it controls the flow of information around the system

• The processor requires instructions telling it what to do

These are provided by the operating system (OS).

• All instructions to the processor are in machine code.

Trang 4

Programming Languages

• Machine code can be represented as as series of binary

digits (or bits).

• Bits are normally organised in groups of 8 called bytes.

• Machine code is unintelligible to most humans, so

instructions are normally provided using a language which can be translated into machine code

• Languages can be:

– Low level (e.g machine code, assembley language)

– High level

Trang 5

• It can take a lot of steps to do even simple things For

example, the following adds two single byte numbers

together in 6502 assembley code

Trang 6

Sum Of Two Numbers

In a high level language like Fortran this would be:

SUM = NUM1 + NUM2

Trang 8

• Interpreters translate the source code one line at a time

• The line is translated into machine code and executed

• If it works, the interpreter translated the next line, and so on

• If an interpreted program breaks down, it is fairly easy to diagnose the problem and possibly even restart the

program from where it broke down

• The main problem with interpreted languages is that they are slow

Trang 9

• Compilers translate the entire program before executing

them.

• Three steps:

– Compile – translate to object (machine) code (.obj)

– Link – link code with other pre-saved code to create an

executable (.exe)

– Execute – run the program

• The initial translation can be problematic, but the translated code can be saved and run without further translation.

• Application software is normally saved as an executable.

Trang 10

High Level Languages

• Some high level languages are lower level than others

• C is a ‘lower’ level high level language – i.e it gives more

control and also runs faster than other high level

languages, but it is more difficult to learn

• Other high level languages (e.g Fortran, Basic) are easily

to learn

• Fortran is a compiled language, Basic is usually

interpreted

Trang 11

• Java was developed to overcome this.

• Java compiles the source code into an intermediate byte

code for distribution.

• This is then interpreted at execution by a Java Virtual

Machine (JVM) for a particular platform.

Trang 12

Programming Paradigms

• There are two main programming paradigms

• Older languages (e.g Fortran, Basic, Cobol, Pascal, C) use

a procedural (or imperative) paradigm.

• Newer languages (Visual Basic, C++, Delphi, Java and

C#) are more likely to be object orientated.

Trang 13

Procedural Languages

• In the early days programs were usually run as batch jobs

and required very little user interaction – so they were

basically a series of instructions to be carried out in a

specific sequence

• This was a function of early input/output devices (e.g

punched cards, line printers)

• In the 1970s keyboards and text monitors allowed

programs to be more interactive, but this did not really

affect the way in which the languages operated (i.e, they were still basically sequential)

Trang 14

Object Orientated Languages(1)

• The availability of graphics monitors and mice in the

1980s facilitated the introduction of WIMP technology (windows, icons, menus and pointers) – i.e the graphical user interfaces (GUI) that we are familiar with today

• GUI programs are event driven, so they are no longer

strictly sequential

• Each element in a GUI can be treated as a discrete object,

so object orientated languages tended to come to the fore, although the procedural languages still have their

supporters

Trang 15

Object Orientated Languages(2)

• The new object orientated languages provide windows, button, menus etc as pre-written objects, making it simple

to build a graphical user interface to a program

• Interpreters and compilers use to be simple programs, but

now they tend to form part of a more complex Integrated

Development Environment (IDE).

• The newer languages tended to GUI orientated, but not all object orientated languages are ‘visual’

Trang 16

Web Scripting Languages

• The explosion of the Internet and more especially the

World Wide Web in the 1990s created a demand for new technologies

• All web pages are written in HTML (hypertext markup language)

• This is not really a language at all, just a ste of tags that can be used to control the display of fonts

• Early web pages were static, so new scripting languages

(e.g JavaScript, VBScript, tcl, and PHP) emerged to

provide dynamic content

• Mostly interpreted, either client-side or server side

Trang 17

Programming Structures

• Procedural programming is essentially sequential

• Branches enable the program to go in different directions

in different situations:

IF (condition) THEN code1 ELSE code2

• Loops enable the program to repeat the same set of steps

multiple times:

TOTAL = 0; FOR I=1 TO 10; TOTAL = TOTAL + D(I); NEXT

• The ethos of procedural programming is encapsulated by a

flow diagram.

Trang 19

• In many situations you might find yourself doing the same type of operation several times within a single program, or you may find yourself doing the same operation in

different programs

• Rather than write new code each time it is required,

procedural languages allow you to write it as a procedure,

routine, subroutine or function separate from the main

program

• The procedure can then be called as required – i.e the

work can be ‘subcontracted’ to the procedure when

necessary

Trang 20

MEANA = MEAN(A, 3)

MEANB = MEAN(B, 5)

Trang 21

• Arguments are the actual values passed by the main

program, parameters are their generalised representations

Trang 22

Object Orientated Programming

• A class is the name given to a collection of objects – it can

also be thought of as a template

• An object has:

– A set of characteristics (attributes or properties)

– A set of things it can do (actions, operations, methods

or services)

– A current state (defined by the values of its attributes)

• The data and the methods for changing it are in the same

‘bundle’ (encapsulation).

• Programmer can issue requests to change properties.

Trang 23

• Creating an object (class instance):

$myObject = new myClass;

Trang 24

PHP Examples(2)

• Setting the property of an object:

$myObject->myValue = “Data Value”;

• Calling a method:

$myObject->myMethod();

• N.B Most languages use dots rather than ->

Trang 25

• You can create lots of objects from a single class – e.g specific students from student class

• You can also modify a class to create a new class

(inheritance) – e.g a postgrad student class from the

students class

• Different classes can have different methods defined for

the same instruction (polymorphism).

• The object orientated equivalent of a flow diagram is a

Unified Modelling Language (UML) diagram This

shows the relationship between objects

Trang 26

Inheritance

Trang 27

Aggregation

Trang 28

Association

Trang 29

Overdraft Holiday

Trang 30

Components

Trang 31

• The Object Orientated approach is replicated at a higher

level by components.

• Object linking and Embedding (OLE)

• Component Object Model (COM)

• DCOM / COBRA

• JavaBeans

• NET

Ngày đăng: 24/10/2014, 21:28