cis 338: computer languages & visual basic.net dr. ralph d. westfall october, 2011

24
CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Upload: albert-anderson

Post on 27-Dec-2015

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

CIS 338: Computer Languages & Visual Basic.NET

Dr. Ralph D. WestfallOctober, 2011

Page 2: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

What is Programming?

program = list of steps for computer like a recipe

steps can be in different "languages" Java, Visual Basic, C++, etc.

each language has own syntax (rules) like grammars in human languages “We ain't got no badges” (video; Wikip.)

Page 3: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Why Is Programming Hard?

a computer is very "stupid" it doesn't understand anything: you

have to tell it exactly what to do have to follow all the rules (syntax) of

the language as you are telling it what to do

it takes a lot of practice to be able to tell the computer exactly what to do, in perfect syntax ["Simon says:"]

Page 4: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Computer Language Types

differences based on: low level vs. high level compiled vs. interpreted special purpose vs. general

purpose procedural vs. object-oriented functional vs. imperative

Page 5: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Language Levels

low level: machine language language that a computer understands binary numbers e.g., 10111000

or hex numbers e.g., a(=10), f(=15) demo: d, u [decimal address], q

high level languages that people can understand words like "if," "else," "for," "true"

Page 6: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Language Levels - 2

1st generation : machine language BFB696 (hex from DOS debugger)

2nd generation: assembler MOV DI,96B6

3rd generation: COBOL, FORTRAN, C 4th generation (“4GL,” usually used with

databases): NOMAD (advertising hype) 5th generation? (Japanese artificial

intelligence research project in ’80s)

Page 7: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Translation

need to convert high level languages into a computer's machine language compiled

all source code in a file converted into an object code file, then run by computer

interpreted source code converted and run one line

at a time

Page 8: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Translation - 2

some languages are both compiled and interpreted (e.g., VB 6) 1st compiled into "intermediate

language" (like machine language).NET languages (~60 groups, Iron) compile into MSIL (Microsoft Intermediate Language) cf. Java bytecode intermediate language then

interpreted and executed by "run time" code (CLR)

Page 9: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Translation - 3

some interpreted languages can also be compiled previous versions of Visual Basic were

interpreted languages interpreter used to run when

developingbut distributed as a compiled EXE

Page 10: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Managed Code

Managed code executes through a virtual machine “unmanaged code … is executed directly

by the computer's CPU” (Wikipedia used to say that)

Java and .NET are based on managed code

Advantages easier to work with better security

Page 11: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Special Purpose Languages

don't do everythingdo a few things very wellexample: markup languages HTML, XML display text, images, etc. do NOT do any calculations

example: SQL for databases

Page 12: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

General Purpose Languages

can be used many different kinds of applications FORTRAN: mathematical (and other) COBOL: business/accounting (and

other) BASIC (before VB): an introductory

language Pascal: to teach good programming

Page 13: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Procedural Languages

one step after another C, COBOL, BASIC (not VB.NET)

data and actions (procedures) are separatedexample: plans for a large wedding data = list of all food & supplies procedures = all instructions for

every part of the wedding

Page 14: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Object-Oriented Languages

newer approach to programming C++, Java, VB.NET

data and procedures that use it are together in the same place (in an object or a class)objects can operate independently event-driven programs instead of one step after another

Page 15: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Object-Oriented Languages - 2

objects are like things in real world(?)

e.g., car, cat, college have data (properties) & actions

(methods) is a number an object?

has a (single) value, but has numerous operations (things you can do with it)

can you think of examples of operations on numbers?

Page 16: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Object-Oriented Languages - 3

encapsulation or "data hiding" can only access data through an

object's proceduresobject is a "black box"

VB.NET provides objects with encapsulated datae.g., to connect to a database

can create your own classes in VB.NET and then instantiate objects from them

Page 17: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Object-Oriented Languages - 4

inheritance: new objects extend capabilities of parents HourlyEmployee inherits all properties

and methods of Employee object VB used to be “the only ‘object-

oriented language’ with no inheritance” (Bruce McKinney)

VB.NET is a true object oriented language

Page 18: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Object-Oriented Advantages

objects are easier to understand ("everyone says") things in real world work like objects

different objects can hook together like a digital Lego block system

objects can be reused instead of "re-inventing the wheel"

Page 19: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Functional vs. Imperative

most common languages are imperative "side effects" can make code not run the

same when other parts of the system differ

functional programming languages should have fewer bugsHaskell and Erlang (used in telecommunications) are functional VB not but see VB Functional Programming

Page 20: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Visual Programming

the Visual Studio.NET IDE is a visual environment, not a language multiple windows:

program codepropertiesdebugging: locals and immediate

manipulation capabilitiesdrag and drop controls

Page 21: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

VB 6 as a Language

commonly referred to as a visual programming language but visual programming really means

selecting symbols instead of writing words like creating a query in MS Access

falls somewhere in between a 3rd and 4th generation languageobject based, not object oriented

Page 22: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

VB.NET as a Language

also somewhere in between 3rd and 4th generationa truly object-oriented programming language has many features that are not in VB 6

copied from Java? inheritance, try/catch blocks, file

output streams, etc.

Page 23: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Comparison with C#

Top 10 reasons VB.NET better than C#1. fewer data casts and conversions2. better Intellisense (autocompletion)3. optional parameters in subroutines4. With..End With construct5. event handlers require less coding6. less typing7. . . . . . . . .

Page 24: CIS 338: Computer Languages & Visual Basic.NET Dr. Ralph D. Westfall October, 2011

Test Your Understanding

Visual Basic.NET is: low level or high level? compiled or interpreted or ... ? managed or unmanaged code? special purpose or general purpose? object oriented or ... ? functional or imperative?