Upgrade to Pro — share decks privately, control downloads, hide ads and more …

IRB, REPL, and Pry

IRB, REPL, and Pry

High-level overview of these terms

Emma Hardman

July 24, 2013

Transcript

9 slides
  1. REPL Read, Evaluate, Print, Loop Simple, interactive computer programming environment

    In a REPL, the user enters one or more expressions, which are then evaluated, and the results displayed. The name read–eval–print loop comes from the names of the Lisp primitive functions A REPL is an important part of learning a new language as it gives quick feedback to the novice. IRB, Pry both provide a REPL Wednesday, July 24, 13
  2. So many REPLS: Some major language environments and associated REPLs

    *thanks, Wikipedia! C does not have a built-in REPL, but third-party REPLs exist, like c-repl and ccons. C++ does not have a built-in REPL, but third-party REPLs exist, like cint and cling. CoffeeScript provides a REPL with mutli-line input support and syntax-highlighted output (coffee). Common Lisp, most implementations have built-in REPLs. F# has a REPL in the form of a command called fsi (F# interactive). Falcon has an interactive mode by running falcon -i. Java does not have a built-in REPL, but has a pure Java implementation in BeanShell. It can also be driven via scripting languages ported to the Java platform like Jython or Groovy. There is a Java REPL implementation in DrJava accessible from the Interactions pane and in JGrasp IDE [2]. A JavaScript REPL is provided by Node.js, Rhino, and in the browser using debug console. Perl provides a REPL via the module Devel::REPL, also Perl Console. PHP's command-line interface has an interactive mode, which you can run by doing php -a (assuming php is your PHP-CLI executable, not PHP-CGI). There is also phpsh and wigwam, which have tab completion and other features, and boris, which claims to be more robust than PHP's native interactive mode. Python has a built-in REPL and a more enhanced version in IPython and bpython Wednesday, July 24, 13
  3. IRB: Interactive Ruby Interactive Ruby (IRB or irb) is a

    shell for programming in Ruby. developed by Keiju Ishitsuka The abbreviation irb comes from the fact that the filename extension for Ruby is ".rb". IRB is launched from a command line and allows the execution of Ruby commands with immediate response, perfect for experimenting in real-time! It provides an environment for you to mess around with Ruby without having to create new files and is basically a way to run methods and see what happens in the command line instead of having to check on your server Ruby’s standard library already has this--it comes with a module called IRB People really liked this about Ruby and began customizing their IRB module and sharing tricks Wednesday, July 24, 13
  4. Pry: Alternative to IRB It is a gem anyone can

    install! In any ruby file: lots of features people love--where IRB couldn’t deal with tons of code or jumping into a method half-way through (among other things), Pry can! great for debugging (binding.pry) Wednesday, July 24, 13
  5. Some more Pry features: • Source code browsing • Navigation

    around state (cd, ls, nesting) • Documentation browsing • Open methods in editors • Syntax highlighting • Command shell integration (start editors, run git, and rake from within Pry) • Gist integration • Runtime invocation (use Pry as a developer console or debugger) • Ability to view and replay history • active IRC channel! • flexible, allowing for lots of user customization! Wednesday, July 24, 13

More Decks by Emma Hardman

Other Decks in Programming