我但愿Ruby程序员一年前就告诉我

What I wish a Ruby programmer had told me one year ago

One year ago, I started coding for real again. I dumped wasting times on stupid games and so on. I like building websites, so I started by going back to the roots. HTML & CSS which I had coded when I was about 10, and it didn't take me long before I had moved from tables to div tags and all. I learned myself to hand-code it, and not rely on software like Dreamweaver. Resulting in better, more compact and valid HTML. I had played around with PHP when I was about 11, so I decided to build some stuff in it again. linux

一年前,我从新开始真正的编码。我再也不浪费时间在愚蠢的游戏或其余事上。我喜欢建设网站,因此我又返回了个人老本行。我10岁时就编码 HTMLCSS了,很快我就掌握了从表到DIV标签和其余全部东西了。我学会手工编码,不依赖Dreamweaver. 这样能获得更好,更紧凑,更有效的HTML。我11岁就开始玩PHP了,因此我决定再用它建立点东西。 git

I should never have done that, I have realized. I used about 4 months in PHP, picking up bad habits. At some point, I found myself reaching points where I saw PHP solutions plain stupid. I didn't have experience with any other languages, but I knew there had to be better ways. So I decided to dive into Python, and later look at the Django web framework. So I did. 程序员

我已经意识到我不应那么作。我用了约4个月的PHP,染上了坏习惯。有时,我发现本身接触到了不少愚蠢的PHP解决方案。我尚未使用其余语言的经验,但我知道必定有更好的办法。因此我决定专研Python,而后看Django Web框架。 我作到了。 github

After a few days playing around with Python, I felt okay with it. I didn't love Python, but it was fairly simple, and from the simple Django examples I felt confident I was ready to proceed and expand my literacy in Python via Django. After following the basic tutorials, I felt Django was already superior to PHP. web

玩了几天Python后,感受不错。我不喜好Python,但它至关简单,并且经过简单的Django示例,我很自信,我想我已经准备好继续扩充个人Python知识了,经过Django. 跟随基本教程学习,我感受Django早已优于PHP编程

I had heard about this evil language called Ruby and some framework called Rails, I had not considered it though because of three (stupid) reasons: ubuntu

  • Highest ratio of smug fanboys windows

  • End-statements ruby

  • Ruby had become popular due to Rails, not the other way around as it is with Django app

我据说过一个邪恶的语言,称为红宝石,还有个叫做Rails的框架,我之前从未考虑过它,由于3个(愚蠢的)缘由:

* 有不少自觉得是的家伙

* End来结束语句

* RubyRails变得流行,而不是其余的东西,就像Django

So a Saturday night, I turned off the light, locked the door and sealed the windows. It was time to check out this Japanese creation. The fanboys all over the web seemed to recommend this fabulous book called Why's (poignant) guide to Ruby. I installed Ruby, and dove into the book.

因而,一个星期六的晚上,我关掉灯,锁上门,密封窗户。开始检查这个 日本创造 的东西。全部网上的粉丝彷佛都推荐这个神话般的书叫 为何(辛酸的)转向Ruby.我安装了Ruby,一头扎进书里。

A few hours later, I had forgotten everything about Python. Stupid language. Ruby was where it was at, and I instantly started recommending it to all my code-buddies. It's such an awesome language, why not spread the joy? They said I was a fanboy, and told me to gtfo. And I quickly realized what had happened.

几个小时后,我已经忘了一切关于Python的东西,那个愚蠢的语言。 Ruby才是我要的,我马上开始推荐给我全部的代码哥们。它是个如此棒的语言,为何不传播喜悦呢?他们说我是变形金钢,叫我滚开(GTFO: Get The Fuck Out). 我很快意识到发生什么事了。

Ruby is evil

Ruby is indeed evil. So evil. Extremely evil. But why so evil? Because it's so beautiful. The syntax is so elegant, everything are objects. Everything makes sense. The Ruby-way of doing things is so sexy.

Ruby很邪恶。

Ruby真的很邪恶。如此邪恶,邪恶之极。但为何如此邪恶? 由于它是如此美丽。语法是如此优雅,一切都是对象。一切都很在理。Ruby的作事方式是如此的性感。

 I quickly headed over to #ruby and asked them what I should do to practise my all-so-awesome Ruby skills, and some guy recommended me coding a todo-app. It seemed it was the new semi-advanced-but-no-so-advanced hello world. So I did, and here's the extremely awesome output (be prepared, it's extremely bad code and you should NEVER do something like this in Ruby):

我赶忙冲到#ruby问他们,我应该作什么来练习个人极棒的Ruby技能,一些人建议我编个待办事项的应用,这看上去是个稍微先进又不很先进的HelloWorld. 我作了,这里是很是可怕的输出(有心理准备,这是极其恶劣的代码,在Ruby中,你永远不要这样作):


Proudly I showed it to the guy who recommended me to create a Todo-app. "Look at this! Ruby is so narwhal!" It took him a while to reply. It would've taken me a while to reply too if somebody showed me such code. It looks like some Bash code, in an object oriented language. Woah. So this guy, he was very helpful and told me he'd make a skeleton for the app. and make me fill in the holes/methods, it was something like this:

我自豪地展现给 推荐我作todo-app的家伙。“看这个!Ruby是个独角兽!". 他花了段时间回复我。若是有人向我展现这种代码我也会花一段时间。它看起来像一些Bash代码,在一个面向对象语言中。哇。原来这家伙,真有用处,他告诉我他作了一个应用的骨架,让我去填孔/方法。它是像这样的东西:


So I did. It took a while to adapt from the bad PHP-style, to the Ruby-style. I ended up with this. And then I added an interface. And then meta-programming. And then I was in love.

我作了。从坏的PHP风格适配到 Ruby风格花了一下子工夫。我就这样结束了这个填空。

而后,我增长了一个接口,而后再元编程,而后我坠入爱河。

So the title of this post is "What I wish a Ruby programmer had told me one year ago..", and that's quite an intro. Since what I wish a Ruby programmer had told me is not much, but could've saved me 4 months in company with PHP.

因些 这篇文章的标题是 “我多但愿Ruby程序员一年前就告诉我”,那是多好的前导。即便我但愿的Ruby程序员没告诉我那么多,但至少能节省我4个月的在公司使用PHP的时间。

Here's what I'll tell anyone asking me how they should get into programming:

 "First, learn Ruby (buy a book). Play around, create a Todo-app. Create simple programs to handle system tasks for you. But always remember to use classes, and separate the interface from the functionality. In the end this will be pain, you'll always think about making it appear Rubyish, but at some point - it becomes natural. And when it has become natural, you go create a Gem. If you create a big Gem, with much functionality - split it into more Gems, and make it require those. Or use other peoples Gems. If you want to move on with developing web applications, start out simple. Check out a lightweight framework like Sinatra, it's cool and very fun to work with. Move on to Rails if you want, it takes longer to learn, but it is much faster to develop in."

这里就是我告诉 任何问我如何踏入编程行业 的人的话:

“首先,学习Ruby(买一本书)。玩弄,作个待办事项应用。为本身建立一个简单来处理系统任务的程序。但永远记住要使用类,并且要从功能分离出接口。最后这可能会痛,你老是思考如何让化更Ruby化,但有时,它会变得更天然,并且这种作法已成为天然时,你去建立一个Gem(宝石,译者注:相似库),若是你建立一个大Gem,有许多功能,把它分割成多个Gem。而后require它们。(译者注:相似include/import)或者使用别人的Gems。若是你想转而开发Web应用,从简单的开始,下载轻量级框架,如Sinatra.它很酷也颇有趣。若是有须要,你能够转到Rails,它须要更长的时间学习,但它开发得更快。

And perhaps point them towards Linux, if they are up for it:

"I do not believe Windows is the best development platform in the world for Ruby. I recommend you to try out Linux (or OS X, if you've got the money for it). Start with a simple distribution, like Ubuntu. And then I recommend something like Arch Linux whenever you feel like you are ready for something more advanced, assuming you want to learn more about how Linux works!"

也许会让他们转到Linux,若是他们承认的话:

”我不相信Windows是世界上最好的Ruby发展平台,我建议你尝试Linux(或OS X,若是你已付钱),从一个简单的发行版开始,像Ubuntu. 当你感受能够准备学习更高级知识时,我建议你改用相似Arch Linux的系统,假如你想学习更多关于Linux如何运行的知识。

Note: I'm biased. And I know it. Ruby is not a language for everyone, and PHP is not a bad language - it's just not for me. Neither is Python a bad language - it's just not for me. Windows is not a bad operating system - It's just not for me. I advise you to try different languages/operating systems, and eventually find the one you feel at home in.

注:我知道我有些偏见。Ruby不是对每一个人来讲都是好语言,PHP不是坏语言,只是它不适合我。Python也不是个坏语言,只是它不适合我。Windows不是个坏系统,只是它不适合我。 我建议你去尝试不一样的语言,不一样的系统,并最终找到一个最适合本身的。

相关文章
相关标签/搜索