Live data from Hacker News

Object-Relational Mapping is the Vietnam of Computer Science

codinghorror.com

21–29 of 29 posts

Re: Object-Relational Mapping is the Vietnam of Computer Science

#21
post #18

Earlier quoted context omitted.

Yes, dict is a hash map. A python dict is not "typeless", it contains whatever python objects you put in it. Most client drivers/libs for RDBs have basic type conversions for each language. You don't always need an ORM for this. If you have a ruby or python Time object, the low level db lib generally will convert it to/from the RDB format. I've used both simple and complex mapping methods. At the moment, I'm using mo…

Most client drivers/libs for RDBs have basic type conversions for each language. You don't always need an ORM for this. If you have a ruby or python Time object, the low level db lib generally will convert it to/from the RDB format. Didn't know that. If that's correct, then the low-level db lib is an ORM in Python. In which case SQLObject/SQLAlchemy probably just harnesses those features and adds some additional crea…

Most all low level rdb libs provide basic type conversion from allowed types in the db to type fitting the language you are using. From these libs you send SQL (any SQL you care to send) and you get returns of a "row" or a cursor usually.

An ORM adds stuff on top of the driver. General these frameworks provide relationship management, connection pooling, caching, and config management.

Re: Object-Relational Mapping is the Vietnam of Computer Science

#22

Earlier quoted context omitted.

The arguments in Atwood's and Neward's articles stand well on their own. The war analogy is there as link bait.

The Vietnam analogy is bad in many respects but I can see where they're coming from. ORM was a battlefield, many faught hard (including myself) and ended up walking way disgusted and defeated at the same time.

In what respects is the Vietnam analogy less meaningful than the rather banal battlefield analogy that you just made?

Re: Object-Relational Mapping is the Vietnam of Computer Science

#23
post #5

Talk about making a mountain out of a molehill. At my company, we don't try to turn database rows into objects. Here is how it works: * we use Python+MySQL * each table has an associated class, a CRUD-API if you will * a cursor object accesses a table like this: cursor.TableName.select_by_ids(low, high) * removing means set time_removed to the current timestamp * rows are returned as lists of dicts So the solution to…

Why reinvent the wheel? An ORM will do all of that for you.

Re: Object-Relational Mapping is the Vietnam of Computer Science

#24
post #15

Neward's article is here: http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Compute... There is a post elsewhere on HN that links to the wrong article. You have to skip forward a bit to get beyond the history of the Vietnam War to get to the meat. The gist of the post is that there is a fundamental impedance mismatch between OO and Relational. If you try to apply inheritance to relational databases you get an unho…

Yes, a mismatch exists and can lead to compromises as you try to use the object paradigm to glue the two layers together. But the benefits are also undeniable, primarily that of productivity gained during development by not having to concern yourself with the job of mapping types between the two layers.

Re: Object-Relational Mapping is the Vietnam of Computer Science

#25
post #22

Earlier quoted context omitted.

The Vietnam analogy is bad in many respects but I can see where they're coming from. ORM was a battlefield, many faught hard (including myself) and ended up walking way disgusted and defeated at the same time.

In what respects is the Vietnam analogy less meaningful than the rather banal battlefield analogy that you just made?

I didn't mean to say that it was less meaningful. My battlefield was meant to be a Vietnam battlefield, not some alternative or better analogy. I'm defending Neward's analogy up to a point. Any war analogy of course misses the humanitarian horror that is a war. That's why it's always a problematic analogy as well.

Re: Object-Relational Mapping is the Vietnam of Computer Science

#26
post #17

What is an object, anyway? An object is a piece of data in memory, a set of fields and a set of pointers to other pieces of data. It's a live object in a small, closed world that is consuming a portion of a finite amount of resources. Consider the data in any kind of database - a traditional RDBMS or a triple store, data in such structures is much larger and cannot be loaded into RAM for querying, so indexes must be…

Usually the ORM has some notion of "associations" between models so that the data relationships are easier to navigate from the application side.

Re: Object-Relational Mapping is the Vietnam of Computer Science

#27
post #18

Earlier quoted context omitted.

Most client drivers/libs for RDBs have basic type conversions for each language. You don't always need an ORM for this. If you have a ruby or python Time object, the low level db lib generally will convert it to/from the RDB format. Didn't know that. If that's correct, then the low-level db lib is an ORM in Python. In which case SQLObject/SQLAlchemy probably just harnesses those features and adds some additional crea…

Most all low level rdb libs provide basic type conversion from allowed types in the db to type fitting the language you are using. From these libs you send SQL (any SQL you care to send) and you get returns of a "row" or a cursor usually. An ORM adds stuff on top of the driver. General these frameworks provide relationship management, connection pooling, caching, and config management.

According to the Wikipedia definition of ORM, it's primarly about the mapping of types:

Object-relational mapping (ORM, O/RM, and O/R mapping) in computer software is a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages.

http://en.wikipedia.org/wiki/Object-relational_mapping

Re: Object-Relational Mapping is the Vietnam of Computer Science

#28
post #27

Earlier quoted context omitted.

Most all low level rdb libs provide basic type conversion from allowed types in the db to type fitting the language you are using. From these libs you send SQL (any SQL you care to send) and you get returns of a "row" or a cursor usually. An ORM adds stuff on top of the driver. General these frameworks provide relationship management, connection pooling, caching, and config management.

According to the Wikipedia definition of ORM, it's primarly about the mapping of types: Object-relational mapping (ORM, O/RM, and O/R mapping) in computer software is a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages. http://en.wikipedia.org/wiki/Object-relational_mapping

Thats a pretty decent definition. I think their phrase "incompatible type systems" is meant for you to stress the word systems. The word type is not needed. Not to be confused with "type of an object, i.e. its class".

If you really want to know what's in various lower level drivers, as opposed to ORM frameworks (which vary quite a bit themselves), just go crack open some code and look at the APIs for yourself. You can go pretty far back to MS ODBC libs or even vendor dependent Oracle libs from mid to late 80s and see they were used quite effectively on their own for many years. JDBC was fairly straightforward derived from these predecessors.

Re: Object-Relational Mapping is the Vietnam of Computer Science

#29
post #5

Talk about making a mountain out of a molehill. At my company, we don't try to turn database rows into objects. Here is how it works: * we use Python+MySQL * each table has an associated class, a CRUD-API if you will * a cursor object accesses a table like this: cursor.TableName.select_by_ids(low, high) * removing means set time_removed to the current timestamp * rows are returned as lists of dicts So the solution to…

Why reinvent the wheel? An ORM will do all of that for you.

yes, an ORM will do all that and then some. Sometimes you don't want the extra stuff. I'm not knocking ORMs. They serve their purpose. Sometimes all I need though is a simple lower level driver.
Post reply on HN