Ruby was created by Yukihiro Matsumoto, or "Matz", in Japan in the mid 1990's. It was designed for programmer productivity with the idea that programming should be fun for programmers. It emphasizes the necessity for software to be understood by humans first and computers second.
Ruby continues to gain popularity for its use in web application development. The Ruby on Rails framework, built with the Ruby language by David Heinemeier Hansson, introduced many people to the joys of programming in Ruby. Ruby has a vibrant community that is supportive for beginners and enthusiastic about producing high-quality code.
In programming and computer science in general, there is a concept called abstraction. Abstraction ensures that as users, we're far removed from what's happening "under the hood". A simple example will help illustrate this concept.
Think about the mobile phone you use everyday to communicate with your friends and loved ones. Basically, you want to make and receive calls, send/receive text messages, check your facebook/twitter and maybe take some pictures. As a user, you only care about the basic functionalities the phone makes available to communicate. Stated differently, you're dealing with an interface provided by the manufacturer of the phone.
The phone technician, on the other hand, must repair the phone and is faced with a different level of abstraction. She's well-versed in how the different components interact with the various sub-systems of the phone. Further down, the software engineer is concerned with the Operating System and deals with yet another layer of abstraction.
The above analysis is similar to what happens with computers. The user or client uses computers to listen to music, send emails, play games and more. They interact with the applications that make these tasks possible without any knowledge of the low level details. Programmers are also offered a level of abstraction by making use of a programming language like Ruby, which is written in C, which translates to Assembly language, which translates to machine language to translate 0s and 1s into something the computer understands. That means, every programming language is based on other lower level layers of code that make it easy to use. Another level of abstraction is how Ruby programmers use the Ruby programming language to design and build higher level languages called Domain Specific Languages or DSL's like Rails and Rspec. We do not necessarily need to know how these DSL's are implemented, but we know they exist and know how to use them.
As a beginner, you'll have to be aware of these abstractions particularly in programming and computer science and how they simplify programming and make computers easy to use. It's often confusing, for example, to read Rails or Rspec code without understanding Ruby because Rails and Rspec are DSLs operating at a higher level of abstraction. The goal of this book is to show you Ruby, so that when you come across higher level abstractions and DSLs, you can recognize it as just Ruby code.
This book is written for the inexperienced or completely new programmer. If you apply the principles and techniques described in this book, you will build a strong basic knowledge of programming in Ruby. You may then use this knowledge to continue to learn more advanced concepts. This book will guide you through the common pitfalls and time-sinks that a beginner may experience. It will give you plenty of practice to commit basic Ruby syntax to long-term memory so you can focus on solving real-world problems and building real-world applications.
Being a programmer is often perceived as a difficult task. It is not. It does, however, require a certain temperament. When this temperament is understood and adopted, the work that a programmer does becomes less frustrating, more fun, and quite rewarding. Perception of the difficulty of a given task is usually inversely proportional to the amount of patience the person attempting the task possesses. If you are patient with yourself and are willing to take the time to work through the exercises and apply the concepts, you will find yourself writing programs and solving problems with code very soon. There is a shift in thinking that will take place and you will develop the ability to think deeply and clearly about a given problem. This process is often referred to as "flow" and can be very satisfying and engaging. It's one of the perks of programming!
This is the first book of a two-book series on programming in Ruby. The second book will focus on Object Oriented Programming, while this book will guide you through the basics of programming fundamentals. Both of the books are meant to supplement the courses at Launch School.
Reading about programming and the act of programming are very different things. If you read this entire book without ever writing one piece of code, it is very likely that you will "understand" intellectually how to code, without being able to actually DO IT. Then, the next time you are in front of your editor with a blank screen and someone asks you to solve a problem with a computer program, you won't be able to complete the task.
There is a muscle memory aspect to computer programming that can often be overlooked. Because of the large amount of information that must be remembered by a computer programmer, practicing certain skills until they become automatic is very helpful for beginners. This is not something that requires a lot of effort per se. It is something that happens naturally through repetition. You can learn with your fingers.
Therefore, it is very important that you do EVERY exercise in this book. Give yourself a real shot at learning how to code. If you wanted to learn a musical instrument, you would have to PLAY that instrument to develop proficiency. Programming is the same way. Think of completing exercises as if you were a musician practicing musical scales. Practicing will cement the basics into your fingers and performing certain operations will become second nature and subconscious, allowing your brain to focus on higher level abstractions.
This book is written for the beginner. In the world of computer programming, there is an infinite amount of information to learn. It is impossible to learn it all. This book knows that. It intentionally avoids certain topics that are not beneficial to the beginner. Trust this fact and you will progress at a much faster rate. It is easy to get lost in the rabbit hole of information available today.
That about covers it. Get ready to build the skills that will transform you into a computer programmer. Don't worry, we'll be there to coach you along the way. Buckle up and enjoy the ride!