6 ms·
Learning Rails – or not as the case may be
- thehodge 16y agoIt's a post from my own blog, but I'd really be interested in what HN thinks (are any others in the same position or have they been and how did you get out of it)
- oceanician 16y agoIs it the next 10 mins. The next 2 tutorials that you're after? Always considered the first 5 mins pretty well documented, but then after that you're in a requirements driven area, of I need my app to do xyz. How can I get it there. I guess my thoughts are what are you trying to achieve with your next tutorial in Rails? I'm guessing you've found RailsCast?
- apotheon 16y agoI found Ruby itself a lot easier to learn than Rails, actually. Try doing some plain ol' Ruby learning instead. You know at least a little programming, so I'd recommend starting with Everyday Scripting With Ruby rather than with Learning Ruby. I don't know much about the more recent editions of Agile Web Development With Rails, but I have a copy of the first edition. In it, Appendix A is Introduction to Ruby. That introduction is about useless to someone who doesn't know any programming, but provides an easy, quick familiarization with the basics of how Ruby (the language, as opposed to Rails the framework) works. If you have access to a copy of the book that has such an Introduction to Ruby appendix, combining that with Everyday Scripting With Ruby makes for a very effective start in the language for those who already dabble in programming. I'd recommend starting out on a Unix-like platform, and using Ruby to automate small tasks as a way to get used to using the language. While you're at it, learn the OptParse core library, which is great for adding command line option handling to your utilities, as well as help output. If you want to migrate from there to simple Web coding, you do not necessarily have to jump straight into Rails or any other framework. You can do CGI programming in Ruby, or you can use eruby to do template-based development much like the basic means of using PHP on most Webhosts. edit: Wow. Maybe I should write a book introducing people to Ruby.
- thehodge 16y agoThanks, I'll definitely checkout that book :)
- auxbuss 16y agoSince you know PHP, why not spend some time using a PHP-type framework, say yii. Once you have the MVC framework thing down, Rails will make a lot more sense. Small steps.
- thehodge 16y agoSmall steps is exactly what I'm after but I guess in my mind, to keep going I need to convince myself I'm making progress
- apotheon 16y agoThis is a common problem in programming books and tutorials, from what I've seen. They all seem to adhere to a false dichotomy, as if there is no choice other than "small steps but no reward for a long time" or "big, huge steps, each with a payoff". This is one of the reasons I believe that more focus on Unix-like command line development early on, with real-world usable functionality as the goal of such development, should be more of a part of general-purpose programming language tutorials. Learning the "right" way to include command line option handling, and learning how to build filter utilities, should be near the beginning of every major tutorial. These skills provide the student with the basis of a lot of novice-level exploratory programming that would be of real, practical use to the larval programmer.
- joshuacc 16y agoPersonally, I recommend http://railstutorial.org/ http://railstutorial.org/ That moved me further along the path to understanding Rails than any of the other books or tutorials I tried. Still not there yet, but closer.
- thehodge 16y agoI'd never seen that before... will put it on the of things to checkout, thanks
- Groxx 16y ago>So I started to look back at why I’m having such a hard time learning when I picked up PHP and ran with it so quickly, again partly its because RoR have a much greater complexity rating (in my mind) that just plain procedural PHP but heres the biggest issue I have... Rails tutorials are too long... Try comparing RoR to a similarly-complex PHP framework. You'll find they all require a lot more groundwork to be able to do Random Thing X regardless of what X may be than a bare-bones PHP / Ruby / what-have-you implementation. But that's normal. Essentially any framework necessarily increases the breadth of things you must learn to do what you want - languages are simple. The advantage is they trade that increased breadth off for decreased depth - you don't need to know how to write a JSON parser or crypto code or ORM logic to be able to use it. As apotheon mentions, give Ruby a try on its own, it's a heck of a lot simpler, and the core library is by far the most brain-friendly I've encountered. If you need things to do with it, you can always try http://www.projecteuler.net http://www.projecteuler.net . edit: geh. I always type .com first :\
- trustfundbaby 16y agoGoing from just PHP to Ruby on Rails requires a huge change in Mindset that isn't apparent when you're starting out. Rails is a framework that is much larger than Ruby the language, so understanding why certain things work the way they do is a very important part of learning it. I feel particular empathy for you because I absolutely hated the 'Agile Web Development with rails book' too. Here's my suggestion ... Get 'Simply Rails 2' (I'm assuming the project you're working on is in Rails 2 not 3) ... work through it, then move on to 'The Rails Way' by Obie Fernandez. If you're really serious about it, getting through the first one should set you up for success ... Obie's book will take a while go go through, because you're going to keep reading and re-reading things as you code.
- rbranson 16y agoWhile reading this, I kept having flashbacks to PHP code written by lazy developers that didn't take the time to learn either PHP or MySQL very well. They would do things like use MySQL to format dates (paraphase: mysql_query("SELECT FORMAT_DATE(" . $date . ")")), because that's just what they remembered, and didn't want to take the time to find the right PHP function. Of course, there's always the opposite side of the same coin, like where they'd use loops of PHP code, executing hundreds or thousands of SELECT statements, instead of just learning how to use a JOIN. EDIT: Just to be clear, I'm not implying that the author produces this kind of code.
- thehodge 16y agoIt's not THAT bad, I'd say two or three steps up from that ;)
- seldo 16y agoAs a PHP developer, I found learning Ruby and Rails at the same time too much. I went back to PHP, learned MVC in a language I was familiar with, and then when I went back to rails it was clear which bits were Rails features and which bits were Ruby language constructs. Of course, I then decided that I didn't like Rails enough to put up with its performance issues, and went back to writing MVC in PHP, so I may be a bad case study. (I hear RoR 3.0 is much better performance-wise, but my current solution works well enough that I'm not interested in trying it out again)
- regularfry 16y agoI found precisely the opposite. Because it was relatively quick to get something impressive working in Rails, it didn't matter to me initially which bits were Ruby and which were Rails. That all came later.
- sunkencity 16y agoComparing rails to just plain PHP pages - yeah, rails is VERY MUCH MORE COMPLEX. The rails 3 project is like some 2500 files and I dunno how many lines of code. There's great benefits in using a framework, most of which is consistency and no need to write the boilerplate functions. Here's a few things to think of: 1. When using a framework you can treat it like a black box, you don't actually need to know how it works, but you need to have a good enough idea of how it could work - that's why so many people roll their own framework in the beginning of their career - it's very useful to have done that. 2. Do you know Object-Orientation works? Can you program object oriented code? I did a lot of programming before I knew OO and could just not understand a single line of object oriented code (that I sometimes had to write in perl using the godawful OO syntax at that time). I just poked at that code until it worked, but I had no way of understanding the code. Took a class in OO programming at the university and it was dead easy after that. I suspect that it would be VERY HARD to grok rails without being able to code object oriented code. 3. Perseverance - for me learning new programming languages and environments always includes making the code work first and then understand. Programming is a practical thing, it either works or not works and the theoretical understanding is just a tool that's more or less useful. You'll just have to keep on working on it until it runs and then try to understand what you have done, you might not even have to understand how rails works, you just have to know enough where to put stuff and have enough experience to know what to do.
- drdaeman 16y agoAlmost a cliché — comparing simple (and poor-designed, in this case) language to a complex framework. If we'll try to compare — PHP is just a quite thin layer above HTTP — you get $_REQUEST/$_SERVER and you write data back. So it's easy to learn "ground-up". Compared, Rails is an extremly complex infrastructure filled with lots of magic. So, the only way for newbie to learn it is to write code without understanding how they work internally — it would take too much time to do it the other way. And when you learned PHP (then invented your own "DB abstraction layer module" bicycle, haha; then learned some simple framework; and so on...) you expect to learn Rails the same way, which is almost impossible due to its complexity.