Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Codefellows lightning talk


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Codefellows lightning talk

  1. 1. A little bit about numbers and caching in Ruby Kathryn Blackley, @keblackley 24 July 2013 CodeFellows, Seattle, WA
  2. 2. Scenario: you want to put a number into your Rails app. Do you want… A float? 6.2321, 113592.2, 0.0000012 An integer? 4, -18, 343338 A rational? (2/3), (-1/4), (29/8) What’s the difference behind the scenes?
  3. 3. Written in binary (base 2) 0 = 0 2 = 10 1 = 1 3 = 11 4 = 100 ON OFF Each switch is a called bit.
  4. 4. Ruby integers: fixnum and bignum Fixnum – limited by length of word in your operating system: 32 bit or 64 bit. Bignum – an object is allocated so there’s one bit per digit required (in binary). Ruby automatically transitions
  5. 5. Float However your computer does numbers: “double-precision floating-point format” Uses powers of 2 and a significand to represent numbers. Problems with limited precision possible.
  6. 6. Q: Where’s this all happening in your computer? A: In the CPU! Q: So, where’s that? CPU registers RAM Hard drive CPU: central processing unit RAM: random access memory
  7. 7. Back to Ruby and Rails: Caching in your rails app is dependent on the environment: Default is OFF in development and testing Default is ON in production Can modify in config/environments Why cache in your app? Optimize your app  scalability Good to know looking ahead to when your app is extremely popular!
  8. 8. Further resource regarding caching: