CSC/ECE 517 Fall 2012/ch1b 1w54 go: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 3: Line 3:
==Introduction==
==Introduction==
The Coursera video series were created to give free college level lessons to anyone with internet access.  The [http://www.youtube.com/watch?v=rC9yrukjU5g Saas video] discussed in this wiki page is the Ruby 101 provided by California University.  The video covers the fundamentals of the Ruby language and the basic concepts needed to write programs.  More information about the language can be found at its [http://en.wikipedia.org/wiki/Ruby_(programming_language) Wikipedia page].
The Coursera video series were created to give free college level lessons to anyone with internet access.  The [http://www.youtube.com/watch?v=rC9yrukjU5g Saas video] discussed in this wiki page is the Ruby 101 provided by California University.  The video covers the fundamentals of the Ruby language and the basic concepts needed to write programs.  More information about the language can be found at its [http://en.wikipedia.org/wiki/Ruby_(programming_language) Wikipedia page].
The sections below will highlight the key points of the video lecture and try to help provide further detail surrounding the concepts in the video.


==What is Ruby==
==What is Ruby==

Revision as of 03:10, 3 October 2012

SaaS Ruby 101

Introduction

The Coursera video series were created to give free college level lessons to anyone with internet access. The Saas video discussed in this wiki page is the Ruby 101 provided by California University. The video covers the fundamentals of the Ruby language and the basic concepts needed to write programs. More information about the language can be found at its Wikipedia page.

The sections below will highlight the key points of the video lecture and try to help provide further detail surrounding the concepts in the video.

What is Ruby

The Ruby language is an interpreted scripting language, meaning that there is no compile time as in other languages. Without the compile time, Ruby programs lose many warnings that programmers rely on for safety however as long as you stick to the Ruby conventions, these pitfalls can be avoided. It is an object oriented language as well. Ruby follows the object oriented paradigm so closely that everything in Ruby in an object. What this means is that all operations on objects are essentially method calls on objects. In addition this gives Ruby objects the ability to ask about themsevles via reflection. This is one of the keys to properly understanding Ruby.

Ruby is a dynamically typed language meaning that the type of some things may not be determinable until run time. All objects have types but variables do not have to have types associated with them. It is possible to see a variable that is given the value of 1 (Ex. x = 1) and then later in the code the variable is then given a string value (Ex. x = 'Hello World'). The fact that Ruby is a dynamic language gives the developer immense power and can be used to leverage code modification at runtime which is referred to as metaprogramming. The idea of metaprogramming is so pervasive in the language that you can consider all programming in Ruby to be metaprogramming.

For more information on metaprogramming and reflection please see the references section at the end of this page.

Syntax

Differences between Ruby and other OO languages (syntactic sugar)

In Ruby lines can end with the typical ; or the keyword


Objects

Ruby is an OO language but unlike other such languages everything in Ruby is an object. Anything created in Ruby can have messages passed to it or be referenced like an object at any time; whether or not this will do anything is determined by what is referenced.


Variables

Strings in Ruby are treated very similarly to how they are treated in Java. You can find their length, concatenate them, find sub-strings, and use regex expressions on them as well. Most of these features, save the last, are built right in to the string data type used.

Symbols are special types in Ruby. Essentially they are immutable strings (they cannot be changed) and their value is just themselves. They begin with a colon and then a lowercase name, (e.g. :symbol is a symbol). Although symbols are a special type of string, they are not actually strings. A symbol and a string with the same name will not be equal to one another. Symbols are used to denote something as being special, it specifies that the name used is not arbitrary and is one of a fixed set.

-Arrays

Hashes, also known as dictionaries, are like arrays that have key->value pairs as their entries. The values for each key does not have to be the same type as the key that references it.


Methods

References

http://tryruby.org/ - A helpful site that provides an interface to execute your ruby code

http://en.wikibooks.org/wiki/Ruby_By_Examples - Wiki book that discusses Ruby and its' syntax

http://rubyinstaller.org/ - Link to download Ruby

http://en.wikipedia.org/wiki/Ruby_(programming_language)- Wikipedia page