3/27/2015

Ruby and

Today’s Presentation

• What is Ruby? • What is Rails? • What are Ruby and Rails used for? • The Need for a Rails Framework • The Rails Framework • The Ruby Language • Ruby and Rails Resources

What is Ruby?

A dynamic, open source with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. -- ruby-lang.org Ruby User’s Group Website

CSCI Seminar Series Ruby and Ruby on Rails 2

1 3/27/2015

What is Ruby?

Ruby was developed: • By (“Matz”) • In japan starting in 1993 (first release 1995) I was talking with my colleague about the possibility of an object-oriented . … [Perl] had the smell of a toy language … I didn't think [Python] was a true object-oriented language — OO features appeared to be add-on to the language. …so I decided to make it.

CSCI Seminar Series Ruby and Ruby on Rails 3

Yukihiro Matsumoto

• Known as “Matz” • born in Osaka in 1965 • Self taught in programming from an early age through high school • information science degree from Univ. of Tsukuba, Ikuo Nakata’s languages and compilers research team • Open source advocate (worked for netlab.jp) • Lisp aficionado

CSCI Seminar Series Ruby and Ruby on Rails 4

2 3/27/2015

Yukihiro Matsumoto

• Worked for open source companies • Most recently the head of the research and development dept. at the Network Applied Communication Laboratory • Was a Mormon missionary • Recently released as an open source project – minimal implementation of Ruby – Based on a minimal virtual machine

CSCI Seminar Series Ruby and Ruby on Rails 5

What is Ruby?

According to Matz: I was talking with my colleague about the possibility of an object-oriented scripting language. … [Perl] had the smell of a toy language … I didn't think [Python] was a true object-oriented language — OO features appeared to be add-on to the language. …So I decided to make it.

CSCI Seminar Series Ruby and Ruby on Rails 6

3 3/27/2015

What is Ruby?

Ruby is a language of careful balance. “Matz” said he blended parts of his favorite languages (Perl, Smalltalk, Eiffel, Ada, and Lisp) to form a new language that balanced functional programming with imperative programming. …natural, not simple …simple in appearance, but is very complex inside, just like our human body.

CSCI Seminar Series Ruby and Ruby on Rails 7

What is Ruby?

• intended for use as a scripting language • interpreted • dynamic and reflexive • multi-paradigm – imperative – functional – object-oriented • not Algol-derived

CSCI Seminar Series Ruby and Ruby on Rails 8

4 3/27/2015

What is Ruby?

Ruby can be • executed directly irb • Embedded in Web-page code erb • Run directly as an interpreted program

CSCI Seminar Series Ruby and Ruby on Rails 9

What is Ruby?

The reference implementation of Ruby is: Matz's Ruby Interpreter, Ruby MRI, CRuby

The is a 2-clause FreeBSD License verified as GPL-compatible free by the Foundation and The .

CSCI Seminar Series Ruby and Ruby on Rails 10

5 3/27/2015

2-Clause FreeBSD License

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

“as is…”

CSCI Seminar Series Ruby and Ruby on Rails 11

What is Ruby?

class Numeric puts “Hello, World!” def plus(x) self.+(x) end for ss in 1...10 puts ss end end

y = 5.plus 6 # prints 1 to 9 # y is now equal to 11

for ss in 1..10 puts ss end # prints 1 to 10

CSCI Seminar Series Ruby and Ruby on Rails 12

6 3/27/2015

What is Rails?

Ruby on Rails® is an open-source web framework that’s optimized for programmer happiness and sustainable productivity. It lets you write beautiful code by favoring convention over configuration. -- http://rubyonrails.org

CSCI Seminar Series Ruby and Ruby on Rails 13

What is Rails?

Web Application Framework • developed by • open source (first released in 2004) • web application framework • written in Ruby • based on software engineering paradigms • popular for streamlining Web development

CSCI Seminar Series Ruby and Ruby on Rails 14

7 3/27/2015

David Heinemeier Hansson

• born in 1979 in Copenhagen • degree from Copenhagen Business School • successful race car driver (LeMans) • after graduation, hired by 37 Signals to work on Basecamp project management software • developed Rails as part of Basecamp project • currently CTO for Basecamp, living in Chicago

CSCI Seminar Series Ruby and Ruby on Rails 15

David Heinemeier Hansson

• born in 1979 in Copenhagen • degree from Copenhagen Business School • successful Race Driver (LeMans) • after graduation, hired by 37 Signals to work on Basecamp project management software • developed Rails as part of Basecamp project • currently CTO for Basecamp, living in Chicago

CSCI Seminar Series Ruby and Ruby on Rails 16

8 3/27/2015

What is Rails?

The Rails name, logo, etc. are still “owned” by David Heinemeier Hansson.

open source – MIT License

CSCI Seminar Series Ruby and Ruby on Rails 17

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

…as-is…

CSCI Seminar Series Ruby and Ruby on Rails 18

9 3/27/2015

What is Rails?

Web Application Framework • software framework basis for development of software applications customizable generic software platform • Web services • Web applications • Web resources • dynamic Web pages

CSCI Seminar Series Ruby and Ruby on Rails 19

What is Rails?

Based on software engineering paradigms: • DRY programming Don’t Repeat Yourself • CoC Convention over Configuration • M-V-C Model – View – Controller • Active Record Pattern (see Wikipedia)

CSCI Seminar Series Ruby and Ruby on Rails 20

10 3/27/2015

What are Ruby and Rails used for?

Rails is used to develop a software stack for Web applications. Ruby is used to customize the framework created by rails for an application.

Rails appeared in 2003. Interest in Ruby and Rails rose quickly but has levelled off. Twitter Effect (2006) SXSWi (2007) 8/16/13

CSCI Seminar Series Ruby and Ruby on Rails 21

What are Ruby and Rails used for?

Rails is used to develop a software stack for Web applications. A stack includes: • Operating Systems • Web Servers • Database server • Middleware • Language Interpreters, and more

CSCI Seminar Series Ruby and Ruby on Rails 22

11 3/27/2015

The Need for a Rails Framework

Elements of a software stack are typically Developed by specialists. Consider an MVC based active record pattern In a typical three-tiered system.

Front end Middleware Basck end user server-side DBMS Web browser programming DBMS server

CSCI Seminar Series Ruby and Ruby on Rails 23

Front end Middleware Basck end user server-side DBMS Web browser programming DBMS server

Web page developers database professionals HTML design Web page scripting administration data entry forms & processing server management SQL programmers

Middleware professionals Web server management DBMS connectivity embedded SQL dynamic HTML ORM Object Relational Modeling

CSCI Seminar Series Ruby and Ruby on Rails 24

12 3/27/2015

Ruby and Rails Resources

Installing Ruby • download source code and build or • download and run a Ruby Installer

Ruby Installer Page: http://rubyinstaller.org

CSCI Seminar Series Ruby and Ruby on Rails 25

Ruby and Rails Resources

Ruby Resources Ruby Language Website https://www.ruby-lang.org/en Ruby Documentation https://www.ruby-lang.org/en/documentation Interactive Ruby Introduction http://tryruby.org

CSCI Seminar Series Ruby and Ruby on Rails 26

13 3/27/2015

Ruby and Rails Resources

Ruby IDEs Studio RadRails http://www.aptana.com/products/radrails.html Komodo IDE http://komodoide.com RubyMine from JetBrains http://www.jetbrains.com/ruby/index.html

NotePad++ and Ruby http://www.rubytips.org/2011/12/22/using-notepad-for-writing-ruby-programs-in-windows

CSCI Seminar Series Ruby and Ruby on Rails 27

Ruby and Rails Resources

Rails Resources Rails Website http://rubyonrails.org Ruby on Rails Guide http://guides.rubyonrails.org Ruby on Rails tutorial (free online ebook, 3rd ed.) https://www.railstutorial.org

CSCI Seminar Series Ruby and Ruby on Rails 28

14