4 ms·
Should I learn PHP or Ruby?
by yashodhan 17y ago
Should I learn PHP or Ruby?
- jrheard 17y agoJust like everything else, the decision's based on nothing but trade-offs. Here's my analysis. If you learn PHP: * You'll be able to see results running in your Web browser a lot quicker * Your knowledge will be really relevant if you're looking to work on slightly older, more established Web sites like Facebook or Yahoo!, but * You probably won't learn very good programming practices on your own - PHP has been pretty notorious for this, but maybe this has changed with PHP5, I haven't been keeping up. If you learn Ruby: * First you'll have to learn the language, and then you'll basically have to learn a framework like Sinatra or Rails before you'll be able to do awesome Web things * Your knowledge will be really relevant to most startup-style Web sites begun since 2005 or so (e.g. Yelp, which is written in Python, which is basically sort of like a sister language to Ruby, give or take) * You'll be much more likely to learn a lot of really good programming practices as you go that will serve you throughout your career. Having worked with both PHP and Ruby, I'd recommend Ruby, because I think it's easier to learn, it's more fun, and it's a better investment; I'm pretty sure most HNers would agree if given the choice between those two languages, but your sample of respondents is probably pretty biased :)
- yashodhan 17y agoThanks for the response. I'd prefer to learn Ruby over PHP but I'm hesitant because it seems like PHP has a larger audience / more documentation that would help me in my quest to create web apps. Googling for help with errors in PHP would be easier I imagine, seeing as more people know PHP. Also, there are a lot of existing PHP scripts that I could build off of. Those are my concerns.
- jrheard 17y agoThose are definitely reasonable concerns! PHP has been more dominant in the Web world for a longer period of time, that much is definitely certain, and there's a lot of resources out there already. I think this Google Trends chart captures my impression of the relationship between the two languages, though: http://www.google.com/trends?q=php%2C+ruby&ctab=0&geo=us&date=all&sort=0 http://www.google.com/trends?q=php%2C+ruby&ctab=0&ge... In addition, although you're definitely right in that there must be much more PHP documentation out there, you're not going to have much difficulty Googling for Ruby errors either - just because there will be fewer results doesn't at all mean that there won't be any. Just like in any other programming language mainstream enough to be considered a good language to learn on, any problem you have in that language will have already been experienced by someone else, and there'll almost definitely be an easily found Google result that'll solve that problem. If you're really on a quest to create web apps and you'd like to invest in knowledge that'll help you and your webapps grow, I'd really strongly recommend learning Ruby (or Python) over PHP. edit: on closer examination of that Google Trends chart, it looks like a good chunk of the Ruby results are from non-programming-related hits, but I'd still be willing to bet that the overall trend is the same.
- yashodhan 17y agoGreat points, solid advice - I can't thank you enough. You've given me a lot to think about and definitely helped stack a few chips in favour of Ruby. I'm a lowly web designer with many ideas for web apps that I'd love to implement/see implemented. Thanks again!
- jrheard 17y agoNo worries! I wish you the best of luck, and hope to see the fruits of your labors posted on HN one of these days! Also, for a well-worded counter-argument to one of my comments, see rick888's post above ( http://news.ycombinator.com/item?id=1163355 http://news.ycombinator.com/item?id=1163355 ).
- quizbiz 17y agoThen how should I get started with Ruby?
- jrheard 17y agoThat's the main topic of the post under discussion. I give some advice about your question in the "the email" section at http://jrheard.tumblr.com/post/421656059/you-yes-you-can-teach-yourself-how-to-program http://jrheard.tumblr.com/post/421656059/you-yes-you-can-tea... .
- bricestacey 17y agoProgramming Ruby 1.9, with the pickaxe on the cover. I am learning Ruby now and it seems good after 66 pages.
- jrheard 17y agoGood suggestion. A commenter on my post also recommended Chris Pine's "Learn to Program," which lives online at http://pine.fm/LearnToProgram/ http://pine.fm/LearnToProgram/ - I haven't looked at it in-depth, but it seems like it has potential.
- rick888 17y ago"Your knowledge will be really relevant if you're looking to work on slightly older, more established Web sites like Facebook or Yahoo!" Many newer sites are using PHP as well. PHP is used on established sites, but that just means that it's a proven concept. I also see many more jobs for php developers than Ruby (I have seen a few startups using ruby). "You probably won't learn very good programming practices on your own - PHP has been pretty notorious for this, but maybe this has changed with PHP5, I haven't been keeping up." I suppose this is true. But I think you can pickup good programming practices in any language. Another reason to learn php is because it uses a C-style syntax, which will make it much easier to transition to other languages like c/c++/javascript/c#/Java. Ruby uses a syntax all its own that you can pretty much only use in Ruby. I also don't feel people should be learning a programming language through frameworks. It's like learning how to add and subtract using a calculator. What beginners need to learn is programming concepts that they can use in any language.
- jrheard 17y agoYou've definitely got some valid points. I think I may be biased toward Ruby and Python because I like programming in them so much, in addition to the fact that I feel that my knowledge of them directly contributed to the quality and quantity of job offers I received when I was on the market. My enjoyment of programming in Ruby and Python may have something to do with them both being scripting languages, and having easily-accessible REPLs (for the uninitiated: Read-Eval-Print-Loops, like irb, a program I mention and show example output from in my post). In addition, scripting languages just... feel easier. If you've got Python installed on your computer, go ahead and pop up a terminal if you'd like to follow along: [jrheard@jrheard:~]$ python >>> import webbrowser >>> webbrowser.open_new('http://google.com') True If you weren't following along: Firefox just opened a new tab with Google in it! Isn't that awesome? How many lines would that be in C? >>> import urllib >>> goog = urllib.urlopen('http://google.com') >>> page_source = goog.read() >>> len(page_source) 6917 >>> page_source[:27] '<!doctype html><html><head>' The real power of Python and Ruby is that I can do awesome stuff without even thinking about it. At all. At least half the time I have a problem, the most I have to do is one Google search to find the built-in library I need. The point I'm trying to make is that, syntax aside, I feel like Python and Ruby just get out of my way most of the time, so I can focus on solving problems and learning programming concepts I can learn in any language. Jeff Atwood sums up a lot of my sentiments in his post "A Scripter At Heart", which you can read at http://www.codinghorror.com/blog/2009/01/a-scripter-at-heart.html http://www.codinghorror.com/blog/2009/01/a-scripter-at-heart... .
- samois98 17y agoSo I hear about scripts in web-based contexts, but also in get-repetitive-shit-done-on-my-computer contexts. What's good for that, and what would work on Windows machines?
- jrheard 17y agoWell, you've got a few options. Ruby and Python can both meet that get-repetitive-shit-done criterion, but you have to do a little extra work in order to get them install on Windows last I checked (although Ruby offers a one-click installer, which you can download via http://www.ruby-lang.org/en/ http://www.ruby-lang.org/en/ ). Your other option would be to google "windows batch file", which is basically Windows' native way to write scripts. You may have other options, and hopefully someone can correct my misconceptions and fill in the gaps where I didn't mention a good option. In any case: Ruby (and Python too, as it turns out: http://www.python.org/download/windows/ http://www.python.org/download/windows/ ) offer installers for Windows and can get repetitive shit done, and are pretty fun to write, so I'd recommend you take a look at either language. I use Python myself.
- sbhat7 17y agoPython. http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-00Fall-2008/CourseHome/index.htm http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Compute...
- Tichy 17y agoJavaScript