这是用户在 2024-4-21 10:58 为 https://www.writesoftwarewell.com/books-to-learn-ruby-and-rails/ 保存的双语快照页面,由 沉浸式翻译 提供双语支持。了解如何保存?
Books to learn programming with Ruby and Rails

A List of Books to Learn Programming with Ruby and Rails
学习 Ruby 和 Rails 编程的书籍列表

This post provides a curated list of books to learn to code in Ruby and build web applications with Rails. It also gives a step-by-step path you can follow to learn enough before moving to the next step. If you ever wanted to learn to program but didn't know where to start, this post is for you.
这篇文章提供了一个精选的书籍列表,帮助您学习 Ruby 编码和使用 Rails 构建 Web 应用程序。它还提供了您可以遵循的分步路径,以便在进入下一步之前了解足够的知识。如果您曾经想学习编程但不知道从哪里开始,那么这篇文章适合您。

9 min read

Ever since I started writing about Ruby and Rails on this blog, I’ve received dozens of emails and messages from students, programmers, and non-software professionals on how to get into programming and start learning Ruby on Rails to build web applications.
自从我开始在这个博客上撰写有关 Ruby 和 Rails 的文章以来,我收到了来自学生、程序员和非软件专业人士的数十封电子邮件和消息,内容涉及如何进入编程并开始学习 Ruby on Rails 来构建 Web 应用程序。

After replying to a lot of these queries both in person and online on various forums and emails, I decided to save some keystrokes and compile everything into a blog post that I could point to and keep updated.
在亲自和在各种论坛和电子邮件上在线回复了很多此类问题后,我决定节省一些击键并将所有内容编译成一篇博客文章,我可以指向并保持更新。

What follows is a curated collection of books to learn to program in Ruby and build web applications using Rails. Each section provides a path that you can follow to learn enough before moving to the next section.
以下是学习 Ruby 编程和使用 Rails 构建 Web 应用程序的精选书籍集。每个部分都提供了一条路径,您可以遵循该路径在进入下一部分之前了解足够的内容。

This post only covers books. Could you learn by watching YouTube, screencasts, or online courses? Probably, but reading books is how I learned Ruby and Rails, and it's the best way I know how to learn anything. So books it is. If you know other material, please mention them in a comment below.
这篇文章只涉及书籍。您可以通过观看 YouTube、截屏视频或在线课程来学习吗?可能吧,但是读书是我学习 Ruby 和 Rails 的方式,也是我学习任何东西的最好方式。书籍也是如此。如果您知道其他材料,请在下面的评论中提及。

Now, if you haven't programmed before, you might have two questions:
现在,如果您以前没有编程过,您可能会有两个问题:

Why Ruby? The simple answer is: it's easy and it's fun. That's it. If you were turned off from programming because you learned Java, C, or C++ in college and found them too complicated, try Ruby. It's different. Most programming languages are designed to make the compiler happy. Ruby is designed to make developers happy.
为什么是红宝石?简单的答案是:这很容易而且很有趣。就是这样。如果您因为在大学学习 Java、C 或 C++ 并且发现它们太复杂而对编程失去兴趣,请尝试 Ruby。这不一样。大多数编程语言都是为了让编译器满意而设计的。 Ruby 旨在让开发人员感到高兴。

Why Rails? It makes it very easy to build web applications. Many of the popular web applications that you know and love (Shopify, Airbnb, Zendesk, Github, HEY, and thousands more) are using Ruby on Rails. Even the initial version of Twitter was built with Rails. Finally, if you want to program Ruby professionally, you'll need to learn Rails.
为什么选择 Rails?它使得构建 Web 应用程序变得非常容易。您了解和喜爱的许多流行 Web 应用程序(Shopify、Airbnb、Zendesk、Github、HEY 等等)都在使用 Ruby on Rails。甚至 Twitter 的初始版本也是使用 Rails 构建的。最后,如果您想专业地进行 Ruby 编程,您需要学习 Rails。

Before you feel intimidated by this list of books to read, remember that learning to program is a long-term journey and it's good to set clear expectations.
在你对这份要读的书清单感到害怕之前,请记住,学习编程是一个长期的旅​​程,设定明确的期望是有好处的。

What You Should Know Before Starting Your Programming Journey
开始编程之旅之前您应该了解什么

Here're a few things to keep in mind before you jump in, if you've never programmed before but want to start.
如果您以前从未编程过但想开始编程,那么在开始之前请记住以下几点。

Your age doesn’t matter. You can start learning to program at any age and become quite good at it in a relatively short time if you apply yourself and take it seriously. Don't let anyone tell you that you're either too young or too old to code.
你的年龄并不重要。你可以在任何年龄开始学习编程,只要你努力并认真对待,你就可以在相对较短的时间内变得非常擅长。不要让任何人告诉你,你太年轻或太老,不适合编码。

From a Lorry Driver to Ruby on Rails Developer at 38
38 岁从卡车司机到 Ruby on Rails 开发人员
I recently had the pleasure to interview Pedro David Garcia Lopez, a Ruby and Rails developer based in UK, who used to be a Lorry driver. What’s interesting is that he decided to become a developer at the age of 38. This post shares his story and I hope you find it as inspiring as I did!
最近,我有幸采访了 Pedro David Garcia Lopez,他是一位来自英国的 Ruby 和 Rails 开发人员,曾经是一名卡车司机。有趣的是,他在 38 岁时决定成为一名开发人员。这篇文章分享了他的故事,我希望你和我一样觉得它鼓舞人心!

Your background doesn’t matter. No matter what work you were doing before, you can (and will) learn how to program if you practice diligently.
你的背景并不重要。无论您以前从事什么工作,如果您勤奋练习,您都可以(并且将会)学习如何编程。

You'll have to spend some money, but it won’t be thousands and thousands of dollars on university degrees, coding bootcamps, or online programs. Just be willing to purchase a few good books. And I mean purchase, do not use the free PDF copies you find online. Trust me, the effort you invest in your learning resources impacts how you learn.
你必须花一些钱,但不会花费数千美元购买大学学位、编码训练营或在线课程。只要愿意购买一些好书即可。我的意思是购买,不要使用您在网上找到的免费 PDF 副本。相信我,您在学习资源上投入的精力会影响您的学习方式。

The psychological concept of effort justification states that people tend to attribute a higher value to an outcome if they've put effort into it.
努力合理性的心理学概念指出,如果人们付出了努力,他们往往会给结果赋予更高的价值。

You don’t need to study programming for eight hours a day. In fact, you shouldn’t. That’s a road to burnout. If you have a busy schedule, studying in full concentration for 90 minutes every day is more than enough, even better than doing nothing for a week and a marathon 8-hour session on Sunday.
你不需要每天花八个小时学习编程。事实上,你不应该。这是一条通往倦怠的道路。如果你的日程很忙,每天全神贯注地学习90分钟就绰绰有余了,甚至比一周无所事事、周日跑8个小时的马拉松还要好。

No matter what anyone tells you, Ruby is the best programming language to start your programming journey. Don’t think that Ruby is some niche language used by passionate hobbyists. Some of the biggest companies you know use Ruby.
无论别人告诉您什么,Ruby 都是开始您的编程之旅的最佳编程语言。不要认为 Ruby 是热情的爱好者使用的某种小众语言。您所知道的一些最大的公司都使用 Ruby。

There's a lot of bad advice out there about getting started in tech and people are trying to get into AI/Crypto and trying to build Web3 apps when they don't know what HTML is, just because some influencer on YouTube told them to. DON'T DO THAT!
关于技术入门有很多不好的建议,人们在不知道 HTML 是什么的情况下试图进入人工智能/加密货币并尝试构建 Web3 应用程序,只是因为 YouTube 上的一些有影响力的人告诉他们。不要那样做!

For programmers only: If someone tells you "Ruby is slow", or "Rails doesn’t scale" run away from them as far as possible. Either they have no idea what they’re talking about, or they're pitching you a JavaScript framework that was created last month, or they work for a giant company like Google, Microsoft, or Facebook and want to promote the big and complicated framework or language they built for their use cases but won’t apply to you as a solo developer with limited resources.
仅限程序员:如果有人告诉您“Ruby 很慢”或“Rails 无法扩展”,请尽可能远离他们。要么他们不知道自己在说什么,要么他们正在向您推销上个月创建的 JavaScript 框架,要么他们为 Google、Microsoft 或 Facebook 这样的大公司工作,想要推广这个庞大而复杂的框架或他们为其用例构建的语言,但不适用于资源有限的独立开发人员。

Finally, don’t expect to start learning tomorrow and hope to become proficient and land a cushy, work-from-home tech job next month. This is a long-term process. Anyone who tells you otherwise is trying to sell you their book/course/bootcamp and get your money. However, if you stick to the path and practice every day, you’ll be amazed at how much progress you can make in just a few months.
最后,不要指望明天就开始学习,而是希望下个月能熟练掌握并找到一份轻松的在家工作的技术工作。这是一个长期的过程。任何告诉你其他情况的人都试图向你推销他们的书/课程/训练营并骗取你的钱。然而,如果你坚持这条道路并每天练习,你会惊讶地发现短短几个月内你就能取得如此大的进步。

With that out of the way, let's look at how you should proceed on your journey to become a web developer.
说完这些,让我们看看您应该如何继续成为一名 Web 开发人员。

Learning Ruby 学习红宝石

Books to Learn Ruby

Assuming you've never programmed before, I recommend starting with Chris Pine's excellent book Learn to Program. It's an awesome beginner-friendly book, and Chris explains each topic in programming in an easy-to-understand way. This book should get you started with Ruby pretty quickly, also teaching you the fundamental concepts in programming such as conditionals and loops.
假设您以前从未编程过,我建议您从 Chris Pine 的优秀著作《学习编程》开始。这是一本很棒的适合初学者的书,克里斯以易于理解的方式解释了编程中的每个主题。这本书应该可以帮助您快速开始使用 Ruby,还可以教您编程的基本概念,例如条件和循环。

Learning the basics of any programming language is one thing, you need to know the best practices in that language to write good software. For this, check out Russ Olsen's Eloquent Ruby, which is one of the best Ruby books I've read. I read it twice last year and can't recommend it enough. Even though it was published in 2011, most of the best practices mentioned in it remain unchanged.
学习任何编程语言的基础知识是一回事,您需要了解该语言的最佳实践才能编写优秀的软件。为此,请查看 Russ Olsen 的 Eloquent Ruby,这是我读过的最好的 Ruby 书籍之一。我去年读了两遍,强烈推荐。尽管它是 2011 年发布的,但其中提到的大多数最佳实践仍然没有改变。

At this point, you should be able to write simple Ruby programs. Now you can start the next section (learning to build web applications) in parallel while you learn intermediate Ruby.
此时,您应该能够编写简单的 Ruby 程序。现在,您可以在学习中级 Ruby 的同时开始下一部分(学习构建 Web 应用程序)。

Intermediate Ruby 中级红宝石

After reading these two books, you should have a solid understanding of Ruby and you'd be able to read and write Ruby programs. At this point, you must be itching to go even deeper into Ruby and learn the various core classes and standard libraries included in Ruby.
读完这两本书后,您应该对 Ruby 有一个扎实的了解,并且能够阅读和编写 Ruby 程序。此时,您一定渴望更深入地了解 Ruby,学习 Ruby 中包含的各种核心类和标准库。

To learn Ruby in depth, I recommend reading Programming Ruby by Dave Thomas. Also known as the Pick-Axe book, this is one of the oldest and most famous books in the Ruby community, and many well-respected Ruby & Rails programmers attribute their initiation to Ruby to this book. If you decide to read just one book from this list, this should be it.
要深入学习 Ruby,我建议阅读 Dave Thomas 的《Programming Ruby》。这本书也被称为 Pick-Axe 书,是 Ruby 社区中最古老、最著名的书籍之一,许多备受尊敬的 Ruby & Rails 程序员都将他们对 Ruby 的启蒙归功于这本书。如果您决定只阅读此列表中的一本书,那么应该就是这本书。

Advanced Ruby 高级红宝石

Finally, there's one book that I recommend to everyone to really master the Ruby language, which is Paolo Perrotta's Metaprogramming Ruby 2. This book not only teaches the powerful metaprogramming concepts in Ruby, but also how to use them judiciously.
最后,我向大家推荐一本真正掌握 Ruby 语言的书,那就是 Paolo Perrotta 的《Metaprogramming Ruby 2》。这本书不仅讲授 Ruby 中强大的元编程概念,还讲授如何明智地使用它们。

Metaprogramming Ruby 2

The primary benefit of metaprogramming I found was not so much in writing clever code, but instead reading and understanding open source code, especially the Rails source code. For a preview, check out my notes.
我发现元编程的主要好处不在于编写聪明的代码,而在于阅读和理解开源代码,尤其是 Rails 源代码。如需预览,请查看我的笔记。

Reference Books 相关书籍

I recommend using the following two books as references at hand instead of reading them end-to-end.
我建议使用以下两本书作为手头的参考,而不是从头到尾地阅读它们。

Reference Books for Ruby
  1. The Well-Grounded Rubyist is a good book that covers various features of Ruby in-depth, including metaprogramming.
    The Well-Grounded Rubyist 是一本好书,深入介绍了 Ruby 的各种功能,包括元编程。
  2. Hal Fulton's Ruby Way: The Solutions and Techniques in Ruby Programming is a wonderful book covering core classes and standard library in-depth.
    Hal Fulton 的《Ruby Way:Ruby 编程解决方案和技术》是一本精彩的书,深入介绍了核心类和标准库。

Intermission: Learn Web Development with Sinatra
中场休息:与 Sinatra 一起学习 Web 开发

When you feel comfortable with Ruby, the obvious next step is to learn Rails. However, I'd ask you to be a little patient and try Sinatra, which is a lightweight web framework for Ruby.
当您对 Ruby 感到满意时,显然下一步就是学习 Rails。不过,我建议您耐心一点,尝试一下 Sinatra,它是 Ruby 的轻量级 Web 框架。

I feel that too often, new developers make two mistakes on their path to becoming a Rails developer:
我觉得新开发人员在成为 Rails 开发人员的道路上经常犯两个错误:

  1. Jumping into Rails without learning Ruby, or
    无需学习 Ruby 即可进入 Rails,或者
  2. Starting to build Rails applications without having a basic understanding of how most web applications work.
    在对大多数 Web 应用程序的工作原理没有基本了解的情况下就开始构建 Rails 应用程序。

Then they see everything that Rails does for you, and either feel it's all magic (it's not!) and get overwhelmed and ultimately discouraged and leave the journey altogether.
然后他们看到 Rails 为您所做的一切,要么觉得这一切都很神奇(事实并非如此!),要么感到不知所措,最终灰心丧气,完全离开旅程。

Don't do that! 不要那样做!

Sinatra is very simple to get up and running in less than a minute. It's just a Ruby file.
Sinatra 非常简单,不到一分钟即可启动并运行。这只是一个 Ruby 文件。

# myapp.rb
require 'sinatra'

get '/' do
  'Hello world!'
end

Then you add a view, some HTML, CSS, and JavaScript, and you have a complete web application. Building one or two simple web applications (e.g. a blog or a to-do list) using Sinatra will give you a good taste of web development, and you'll be ready to tackle basic Rails concepts such as routing, views, etc.
然后添加一个视图、一些 HTML、CSS 和 JavaScript,您就拥有了一个完整的 Web 应用程序。使用 Sinatra 构建一两个简单的 Web 应用程序(例如博客或待办事项列表)将使您很好地体验 Web 开发,并且您将准备好处理基本的 Rails 概念,例如路由、视图等。

This stage shouldn't take long. Your goal is not to master Sinatra or web development right now (it's a lifelong journey), but just to get familiar enough to not get scared when you see a Rails application.
这个阶段应该不会花很长时间。您的目标不是立即掌握 Sinatra 或 Web 开发(这是一个终生的旅程),而只是足够熟悉,以便在看到 Rails 应用程序时不会感到害怕。

While you're making your way through Sinatra, I strongly suggest you learn the basic concepts of HTML, CSS, and JavaScript at the same time. The best resource I know to learn front-end development is Free Code Camp. It's excellent. This should give you a good understanding of the fundamental building blocks of web applications.
当您学习 Sinatra 时,我强烈建议您同时学习 HTML、CSS 和 JavaScript 的基本概念。我所知道的学习前端开发的最好资源是 Free Code Camp。太棒了。这应该能让您很好地理解 Web 应用程序的基本构建块。

Learning Ruby on Rails 学习 Ruby on Rails

Books to Learn Rails

After you've been programming in Ruby for a while, have a basic understanding of how web applications work, and have preferably built a few, you're ready to learn Ruby on Rails, the framework you'll use most likely as a professional Ruby developer.
在您使用 Ruby 编程一段时间、对 Web 应用程序的工作原理有基本了解并且最好构建了一些应用程序之后,您就可以开始学习 Ruby on Rails,这是您最有可能作为专业人士使用的框架红宝石开发者。

To learn Rails, I recommend starting with The Agile Web Development with Rails book. Reading this book end-to-end and actually coding while you're reading will give you a great introduction to Rails.
要学习 Rails,我建议从《The Agile Web Development with Rails》一书开始。从头到尾地阅读本书并在阅读时实际进行编码将为您提供有关 Rails 的精彩介绍。

Next, you should read Michael Hartl's Rails Tutorial. Again, read it end-to-end and build the project in the book as your read it. Reading these two books and live-coding Rails apps will give you the confidence to build web applications on your own.
接下来,您应该阅读 Michael Hartl 的 Rails 教程。再次,从头到尾地阅读它,并在阅读时构建书中的项目。阅读这两本书和实时编码 Rails 应用程序将使您有信心自己构建 Web 应用程序。

At this point, you'll be curious to learn how Rails really works and more advanced features of it. To learn how Rails works, there's nothing better than reading the Rails source code.
此时,您将会好奇地想了解 Rails 的实际工作原理以及它的更多高级功能。要了解 Rails 的工作原理,没有什么比阅读 Rails 源代码更好的了。

For a deeper understanding of Rails, I recommend reading the latest edition of The Rails Way by Obie Fernandez. A warning: reading this book is a slog, as it's huge and covers almost all of Rails features in-depth. However, the trick is to read this book over multiple passes. Every time you read it, you'll learn a bunch of new things that you didn't get before. I'm currently on my third read of the book.
为了更深入地了解 Rails,我建议阅读 Obie Fernandez 撰写的最新版本的 The Rails Way。警告:阅读这本书是一项艰巨的任务,因为它内容庞大并且深入涵盖了几乎所有 Rails 功能。然而,诀窍是多遍阅读这本书。每次阅读它,您都会学到很多以前没有学到的新东西。我目前正在第三次阅读这本书。

Finally, to understand how Rails works behind the scenes, read Noah Gibbs' book: Rebuilding Rails. It's an excellent book that shows you how you can build your own web development framework. After reading this book, a lot of Rails magic started making sense to me. Highly recommended.
最后,要了解 Rails 在幕后的工作原理,请阅读 Noah Gibbs 的书:Rebuilding Rails。这是一本优秀的书,向您展示如何构建自己的 Web 开发框架。读完这本书后,我开始理解 Rails 的许多魔力。强烈推荐。


That's a wrap. I hope you enjoyed reading this post and plan to start reading at least one book from the above list.
这是一个包装。我希望您喜欢阅读这篇文章,并计划开始阅读上面列表中的至少一本书。

If you’ve read till the end, I’ve got something to ask you. Most of the people reading this blog are already experienced Rails developers, so you must be already aware of these books and know many points I mention above.
如果你读到最后,我有件事要问你。大多数阅读这篇博客的人都是经验丰富的 Rails 开发人员,因此您一定已经了解这些书籍并且了解我上面提到的许多要点。

What I ask you is that you share this post with someone you know who wants to learn to code but doesn’t know where to start. Whether it’s your retired mom or dad, your teenage kid, or your friends in finance or marketing who want to switch careers. As I mentioned earlier, there's a lot of bad advice on getting started in programming, and I think they'll find it useful.
我要求您与您认识的想要学习编码但不知道从哪里开始的人分享这篇文章。无论是您退休的妈妈或爸爸、您十几岁的孩子,还是您在金融或营销领域想要转行的朋友。正如我之前提到的,关于编程入门有很多不好的建议,但我认为他们会发现它很有用。

As always, if you have any questions or feedback, or would like to recommend more books, please leave a comment below or send me an email. I look forward to hearing from you.
一如既往,如果您有任何问题或反馈,或者想推荐更多书籍,请在下面发表评论或给我发送电子邮件。我期待着您的回音。

If you'd like to receive future articles directly in your email, please subscribe to my blog. If you're already a subscriber, thank you.
如果您想直接在电子邮件中接收未来的文章,请订阅我的博客。如果您已经是订阅者,谢谢。