Your SlideShare is downloading. ×
Ruby v cpp_preso
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Ruby v cpp_preso

993
views

Published on

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
993
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. Ruby!? Yep.
    • 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
    • 6. REPLIt’s How You Learn
    • 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
    • 9. RubygemsPackage Management Made Easy
    • 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/
    • 11. Everything Is An Object
    • 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
    • 14. Monkey Patching
    • 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”
    • 16. Easy Closures
    • 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
    • 18. Mixins...
    • 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”
    • 20. Let’s Get Setup RTFM
    • 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

    ×