50. I ben noti cicli Molti linguaggi Ruby while { ... } until { ... } while ... end until ... end do { ... } while do { ... } until begin ... end while begin ... end until foreach { ... } each do ... end for(...;...;...) { ... }
79. 108 librerie standard Lettura/Scrittura CSV XML YAML Comunica con Email FTP Web Fornisce Code Servlets XML-RPC Lavora con Math Templates Threads Strumenti per Debugging Docs Testing
81. 1. «It's entirely too fun and productive for most people» — Mike Clark
Notas do Editor
A free scripting (or dynamic) language invented by Yukihiro Matsumoto. Similar to Perl, Python, TLC, Lisp, Lua, and more.
Ruby 0.95 was posted to the newsgroups in December of 1995. Now 10 years old. Early forms of C where around in the mid-1960s. Almost 50 years old now.
Chris Pine’s Learn to Program tutorial is great for beginners. Why’s (Poignant) Guide to Ruby by Why the Lucky Stiff is just a fun romp through Ruby. Facet’s first book is out: Agile Web Development with Rails. The Best of Ruby Quiz is coming soon.
Abbreviations: Hewlett-Packard, National Aeronautics and Space Administration, National Oceanic and Atmospheric Administration. Hurricane Katrina image analysis is being done with Ruby. Basecamp is a project and task management web application. Blinksale is a web application for sending and tracking invoices.
We will see examples of the attribute methods a little later. (slide 15)
We will see examples of variable scope a little later. (slide 15)
Inspired by Smalltalk, not Python or Perl.
This makes sense: Java’s main is procedural code in disguise.
Comparable isn’t actually needed here, since String already implements it.
each do ... end is really and iterator, and we’ll talk about that shortly. begin ... end while/until is a syntax trick that isn’t quite equivalent to do { ... } while/until in most languages.
Loops work fine for simple arrays, which is their primary use, but what about when we want to start doing custom iteration.
This is powerful in prototyping. You can mock-out solutions with basic Ruby objects like String and Array, then gradually replace then with custom objects and specialize behavior. This gets your code running fast, but allows for later customization as development progresses.
REXML transformations are easier than XSLT. YAML literally handles persistence with two lines of code: Load and save. Ruby can open web pages and read, just like it opens a file. DRb is similar to CORBA or Java’s RMI, and standard Ruby. WEBrick is Ruby’s Tomcat. Ships with Ruby. SOAP is also included, on top of XML-RPC. ERb makes templating simple and flexible. Similar to JSP style templates, but for any format. RDoc is similar to JavaDoc and can build web documentation, or command-line documentation. Test::Unit uses reflection to make testing trivial.
Seriously, most languages are equivalent. They can all be used to do our work. You just need to find what speaks to you. Ruby speaks to me.