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

It's about convention over configuration.

Learn a few conventions (not hard) and there you go. In some ORM's, the magic findByX functions will do no joins -- in others it will do all joins. And learning which is quite easy.

And almost universarlly, the findByFooAndBar type magic methods are not the most commonly used feature because often you need complex conditionals (let alone complex joins). But when you do need just a quick record, it's wonderfully easy.

You can get cozy with an ORM in an afternoon. After that, you've got nothing ahead of you but timesaves. Sure, sometimes the ORM abstraction will break or you'll find yourself fighting it. So at that point you use the ORMs connection manager to execute some raw SQL and be on your way.

Your argument, to me sounds as wrong as if you said "I don't like MVC frameworks. Without a frameowork, I know that when I go to www.example.com/path/to/index.php I know exactly what is being called.

But in an MVC, www.example.com/path/to could be anything! The routing engine and framework hides away what it's doing.

But I use it because it's not really as opaque as you portray, and it saves me SO. MUCH. TIME.

And once you learn convention, the ORM makes it EASIER to grok any codebase that uses it than it would if they used straight SQL.

Anyway, as always, YMMV and I respect your fence-riding. I've used some unfortunate ORM's before (CakePHP I'm looking at you! Adopt Doctrine!) where instead of writing a simple query I'm stuck crafting some insane nested dictionary structure.



Do you recommend any particular good (free preferably) ORMs to practice with? Never used one before in my day to day job :(


Really I'd find the best one for whatever language you're strongest with.

My absolute favorite, bar none, is Ruby's DataMapper.

In PHP, the best ORM project is certainly Doctrine. Doctrine can be a little overwhelming at first, but it's worth it. However if you found yourself just not pursuing it because of its complexity, I've found that the Kohana framework has a quaint, easy to use ORM. Not a bad start.

In Python, SQLAlchemy is great.

In .Net obviously LINQ.


> In .Net obviously LINQ.

LINQ is not an ORM. There is LINQ to Objects and LINQ to XML, which query collections and XML documents respectively.

The first ORM over Linq from Microsoft was Linq to SQL. This is now deprecated, and the second one is called Entity Framework (EF), which was a more ambitious but slower-moving project. In the latest release, EF 4.1, it's actually quite good.

NHibernate is still very popular, in part because over the confusion over Linq to SQL and EF, in part becuase it was there first and is very mature.

There are a whole lot of other, less-well-known .Net ORMS - SubSonic, SimpleData ... just google ".net orm". But for new work, most people would only consider EF and NHibernate.

There's even a Linq to NHibernate:http://ayende.com/blog/4083/nhibernate-linq-1-0-released

That and fluent NHibernate take some of the pain out of configuring NHibernate.


.NET also has NHibernate. I'm not intimately familiar with the pros/cons of LINQ to SQL vs NHibernate, but I believe it gives you a lot more control over things like pre-loading associations, etc (while requiring a lot more configuration).


One con of LINQ to SQL is that it only supports MS's DBs. LINQ to Entities is the more flexible version. Though you have to go whole hog and use Entity Framework. There is also a active record implementation for .NET called castle active record.


> One con of LINQ to SQL is that it only supports MS's DBs.

This is not true for Entity Framework (which is essentially the newest iteration of Linq2Sql.) I have successfully used EF with SQLite in production, and it appears to have a MySQL driver as well (I honestly don't know how well the MySQL driver works.)


That is what I meant by LINQ to Entities, which is what I thought they were calling the new version. There are plenty of DB drivers(I think they call them providers) for EF.


I've been using datamapper recently - I like it, but would be interested to hear what makes you like it so much over the others (which I haven't used, except for a smattering of ActiveRecord).


I'm a Doctrine user as well, and I've been using it for years now. But I still stand by what I said. Mostly it's a result of finding that regardless of the ORM being used, knowing SQL is still required for anything serious (or, not knowing SQL can hurt).




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

Search: