Network: BuildRight

Password: betterweb


Slides: bit.ly/gdi-dayton-intro-programming

While you wait for class to begin, get on the wifi, bring up the slides.

Introduction to Programming Concepts

Brought to you by Girl Develop It Dayton | @GDIDayton

Presented by K.C. Jones-Evans | @kcjonesevans

Thanks to our location sponsor:

Thanks to our snacks sponsor:

A few quick announcements

  • WiFi Network is BuildRight, the password is betterweb
  • Restrooms are down the ramp and to the right
  • Please be respectful!

Welcome!

Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands on instruction.

Some "rules"

  • We are here for you!
  • Every question is important
  • Help each other
  • Have fun

Getting to Know You

  1. What's your name?
  2. What do you do day to day?
  3. If you were a vegetable, what vegetable would you be?

What We'll Be Covering:

  1. The History of Computing
  2. How Computers Think
  3. How Programming Languages Developed
  4. Basic Programming Concepts
  5. "What Should I Do Next?"

Computation:
The Early Years

Computation: The Early Years

An abacus.
An astrolabe.
A slide rule.

Examples of some early analog calculators.

Computation: The Early Years

Difference Engine drawing

Diagram of Charles Babbage's Difference Engine.

Computation: The Early Years

A constructed difference engine

An actual difference engine built out.

Computation: The Early Years

A diagram showing Ada Lovelace's program for the computation of Bernoulli numbers.

A program for the computation of Bernoulli numbers designed for the analytical engine.

Computation: The Early Years

A portrait of Ada Lovelace.

Our Lady of Conceptual Programming, Ada Lovelace

Computation: The Early Years

Illustration of Ada Lovelace and Charles Babbage standing beside a constructed Analytical Engine.

Analytical Engine per Sydney Padua's The Thrilling Adventures of Lovelace and Babbage.

Computation: The Early Years

Photo of two programmers next to the Colossus at Bletchley Park

Programmers working with the Colossus, a Nazi code-breakin'
machine and one of the first digital computers.

Computation: The Early Years

Photo of Mary Jackson in front of NASA's fortran computer

Photo of Mary Jackson in front of NASA's fortran computer

How Do Computers Do Their Thinking?

How Computers Think

Computers have three types of memory — Read-Only Memory, Hard Drive Memory, and Random Access Memory.

How Computers Think: ROM

ROM, or Read-Only Memory, is hardwritten into chips and handles data essential to a computer's operation.

How Computers Think: ROM

Cartridge-based video games are a small example of read-only memory. A dissected Game Boy game cartridge. A screenshot of Super Mario World.

How Computers Think: ROM

Read-Only Memory functions similarly to the brainstem. A fat cat with the caption 'heavy breathing' breathes heavily.

How Computers Think:
Hard Drive Memory

Hard Drive Memory is editable memory that holds files and programs that you create and install.

How Computers Think:
Hard Drive Memory

The Emotions from Inside Out

How Computers Think: RAM

RAM, or Random Access Memory is volatile memory that handles data that the computer is actively using.

How Computers Think: ROM v. RAM

ROM is like our long-term memory.

RAM is like our working memory.

Amy Poehler as Leslie Knope looking disgusted with herself.

How Computers Think: A Review

  • ROM handles data that's essential for device operation
  • Hard Drive handles hardwritten, saved data.
  • RAM handles data your computer is using.

How Do We Talk To Computers?

Programming languages!

The Evolution of Programming Languages

  • First Generation: Machine Code
  • Second Generation (1949): Assembly Code
  • Third Generation (Late 1950s): High-Level Language
  • Fourth Generation (1980s): Even Higher-Level Language

How We Talk To Computers:
The First Generation

Machine code, is the straight-up use of binary as a means of programming.

A computer saying hello in binary.

How We Talk To Computers:
The First Generation

Photo of two programmers next to the Colossus at Bletchley Park

How We Talk To Computers:
The Second Generation

A screencap of some gnarly assembly code.

How We Talk To Computers:
The Second Generation

Assembly code is code that uses chunks of text as symbols for specific processes.

A portrait of Grace Hopper

Our Lady of Code Compilation, Grace Hopper

How We Talk To Computers:
The Third Generation

Third-generation languages are languages that machine-independent and whose syntax is abstracted and reads in a much more human fashion.

Before with Assembly

section     .text
global      _start               		;must be declared for linker (ld)

_start:                          		;tell linker entry point

mov     edx,len              		;message length
mov     ecx,msg              		;message to write
mov     ebx,1                		;file descriptor (stdout)
mov     eax,4                		;system call number (sys_write)
int     0x80                 		;call kernel

mov     eax,1                		;system call number (sys_exit)
int     0x80                 		;call kernel

section     .data

msg     db  'Hello, world!',0xa  ;our dear string
len     equ $ - msg              ;length of our dear string
				

A touch of Assembly.

After!

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLOWORLD.
PROCEDURE DIVISION.
MAIN.
DISPLAY 'Hello, world.'.
STOP RUN.

A touch of COBOL.

How We Talk To Computers:
The Third Generation

Examples:
  • COBOL
  • FORTRAN
  • BASIC
  • C

How We Talk To Computers:
The Fourth Generation

Examples:
  • Java
  • Python
  • Ruby
  • MySQL + PostgresSQL
A Ruby icon.
I want to see Ruby help
every programmer in the world
to be productive, and to enjoy programming, and to be happy.

— Yukihiro "Matz" Matsumoto

How We Talk To Computers:
The Fourth Generation

puts 'Hello, world!'
A touch of Ruby.

To review...

First Generation

011010000110010101101100011011000110111100100000011101110110111101110

"Hello World" in binary.

Second Generation

section     .text
global      _start               		;must be declared for linker (ld)

_start:                          		;tell linker entry point

mov     edx,len              		;message length
mov     ecx,msg              		;message to write
mov     ebx,1                		;file descriptor (stdout)
mov     eax,4                		;system call number (sys_write)
int     0x80                 		;call kernel

mov     eax,1                		;system call number (sys_exit)
int     0x80                 		;call kernel

section     .data

msg     db  'Hello, world!',0xa  ;our dear string
len     equ $ - msg              ;length of our dear string
				

"Hello World" in Assembly.

Third Generation

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLOWORLD.
PROCEDURE DIVISION.
MAIN.
DISPLAY 'Hello, world.'.
STOP RUN.

"Hello World" in COBOL.

Fourth Generation

puts 'Hello, world!'
"Hello World" in Ruby.

Learning To Talk To Computers

The best thing about computers is that they
will do exactly what you tell them to do.

The worst thing about computers is that they
will do exactly what you tell them to do.

Demonstration

Let's Talk To Computers!

Let's Talk To Computers: Concepts

5 Concepts of every Language

  1. Tools *
  2. Syntax *
  3. Variables
  4. Control Structures
  5. Data Structures *

Tools

  • Terminal or command line
  • The IDE, Intergrated Development Environment
  • The developer community!

Syntax

The Syntax of a programming language is the set of rules that define the combinations of symbols that are considered to be correctly structured programs in that language.

Variables

  • A variable is a storage container for information.
  • Examples:
  • 
    age = 28
    color = "blue"
    					
  • There are different kinds of variables based on the information that you want to store.

Number Variables

  • Number or integer variables are used to store positive or negative whole numbers.

age = 28
year = 2016
				

String Variables

  • String variables are used to store text.

name = "K.C. Jones-Evans"
myString = 'Hello World'
				

Numbers as strings

  • You can store a number as a string variable.
  • If you store a number as a string variable, you can’t use it in any math calculations.

age = "28"
year = '2016'
				

Boolean Variables

  • Boolean variables are used to store the value TRUE or FALSE (yes or no).

am_i_a_cat = false
areMyEyesGreen = true
				

Our Sandwich Example as Variables

  • What could be a variable?
  • What kind of variable will it be?

Control Structures

  • Now that you can store data, you probably want to do something with it.
  • There are two groups of control structures:
    1. If/Else statements
    2. Loops

If/Then/Else

  • If/Then/Else statements evaluate a condition and take actions based on the result.
						
if MY_CONDITIONS then DO_ALL_THE_THINGS
else DO_SOMETHING_ELSE_ENTIRELY end
						
					

Boolean Operators on Variables

  • Boolean Operators are words or symbols that let you compare, combine, or evaulate input or varaibles to produce an output.
  • A few examples:
    a == b a is equal to b
    a != b a does not equal b
    a < b a is less than b
    a > b a is greater than b
    a <= b a is less than or equal to b
    a >= b a is greater than or equal to b
    a and b a and b together!
    a or b a or b

Our Sandwich Example with If/Else

  • What conditions do we have?
  • What variables might need to be a different type?

Loops

  • A loop is a list of instructions that repeats until a certain condition is reached.
  • There are while loops, do-while loops, and for-each loops.

Loop Examples

  • In real life: As long as it's raining, use an umbrella.
  • On an auction like Ebay.com: Allow bids on this item until the auction timer hits 0.

The #1 reason to use a loop is to reduce the number of lines of code you need to write to accomplish a task.

While loops

A while loop allows code to be executed repeatedly based on a given condition, often based on the value of a variable. Usually your code will need to change the variable within the body of the loop.



number_of_bottles = 99

while number_of_bottles > 0:
	print number_of_bottles
	print ' bottles of beer on the wall'
	number_of_bottles = number_of_bottles - 1
print 'no more bottles of beer!'
				

For loops

For loops are very similar to while loops. They just have a different syntax. In a for loop, you set up the conditional AND increment or decrement your variable in the same line.



for (number_of_bottles = 99;
		number_of_bottles > 0;
		number_of_bottles = number_of_bottles - 1)
	{
	print number_of_bottles
	print ' bottles of beer on the wall'
}
print 'no more bottles of beer!'
				

Beware the Infinite Loop!

  • An infinite loop is a loop that will never meet the condition to stop. It will keep going until it's used up all your computer's (or server's) memory (RAM). This is bad!
  • In the 99 bottles of beer example:
    1. If the "number_of_bottles = number_of_bottles - 1" line was missing, it would keep looping because 99 is always greater than 0!
    2. If "number_of_bottles = number_of_bottles - 1" was changed to "+ 1", it would keep adding 1 to 99 forever!

Data Structures

  • A data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.
  • Having data structures provides two key things:
    1. Keeps us from repeating code
    2. Allows us to keep the code flexible

  • In essence, a data structure is just a way to get around having to create tons of variables.

Data Structures

  • Address book or gmail contacts
  • Ordering systems

Data structures are all about genericizing the problem to write the least amount of code.

Data Structures Continued

  • Every language has it's own set of data structures, and their own unique way of organizing data.
  • There are so many types, that we can't cover them all! List Of Data Structures

Review!

5 Concepts of every Language

  1. Tools *
  2. Syntax *
  3. Variables
  4. Control Structures
  5. Data Structures *

Let's Revisit the Sandwich Program

Congratulations!

Coding Classes Resources (most are free) and Books

Class survey

bit.ly/gdi-dayton-class-survey