Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.
Some "rules"
Computer programs are everywhere.
But how do you go from an idea to a computer program? And what IS a computer program?
Turns out you're not the only person to wonder this.
Paul Ford wrote a 38,000-word essay called "What is Code" that was published on June 11, 2015, in Bloomberg Businessweek, and it captured the attention of many.
At its core, a computer program is a way of getting something done.
One of the ways to accomplish "getting something done" is a list of instructions that tells the computer exactly what to do and allows interaction with human beings.
Those instructions have to be written in a "language" that the computer can understand.
Computers don't understand things the same way humans do. Words and symbols that make sense to human eyes need to be translated down to binary for the computer to understand.
Binary is a system of expressing everything using only 1s and 0s.
For example, in ASCII (one system of encoding in binary), the lower case letter 'a' is represented as '1100001'.
'GDI' in ASCII is 01000111 01000100 01001001!
From human-readable languages to binary:
Baking a cake....
So which human-readable programming language do you choose to use?
It depends on the task you're trying to accomplish!
Different languages are designed to do different things.
Ever heard of the acronym "PEBKAC"?
In other words, user error.
Remember, when you're writing a program and the computer is executing it, the computer is only doing what you told it to do. If it's not working the way you expect, look for an error in your program.
Just like English has the concepts of vocabulary and grammar, so do computer languages!
In computer programming, the syntax of a computer language is what defines if the combination of letters and symbols used are considered a valid construction in that language.
Syntax mistakes may cause your code to throw compile time errors.
When you're first playing around and learning the syntax of a new computer language, one of the most common first exercises is called "Hello, World!".
The "Hello, World!" program is one that outputs the text "Hello, World!" on the screen for the user.
This task is usually relatively simple to accomplish in most programming languages, so it's a good warm-up exercise.
There are many, many, many examples in many, many, many languages.
We're going to use a website called https://repl.it/ to try out "Hello, World!" in a language or two.
Once you have a project and a language, you'll want to program your project in that language.
Let's talk about some of the basic foundational building blocks of all programming languages.
Keep in mind that each language may have a different syntax for expressing these concepts, but the underlying concepts will be the same through them all.
A variable is a storage container for information.
A variable has a name that you use to refer to it, and a value, which is the information it contains.
For example:
There are different types of variables based on the information that you want to store.
Integer variables are used to store integers (0 as well as positive and negative whole numbers).
Float variables are used to store numbers with fractional values (that is, containing decimal places).
For example, consider Amazon.com:
Not every programming language makes a distinction between these two (and some have even finer-grained distinctions!), but it's good to be aware of.
String variables are used to store text. A string is made up of characters like letters, numbers, and symbols.
For example, on Amazon.com:
Usually when you're creating a string variable, you will need to surround the value with either single or double quotation marks (either ' or ") to specify the start and end of the string. (Remember how "Hello, World!" had quotes?)
You can store a number as a string variable, but then you typically can't use it in any mathematical calculations.
For example, credit card numbers are integers, but you would never use them in a mathematical calculation, so you could store them either way.
As another example, consider postal codes. If you store them as integers, then you can only support codes from the USA! Other countries use postal codes with letters in them (e.g., BL1 1AD is in the UK).
Boolean variables are used to store the value TRUE or FALSE (yes or no).
Booleans are most frequently used to control whether certain functionality is enabled or disabled.
For example, back on Amazon.com, if your login credentials validate, this may be stored as a "true" (yes). As a result, your account information displays, your cart is populated, etc.
You may be asking yourself how exactly the computer "stores" these variables. As anyone who's shopped for a computer knows, there's a lot of terms when it comes to computer storage and memory. Let's briefly touch on them.
ROM or Read-Only Memory is for the most part not editable.
It's used by the computer to store important pieces of data when switched on, like data about the operating system.
RAM or Random Access Memory is where the computer does its "thinking".
This is where programs temporarily store data like variables while executing programs. Data in RAM is frequently overwritten and is destroyed when you turn off your computer.
If your program needs to save data for later use, you may need to make use of long-term storage.
Storage is a more permanent type of memory. The computer user can utilize it to keep data around even after the computer is turned off.
Examples include the hard drive on the computer, a thumb drive, or an external hard drive.
Files and databases can be saved in a computer's storage.
Colorless green ideas sleep furiously.
Noam Chomsky
It is possible to create an English sentence that is grammatically correct but meaningless or self-contradictory. The same is true of programming languages.
In coding, semantics refers to the meaning of the symbols you use.
Semantic mistakes may cause your code to throw run time errors.
Now that we have variables storing data for us, what can we do with them?
We use operators to compare, combine, or evaluate combinations of variables in order to produce some desired output. We could then store this output in another variable, if we wanted!
Some examples of operators:
If/Then/Else statements evaluate a condition and take actions based on the result.
If the given condition is true, Then the computer will do the actions you specify in the If clause. (In some languages, the word "then" is implied.)
Else (otherwise), if the given condition is false, the computer will do the actions you specify in the Else clause.
Let's practice If/Then/Else in the language Ruby.
Let's go back to repl.it and choose the language "Ruby" under "Popular" languages.
Copy or type the following into the left-hand side and click the "play" button:
cart_total = 8
if cart_total > 2
print "You get free shipping!"
end
Let's make this a little more complicated and add an "else" statement after the "if" statement!
cart_total = 8
if cart_total > 2
print "You get free shipping!"
else
print "You'll have to pay for shipping."
end
A loop is a list of instructions that repeats until a certain condition is met.
For example:
One reason to use a loop is to reduce the number of lines of code you need to write to accomplish a task.
Important: Beware the infinite loop!
An infinite loop is a loop that will never meet the condition to stop. For example, if you're waiting for a variable (like that ebay timer) to reach 0, but the timer variable keeps *increasing* instead of *decreasing*, the loop will continue forever!
Your program will keep running until it uses up all your computer's RAM memory. This is (generally) BAD!
An exception to this rule is a worker program, which may run constantly so that it can listen for certain kinds of input and respond without being "turned on".
There are two kinds of 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!'
Let's try this in repl.it. This time, choose the language "Python" under "Popular".
Things to try:
Careful not to create an infinite loop! If you do, you may need to force-quit your browser!
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.
Redoing our last example with a for loop, again in Python:
for number_of_bottles in range(99, 0, -1):
print number_of_bottles
print ' bottles of beer on the wall'
print 'no more bottles of beer!'
Some programmers like to leave comments in their code. Comments are not executed by the program. They're just there for you (and other programmers) to read.
Comments should explain why your code is doing what it's doing.
For example, in PHP, comments are preceded by either a # or a //.
# The following code prints something
print 'hello, world!';
Code with style! (Just like everybody else).
Style describes sets of rules that coders apply to their code. These rules can help to make the code more readable, prevent errors, and enforce consistency.
Linters are tools that know about these rules and can check your code for consistency with them. Coding teams use linters to ensure code in their projects meets certain standards.
Style mistakes may cause your code to throw no errors at all! (But may annoy your teammates).
These terms are often used in describing types of web developers.
You may see them in job postings or course descriptions.
They correspond roughly to client-side and server-side development.
Front-end developers work with the part of a web application you can see and interact with. In general this is what we think of as the web page.
Front-end developers may do some design as well as coding.
Technologies: HTML, CSS, Javascript, JQuery, Dreamweaver, Photoshop
Back-end developers work with the part of a web application that stores and processes data. They will often write code to manipulate the database or interact with other systems outside of the web site.
Technologies: PHP, Ruby, Node, SQL
Please help us make this class better by completing this short survey: