SlideShare a Scribd company logo
Ruby!?
  Yep.
The Plan

• Language Intro & Features
• Environment Install
• Hello World Sinatra App on Heroku
C++

• Statically Typed Compiled Language
• int x = 2;
• x = “a”;
• uh oh...
Ruby

• Dynamically Typed Interpreted Scripting
  Language
• x=2
• x = “a”
• Mmhhmm
Ruby Features
•   http://ruby-lang.org/en/about
•   REPL
•   Rubygems
•   Everything is an object
•   Monkey patching
•   Easy closures
•   Mixins
REPL
It’s How You Learn
What it is, yo?!

• REPL = Read Eval Print Loop
• Err...
• It’s a command line tool to write ruby
• IRB & Pry
• Pry :: http://vimeo.com/26391171
In C++

• A C++ REPL?
• I guess...
• http://www.artificialworlds.net/wiki/IGCC/
  IGCC
Rubygems
Package Management Made Easy
There’s a Gem for That
•   Wait, there isn’t?
•   Write your own and publish
•   > gem install rails
    > rails new my_sweet_app
    > cd my_sweet_app
    > rails s
    > open http://0.0.0.0:3000/
•   You now have the beginnings of a web application
•   http://rubygems.org/
Everything Is An Object
Literally...

• 5.class => Fixnum
• “What?!”.length => 6
• “What?!”.length.class => Fixnum
I Don’t Believe It

•   42.class => Fixnum
• 42.class.superclass => Integer
•   42.class.superclass.superclass => Numeric
•   42.class.superclass.superclass.superclass => Integer

•   42.class.superclass.superclass.superclass.superclass => Object
Monkey Patching
Too Silly To Be Real
•   Just kidding
•   Crazy language flexibility
•   class Fixnum
       def to_kittens
          return to_s << “ kitten” if abs == 1
          to_s << “ kittens”
       end
    end
•   5.to_kittens => “5 kittens”
•   -1.to_kittens => “-1 kitten”
Easy Closures
Actually...
•   In ruby, they’re called blocks
•   Enumerators (Loops)
•   42.times do
       p “What is the meaning of life?”
    end
•   [ 1 , 2 , 3 ].each do |i|
       p i.to_kittens
    end
Mixins...
...Use Them
•   Composition vs. (Multiple?) Inheritance
•   Keep your code fresh and clean
•   module Kittens
      def to_kittens
        return to_s << “ kitten” if abs == 1
        to_s << “ kittens”
      end
    end
•   Fixnum.include Kittens
•   5.to_kittens => “5 kittens”
Let’s Get Setup
      RTFM
Command Line
• Mac: Terminal.app
• Mac: iTerm 2 alpha - http://iterm2.com
• Windows: cmd.exe
• Windows: Cygwin - http://cygwin.com
• MSys Git - http://code.google.com/p/
  msysgit/
Package Installer


• Mac: homebrew - https://github.com/mxcl/
  homebrew
• Windows: Uhhh...
Ruby


• Mac:
  > brew install ruby
• Windows: http://rubyinstaller.org/
Ruby Version Managers

• Why do we need these?
• Mac: rvm - https://
  rvm.beginrescueend.com/
• Windows: pik - https://github.com/
  vertiginous/pik
Git


• Mac: http://git-scm.com/download
• Windows: Cygwin packages/preferences
A Nice Little Web App
Sinatra


• Your first web app
• http://www.sinatrarb.com/
Heroku

• We’ll need to setup a few more things
• Gemfile
• Procfile
• Git repo
Gemfile
•   Tells heroku which gems we’ll need
•   > gem install bundler
•   Add a file called Gemfile (capital G is important)
    with the following contents...

    source :rubygems
    gem “sinatra”
    gem “heroku”, :group => :development
•   > bundle
Procfile

• Tells heroku how to boot our web app
• Add a file called Procfile (capital P is
  important) with the following contents...

  web: ruby -rubygems hi.rb -p $PORT
Git Repo

• Run the following in your terminal
• > git init
  > git add .
  > git commit -m “my first git commit!”
Heroku Again
• Sign Up - http://heroku.com
• > heroku apps:create --stack=cedar
  > git push heroku master
  > heroku open
• If your heroku commands aren’t working,
  try prepending them with “bundle exec” e.g.

  > bundle exec heroku open

More Related Content

PPTX
ZfDayIt 2014 - There is a module for everything
PDF
Bundler is the Best
KEY
Plack perl superglue for web frameworks and servers
KEY
Ruby 1.9 Fibers
PDF
OSDC 2017 - Felix Frank - Is that an Ansible_ Stop holding It Like a Puppet
PDF
Building an API with Django and Django REST Framework
PDF
Be a microservices hero
KEY
CoffeeScript presentation
ZfDayIt 2014 - There is a module for everything
Bundler is the Best
Plack perl superglue for web frameworks and servers
Ruby 1.9 Fibers
OSDC 2017 - Felix Frank - Is that an Ansible_ Stop holding It Like a Puppet
Building an API with Django and Django REST Framework
Be a microservices hero
CoffeeScript presentation

What's hot (18)

PDF
Happy Programming with CoffeeScript
PDF
How to use App::FatPacker effectively
PDF
CPAN Dependency Heaven
PDF
Node js quick tour v2
PDF
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
PDF
My Top 5 Favorite Gems
KEY
Bar Camp Atl3
PPTX
Lisp in the Cloud
PDF
WP Weekend #2 - Corcel, aneb WordPress přes Laravel
PDF
Woo: Writing a fast web server
PDF
What's new in Symfony3
PDF
C# & AWS Lambda
PPTX
Baking in the cloud with packer and puppet
PDF
AWS SDK for PHP のインストールから 始めるクラウドマスターへの道 〜 Promise による非同期オペレーション 〜
PDF
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
PDF
Developing OpenResty Framework
KEY
Ender
PDF
Rails Girls: Programming, Web Applications and Ruby on Rails
Happy Programming with CoffeeScript
How to use App::FatPacker effectively
CPAN Dependency Heaven
Node js quick tour v2
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
My Top 5 Favorite Gems
Bar Camp Atl3
Lisp in the Cloud
WP Weekend #2 - Corcel, aneb WordPress přes Laravel
Woo: Writing a fast web server
What's new in Symfony3
C# & AWS Lambda
Baking in the cloud with packer and puppet
AWS SDK for PHP のインストールから 始めるクラウドマスターへの道 〜 Promise による非同期オペレーション 〜
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Developing OpenResty Framework
Ender
Rails Girls: Programming, Web Applications and Ruby on Rails
Ad

Viewers also liked (6)

PDF
Few Countless And Collected Words 11
PPT
National Youth Program Registration Strategy Powerpoint from June 18th All-St...
PDF
Bruno William Pitzalis - Few, Countless and Selected Words
PPTX
Women and LGBT Rights Webinar
PDF
The hague conference background document 2-
PPT
AI Basics
Few Countless And Collected Words 11
National Youth Program Registration Strategy Powerpoint from June 18th All-St...
Bruno William Pitzalis - Few, Countless and Selected Words
Women and LGBT Rights Webinar
The hague conference background document 2-
AI Basics
Ad

Similar to Ruby v cpp_preso (20)

PDF
Ruby Presentation
PDF
Ruby Presentation - Article
ZIP
Ruby Kaigi 2008 LT
PPTX
Ruby and Security
PDF
How to distribute Ruby to the world
PDF
IJTC%202009%20JRuby
PDF
IJTC%202009%20JRuby
PDF
Writing a Ruby Gem for beginners
PPTX
Ruby for PHP developers
KEY
Ruby - Behind the Scenes
DOCX
Page List & Sample Material (Repaired)
PDF
An introduction to the ruby ecosystem
KEY
Crafting Beautiful CLI Applications in Ruby
KEY
An introduction to Rails 3
PDF
Swing when you're winning - an introduction to Ruby and Sinatra
PPTX
Ruby And Ruby On Rails
PPT
KEY
Ruby on Rails survival guide of an aged Java developer
PDF
How to distribute Ruby to the world
PDF
O que tem de novo no Ruby 2.0?
Ruby Presentation
Ruby Presentation - Article
Ruby Kaigi 2008 LT
Ruby and Security
How to distribute Ruby to the world
IJTC%202009%20JRuby
IJTC%202009%20JRuby
Writing a Ruby Gem for beginners
Ruby for PHP developers
Ruby - Behind the Scenes
Page List & Sample Material (Repaired)
An introduction to the ruby ecosystem
Crafting Beautiful CLI Applications in Ruby
An introduction to Rails 3
Swing when you're winning - an introduction to Ruby and Sinatra
Ruby And Ruby On Rails
Ruby on Rails survival guide of an aged Java developer
How to distribute Ruby to the world
O que tem de novo no Ruby 2.0?

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Spectroscopy.pptx food analysis technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
MYSQL Presentation for SQL database connectivity
sap open course for s4hana steps from ECC to s4
Empathic Computing: Creating Shared Understanding
Programs and apps: productivity, graphics, security and other tools
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation_ Review paper, used for researhc scholars
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Review of recent advances in non-invasive hemoglobin estimation
Spectroscopy.pptx food analysis technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Network Security Unit 5.pdf for BCA BBA.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Approach and Philosophy of On baking technology
Reach Out and Touch Someone: Haptics and Empathic Computing
Understanding_Digital_Forensics_Presentation.pptx
20250228 LYD VKU AI Blended-Learning.pptx

Ruby v cpp_preso

  • 2. The Plan • Language Intro & Features • Environment Install • Hello World Sinatra App on Heroku
  • 3. C++ • Statically Typed Compiled Language • int x = 2; • x = “a”; • uh oh...
  • 4. Ruby • Dynamically Typed Interpreted Scripting Language • x=2 • x = “a” • Mmhhmm
  • 5. Ruby Features • http://ruby-lang.org/en/about • REPL • Rubygems • Everything is an object • Monkey patching • Easy closures • Mixins
  • 7. What it is, yo?! • REPL = Read Eval Print Loop • Err... • It’s a command line tool to write ruby • IRB & Pry • Pry :: http://vimeo.com/26391171
  • 8. In C++ • A C++ REPL? • I guess... • http://www.artificialworlds.net/wiki/IGCC/ IGCC
  • 10. There’s a Gem for That • Wait, there isn’t? • Write your own and publish • > gem install rails > rails new my_sweet_app > cd my_sweet_app > rails s > open http://0.0.0.0:3000/ • You now have the beginnings of a web application • http://rubygems.org/
  • 12. Literally... • 5.class => Fixnum • “What?!”.length => 6 • “What?!”.length.class => Fixnum
  • 13. I Don’t Believe It • 42.class => Fixnum • 42.class.superclass => Integer • 42.class.superclass.superclass => Numeric • 42.class.superclass.superclass.superclass => Integer • 42.class.superclass.superclass.superclass.superclass => Object
  • 15. Too Silly To Be Real • Just kidding • Crazy language flexibility • class Fixnum def to_kittens return to_s << “ kitten” if abs == 1 to_s << “ kittens” end end • 5.to_kittens => “5 kittens” • -1.to_kittens => “-1 kitten”
  • 17. Actually... • In ruby, they’re called blocks • Enumerators (Loops) • 42.times do p “What is the meaning of life?” end • [ 1 , 2 , 3 ].each do |i| p i.to_kittens end
  • 19. ...Use Them • Composition vs. (Multiple?) Inheritance • Keep your code fresh and clean • module Kittens def to_kittens return to_s << “ kitten” if abs == 1 to_s << “ kittens” end end • Fixnum.include Kittens • 5.to_kittens => “5 kittens”
  • 21. Command Line • Mac: Terminal.app • Mac: iTerm 2 alpha - http://iterm2.com • Windows: cmd.exe • Windows: Cygwin - http://cygwin.com • MSys Git - http://code.google.com/p/ msysgit/
  • 22. Package Installer • Mac: homebrew - https://github.com/mxcl/ homebrew • Windows: Uhhh...
  • 23. Ruby • Mac: > brew install ruby • Windows: http://rubyinstaller.org/
  • 24. Ruby Version Managers • Why do we need these? • Mac: rvm - https:// rvm.beginrescueend.com/ • Windows: pik - https://github.com/ vertiginous/pik
  • 25. Git • Mac: http://git-scm.com/download • Windows: Cygwin packages/preferences
  • 26. A Nice Little Web App
  • 27. Sinatra • Your first web app • http://www.sinatrarb.com/
  • 28. Heroku • We’ll need to setup a few more things • Gemfile • Procfile • Git repo
  • 29. Gemfile • Tells heroku which gems we’ll need • > gem install bundler • Add a file called Gemfile (capital G is important) with the following contents... source :rubygems gem “sinatra” gem “heroku”, :group => :development • > bundle
  • 30. Procfile • Tells heroku how to boot our web app • Add a file called Procfile (capital P is important) with the following contents... web: ruby -rubygems hi.rb -p $PORT
  • 31. Git Repo • Run the following in your terminal • > git init > git add . > git commit -m “my first git commit!”
  • 32. Heroku Again • Sign Up - http://heroku.com • > heroku apps:create --stack=cedar > git push heroku master > heroku open • If your heroku commands aren’t working, try prepending them with “bundle exec” e.g. > bundle exec heroku open

Editor's Notes