Lesson 1:Introduction to Programming (Python/Java) Computer Science 1 Mr. Bernstein.

Post on 26-Mar-2015

212 views 0 download

Transcript of Lesson 1:Introduction to Programming (Python/Java) Computer Science 1 Mr. Bernstein.

Lesson 1:Introduction to Programming (Python/Java)

Computer Science 1

Mr. Bernstein

Hardware Vs Software

• What’s the difference?• Hardware:

• Software:

Some Examples

• Hardware:

• Software:

The problem with Binary…Machine Code to the Rescue!• As simple as Binary is, it’s

very difficult for Hardware to use

• Instead…Hardware uses Machine CodeMachine Code - which translates into binary

The problem with Machine Code…Programming Languages to the Rescue!

• Ok, so Machine code is understood by hardware…

• But very difficult for humans to understand and write…

• So programming languages were created (semi-English) that translate into Machine Code!

• ZOMG!, now, code-monkeys like u and me can tell hardware what to do without having to learn Machine Code or Binary!!!

Quick History of Programming

• 1950s – Chaos Grammin!– No real structure very buggy and expensive– Cheaper to do stuff by hand(less expensive)– Not dependable locked away in big rooms with

AC and lots of programmers to make sure they worked

• 1960-1975 – Functional Grammin !– Allowed programmers to create functions– Can write Bigger Programs Faster– Still difficult to find bugs– Example : Fortran

Quick History of Programming (continued)

• 1975-1990 – Structured Grammin !– Programmers finally figured out that they needed a

lang that would be easier to debug– Instead of having random bits of info flying

everywhere they structured it such that all data about a certain thing was all in one place.

– So like, 4Eg, all info for a Car (year,color,model) would be stored in one place

– If something went wrong with the car data, the grammers would know where to go

– Example : C

Quick History of Programming (continued)

• 1990-present – OOP !(no it’s not the singular form of oops, it’s object oriented programming )– Expanded the concept of Structured

Programming into something called a class– Instead of just storing data, this class can

actually do certain actions. 4Eg: A car can accelerate, break, turn, honk etc.

– Ex: C++ , Java, Python, Pascal

Some Terms• Source Code

– The Source Code is the actual code the programmer writes – Our source code will be in Python and Java

• Interpreter– A software program converts the source code to

object code– Will only do so if there are no language errors in the

source code

• Executable file– A software program that executes the commands you

wrote in your source code

How Python/Java Works

1. Programmer types Source Code2. Programmer runs Source code through a

Compiler3. Compiler/Interpreter checks for errors, if

none, will produce Object Code4. Programmer will run Object Code Through

a Linker5. Linker will create an Executable6. Programmer can now run the Executable

Software!

Python – Snake or Circus?

• Python comes from Monty Python

• Python has a lot of hidden references from Monty Python Flying Circus

• http://youtu.be/zP0sqRMzkwo

Warmup from yesterdayHow does Python Work ?

Summary

• Not too long ago software was not that dependable

• Went from Chaos, to Functional, to Structured to OOP

• OOP is soo hott now. Now almost everything we do depends on reliable software.

• Java/Python is a lang that uses OOP• SrcCodeinterpreterObjectCodeLinker Executable