SlideShare ist ein Scribd-Unternehmen logo
1 von 32
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

Weitere ähnliche Inhalte

Was ist angesagt?

Happy Programming with CoffeeScript
Happy Programming with CoffeeScriptHappy Programming with CoffeeScript
Happy Programming with CoffeeScript
Eddie Kao
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2
Wyatt Fang
 
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
Kei Shiratsuchi
 
AWS SDK for PHP のインストールから 始めるクラウドマスターへの道 〜 Promise による非同期オペレーション 〜
AWS SDK for PHP のインストールから 始めるクラウドマスターへの道 〜 Promise による非同期オペレーション 〜 AWS SDK for PHP のインストールから 始めるクラウドマスターへの道 〜 Promise による非同期オペレーション 〜
AWS SDK for PHP のインストールから 始めるクラウドマスターへの道 〜 Promise による非同期オペレーション 〜
崇之 清水
 
Developing OpenResty Framework
Developing OpenResty FrameworkDeveloping OpenResty Framework
Developing OpenResty Framework
Aapo Talvensaari
 

Was ist angesagt? (18)

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

Andere mochten auch

Andere mochten auch (6)

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

Ähnlich wie Ruby v cpp_preso

Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014
Mandi Walls
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
goccy
 

Ähnlich wie Ruby v cpp_preso (20)

Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)
 
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflow
 
CPAN 模組二三事
CPAN 模組二三事CPAN 模組二三事
CPAN 模組二三事
 
Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014
 
perlbrew yapcasia 2010
perlbrew yapcasia 2010perlbrew yapcasia 2010
perlbrew yapcasia 2010
 
Taking Spinnaker for a spin @ London DevOps Meetup 36
Taking Spinnaker for a spin @ London DevOps Meetup 36Taking Spinnaker for a spin @ London DevOps Meetup 36
Taking Spinnaker for a spin @ London DevOps Meetup 36
 
Package manages and Puppet - PuppetConf 2015
Package manages and Puppet - PuppetConf 2015Package manages and Puppet - PuppetConf 2015
Package manages and Puppet - PuppetConf 2015
 
Lessons Learnt in 2009
Lessons Learnt in 2009Lessons Learnt in 2009
Lessons Learnt in 2009
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
 
The New Frontend Toolchain
The New Frontend ToolchainThe New Frontend Toolchain
The New Frontend Toolchain
 
Ship It ! with Ruby/ Rails Ecosystem
Ship It ! with Ruby/ Rails EcosystemShip It ! with Ruby/ Rails Ecosystem
Ship It ! with Ruby/ Rails Ecosystem
 
Great Tools Heavily Used In Japan, You Don't Know.
Great Tools Heavily Used In Japan, You Don't Know.Great Tools Heavily Used In Japan, You Don't Know.
Great Tools Heavily Used In Japan, You Don't Know.
 
Puppet Development Workflow
Puppet Development WorkflowPuppet Development Workflow
Puppet Development Workflow
 
Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"
 
Ruby performance - The low hanging fruit
Ruby performance - The low hanging fruitRuby performance - The low hanging fruit
Ruby performance - The low hanging fruit
 
Continuous feature-development
Continuous feature-developmentContinuous feature-development
Continuous feature-development
 
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
 
Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015
 
Our Puppet Story (GUUG FFG 2015)
Our Puppet Story (GUUG FFG 2015)Our Puppet Story (GUUG FFG 2015)
Our Puppet Story (GUUG FFG 2015)
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

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

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n