Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not a Rails developer...but it doesn't seem like rails should have a "new blog" command at all. Rails is a web framework. Frameworks are supposed to take care of all those annoying intricacies involved in building a web site. That would be things like URL mapping, routing web requests, handling gets and posts, talking with the database, session persistance...

A blog, on the other hand, is an application that should be written on top of all this. It would make more sense to me include this as an example application.

It seems pretty obvious to me that the intent of creating the "ruby new blog" command was to make it extremely easy to install the example blog app. However, by doing this, they are marketing rails as a magical framework. The framework auto-generating you a whole blog isn't really a good hello world program; it didn't teach me anything about how rails works.

I remember back when ruby first came out (I'm sure a lot has changed since) I was watching videos that introduced it, and every time the presenter would say something like "Hey you want a blog? Just type magic make me a blog command, and now you have a fully functioning blog with a built in CMS." I remember thinking to myself, "but I'm not building a blog" and then I went back to my PHP. I'm not saying this was the correct reaction, perhaps I should have instead gone and investigated it further, but that's how it was marketed, and I found it off-putting.



"rails new blog" doesn't create a blog, it creates an empty Rails 3 project using a SQLite database backend called... "blog".

> I remember back when ruby first came out

I think you meant Rails here (not sure if you can edit HN posts). Ruby's been around since the mid-90s.

> I remember thinking to myself, "but I'm not building a blog" and then I went back to my PHP

This makes me think that you're not using a MVC framework. PLEASE, please spend 30 minutes researching MVC and conceptualising the models behind your application talking to each other.

In plain PHP, you would run a SQL query to see if a user can reply to a blog post. In a MVC framework (such as Rails), you would ask the user itself in a higher-level manner:

if @user.can_reply_to? @post

This helps keep your views clean and all your business logic separated out. Views should contain no logic, controllers should contain as little code as possible to grab model data and anything else needed to show in the view, models should be where all the magic happens.


"Views should contain no logic, controllers should contain as little code as possible to grab model data and anything else needed to show in the view, models should be where all the magic happens."

This is exactly right, and diametrically opposed to J2EE "best practices," where pretty much every model "object" ends up as a Java Bean with a no-args constructor, public accessors for every field, and no business logic whatsoever. And to think they have the nerve to still call this "object oriented programming."


I have no Java experience aside from playing Minecraft and running OpenOffice, but I feel like I dodged a bullet by avoiding it as a programming language/platform. Everything I've ever read about it makes it feel extremely overwrought and bloated.

I'm perfectly content with the Smalltalk-inspired object model Ruby uses. :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: