This site:
http://poignantguide.net/ruby/chapter-2.html
offers a very interesting introduction to Ruby. You are to read chapters 2 and 3 for homework.
This site:
http://poignantguide.net/ruby/chapter-2.html
offers a very interesting introduction to Ruby. You are to read chapters 2 and 3 for homework.
Just some quick notes about our Ruby on Rails development:
Ruby - A very clean programming language often used for creating web applications
Rails - A framework for creating web applications that will use Ruby
Aptana Studio – An Integrated Development Environment (IDE) for creating Ruby on Rails applications (amongst others.)
RubyGems - Package Installer for Ruby (also can update)
WampServer - RUns a local server on your machine; includes MySQL, Apache, and PHP
“Rails” command – A command that generates a rails framework for a web app
http://localhost:3000 – The default location (IP and port) where the server from Aptana will host the web appl
As I have already said, for class we will be using Ruby on Rails to explore elements of programming. I have a new category about Ruby posts here on the blog. I will post information about each lesson and tutorial we work through. I will make videos as we go along, however, I will not post them here. The reason is, I will use a lot of references from our book and that may pose some problems posting that in the public domain. Instead I will email you the links to where I have posted the videos privately.
Welcome to our programming unit. As I have mentioned in class we will be learning how to use the Rails Framework to develop a web application that uses Ruby code. I am using the book “RailsSpace” byHartl and Prochazka as a guide. It is a great book that teaches RubyOnRails (RoR) through the development of a social networking site they call RailsSpace. The book is really well written for experienced and novice programmers alike. Working incrementally on a large project is a great way to learn, and in my experience, far better that a collection of non-related examples to work with. There should be a guide like this for every language.
Since I will be using examples from the book, I will not be posting all the tutorials publicly. But there is not much more in my tutorials that is not in the book. So if you are reading this and want to follow along, just buy the book. It will have many more examples and explanations than I give in my video tutorials anyways. For my class, you will have private access to the videos.
Good morning Computer Scientists. Read the following post and please summarize for your own notes.
This a ultra-stripped down introduction to concepts in programming. This is a starting point from no knowledge. So if you come across this page and you have some background in programming, and you notice some things aren’t technically correct ~ you might care but my grade 11 students do not. As a side note for my students, programmers tend to have serious idiosyncrasies (peculiar tendencies), a common one is the need to correct people when they feel a slight misinterpretation of their craft has been made.
Let’s start with some simple explanations of concepts in programming. Many times I will use “real world” examples. It isn’t that programming isn’t part of our reality, I mean that we have our every day world an the virtual one we are creating through programming.
Variables - A variable is something that represents something else. It is that simple. In math class when we say x+2 = 5, we are basically saying that x is representing a 3. We could also say more generally that x is representing a number, integer, real number whole number, prime number etc. A variable can also represent a word, a password might actually represent “iluvamericanidol.” In real life, our name is a variable that represents us. We’ll say “Jon Smith” rather than describe every characteristic that makes up John. It is easier to use a variable. You should name variables something meaningful like “person_height” rather than “z.” You should know that you cannot name variables certain keywords. Keywords are special words in the language that have special meaning.
Basic Data Types – Data can be different things. Most often it is numbers and strings (letters, words, text.) These are our basic types of data. Later we’ll talk about advanced data types, but these are data types made of our basic ones. Most programming languages have the following (or similar) basic data types.
Properties (Attributes) – Properties are things that an object has. They are the things that describe the object and in most cases make it unique. In real life we have trees. Some properties of trees are colour, height, weight and type. There are surely more, we’ll just look at these ones. Colour is a property, if the colour of the tree is green, then the property colour has a value of “green.” So properties have three parts, the property name, the value, and the type. Types of properties are things like numbers, words, etc. You can think of properties as special variables that belong to an object.
Objects - I should point out that in programming, Objects don’t exist in every programming language. Languages like Squeak, Java, and C++ are “object oriented.” That basically means that everything is an object (this is especially true in Java.) languages like C and PERL are not object oriented, however, a skilled program can use constructs like objects if they wish. An object is just something we represent in programming that is like its real life counterpart (or would be like if it existed.) So if we were making the Need For Speed 30 car racing game, we might want to code a car object. This car object would have properties, like weight, type, colour, etc.
IDE (Integrated Development Environment)- An IDE is where the programmer works. If Word is for a writer, an IDE is for a programmer. It allows programmers to write programs and usually provides helpful features. This means it might have special display windows, or that it colour codes key words. For most languages you don’t need a nice IDE and you could just use something like Notepad. But a good IDE can really help you along.
Boolean Algebra- Boolean Algebra are like equations that can only have one of two results, either True or False. In boolean algebra, something like 8 < 30 would equal True. An expression like Brittney Spears AND Albert Einstein are both really smart, would be False because they are not BOTH smart (Albert Einstein is dead.) The AND is called a boolean operator.
You’ll notice above that I used AND. AND is a boolean operator. We also have OR and NOT as the basic operators. An expression like “I know how to drive a car OR I know how to fly a plane” would be True. That is because I do know how to drive. As long as one of the statements is True than the whole statement is true. A NOT operator simply reverses the expression, so a true statement results in false and vice-versa.
Comparison Operators- These are operators that are also used in boolean algebra. The expressions will still result in true or false. In the example I used before: 8<30 is True, the “<” is a less-than operator. These are often used to compare numbers but can also compare strings, or even objects. We use the operators < (less-than), > (greater than), = (equal-to), and != (not equal-to).
Functions (or Methods) – Functions are named chunks of code. Programmers create functions to perform a job that the program will complete often. That way instead of re-writing the same chunk of code over and over again. That is the easiest thing to see. Think about directions to school. If we had to re-write code for each day of school, it adds up. It is easier to have a function called “go_to_school,” you’d never miss class again.
Functions also make our program more easy to understand when we look at it. That’s because we name our functions things that makes sense. So if we saw a function called “stringToInteger(x)”, we might guess that it converts the string x to an Integer. As a side note these chunks of code are called blocks in Ruby.
Syntax- Syntax is the rules of a language. English is a language and it has rules. Those rules are called its grammar. If we don’t use grammar correctly, even though we are using English words, our message will be lost. The same is true for programming languages. We need to follow the rules of our language or the computer won’t be able to understand what we want the program to do. Every language has its own syntax. Some programmers will have preferences and say one language’s syntax is more difficult than another language’s grammar. And syntax can be tricky; forgetting a semi-colon may cause a whole program to crash. And you thought English grammar was difficult.
Semantics – Remember when Homer said “Let’s not get bogged down in semantics.”? I do…and I laughed. Well, if there is something that can bog you down, it’s semantics. Semantics is the meaning of a message. Basically it’s what the message you are trying to get across. While syntax is how you say something; semantics is what you are saying. In programming, when we discuss semantics, we are talking about what you are trying to do with your program. Are you trying to solve a complex calculation? Create artificial intelligence for a game? Launch a space shuttle? Getting your semantics correct, means creating a program that completes the correct steps to solve a task.
Visit this site: http://cisnet.baruch.cuny.edu/holowczak/classes/programming/ for some more information. Use these explanations to add to your understanding. Remember, you are expected to make notes…its is your homework.
Also for homework, visit this site: http://tryruby.hobix.com/ . It will give you a very brief introduction to Ruby. Don’t worry if a lot of it doesn’t make the most sense yet. It will get better in time!
Just a reminder that your test is Thursday March 20.
One thing we haven’t discussed in depth is how a processor works. Part of that reason is that processor technology is rapidly changing. With dual core and quad core CPU’s on the scene, there is a lot to talk about. Some things that don’t change are the basics of the CPU. We often refer to the CPU as the brain of the computer. Well obviously that is a very big generalization (and for the most part, the CPU doesn’t “think”.)
So let’s take a bit of an in depth look at processors. Intel (the leader in CPU sales) has some great information for students on their website. Visit their lessons on processors here.
I wouldn’t be surprised if there were a couple questions on your test relating to this material.
We are going to be looking at programs written in assembly language, specifically those that would run on a RISC architecture. Yesterday we talked about the add, store, load, and bit test commands.
To actually create a program, we will need an emulator to act as a RISC machine.
You can download one here. Be sure to download the version for Windows XP.