
Problems with Object/Relational Mapping (2006) - jwdunne
http://blogs.tedneward.com/post/the-vietnam-of-computer-science/
======
neilk
It's a good description of the problems of ORM and their possible resolutions.

Personally, I prefer to interact with a relational database via a good query
builder. The advantage of a query builder is that you inevitably end up with
dozens of slightly different queries. With a query builder you can make a
query just like another, but with slightly different constraints or joins or
whatever you like.

You can then populate objects with said queries when it make sense, and do
other non-objecty operations like reporting and search. The entire point of an
object system is to reduce coupling, so IDK why people are so eager to tightly
couple their programming model to storage.

But about the Vietnam part... really, that's a shocking analogy. The overlong,
painfully US-centric military history part could be completely excised. I
didn't even understand the title at first. Vietnam is not solely defined by
America's failed attempt to ~~napalm it into submission~~ nobly preserve
democracy.

~~~
igkgudtzucf
I was dating a Vietnamese woman a little while ago. This eventually,
inevitably came up. It is extremely difficult to defend a US policy that
measures "success" as a body count metric. The Vietnamese people vividly
remember this, I don't think it's appropriate to make flip comparisons to a
humanitarian catastrophe perpetrated by people the likes of Henry Kissinger in
multiple countries, with body counts of millions.

------
ThinkBeat
The Vietnam analogy is just in bad taste and does not add much to the article.

~~~
averagewall
We're trained not to compare things to the holocaust because it's in bad
taste. Somehow lessons of how to treat other people don't translate from case
to case. Us soldiers in Vietnam were supposed to be bad people doing inhumane
things but US soldiers in Iraq somehow aren't. History keeps repeating and
even though we remember it, we always think this time is special.

~~~
ido
I'm most often hearing about the Iraq war in terms of "bad things <coalition
forces> did". Not sure where you get the positive-sounding perspective (the
most positive thing I ever hear is "Saddam was even worse").

~~~
jorgec
Satan Hussein. He was considered even worst than Hitler and soldiers carried
freedom to Iraq, how the army was called? freedom coalition force). It was the
opposite.

~~~
ido
Yes he was terrible. But the situation hasn't actually improved for the
average Iraqi compared to before he war.

~~~
tome
I think jorgec was being sarcastic.

------
PaulHoule
This is an old article and much has changed.

ORM frameworks in many languages such as Ruby, Python, Java, etc. have
improved enormously since that time. I think they'll continue to improve as
metaprogramming facilities improve, it is very feasible to convert an
expression like 'x>2*y-7' from conventional programming languages to SQL and
other query languages.

Also there is immense interest in document databases such as CouchDB,
Marklogic, Elasticsearch, DynamoDB, etc. These solve some of the problems of
object-relational mapping, and we will someday see new frameworks.

~~~
eropple
ORM frameworks in the languages you listed primarily act as mutating state
functions. So, to be honest: no, they haven't improved enormously at all.

If your framework doesn't work first-and-foremost on immutable objects on
which defined state transforms can be applied, you're putting your foot in a
bucket that's very hard to extricate yourself from.

Data mappers are pretty much the only reasonable mode, it seems. And they
kinda suck, but they suck much less.

~~~
specialist
ORMs tip over once your queries have joins.

~~~
WalterGR
Which ORMs don't?

------
fizixer
ORM is the Vietnam of Computer Science, because OOP is the Vietnam of Computer
Science: A 25-year failed experiment in boosting productivity of masses of
mediocre programmers using this one true silver bullet.

~~~
booleandilemma
Hi, mediocre programmer here.

OOP is the most popular paradigm because it works the best for the greatest
number of people and projects. It's natural to break large systems into
component parts recursively, and to let components have their own state.

What alternative did you have in mind? Functional programming?

~~~
naasking
> OOP is the most popular paradigm because it works the best for the greatest
> number of people and projects

It's a novice mistake to think the solution that wins out is the one with the
most technical merit. Virtually nothing is truly meritocratic.

> It's natural to break large systems into component parts recursively, and to
> let components have their own state.

That's just modularity. Nearly every language has it, and OOP is merely one
way to achieve it.

~~~
seanmcdirmid
What other paradigm focuses on components with encapsulated state? Definitely
not functional! Isn't any nounish "thing" with state an object anyways? Why
else could it be?

~~~
naasking
1\. You don't want components with encapsulated state at every level of your
system.

2\. Where you do want them, like at coarser service boundaries, virtually all
general purpose languages have modules of some sort.

~~~
seanmcdirmid
1\. Sure, most system are not made purely out of functions or purely out of
objects.

2\. If a module has state, is it not named with a noun, is not an object even
if we try calling it an entity, an actor, or anything else?

~~~
naasking
> If a module has state, is it not named with a noun, is not an object even if
> we try calling it an entity, an actor, or anything else?

But we're talking about OOP, which is characterized by specific logical
properties surrounding modelling, encapsulation and extension, not about
colloquial terms like "objects" that are referred to by nouns.

Conflating colloquial language with the programming language is one of many
reasons why OOP seems seductive but is often misleading.

------
jancsika
> Johnson’s successor, Republican $g(Richard Nixon), tried several tactics to
> bring pressure to the NVA/VC forces to bargain [...]

One such tactic the author fails to mention was the successful effort to
undermine Johnson's peace negotations by doing illegal covert dealings with
the South Vietnamese through Nixon's underlings. Nixon was undermining the
negotiations between the U.S. executive branch and North/South Vietnam when
Nixon was still a candidate, encouraging the South to hold out until after the
election.

You can read about it and much more in Christopher Hitchens' "The Trial of
Henry Kissinger." Regardless of one's opinion of Hitchens, he refers to
unclassified documents and many other reputable sources in his section on
this.

The only reason I mention it here is because the author has attempted to flesh
out an analogy with what I must assume were supposed to be the salient details
of each item being compared. To do that and leave out the fact that a
presidential candidate undermined the acting president's effort to end the war
is quite strange.

Also, I'd be interested to hear the author explain what "regular violations of
nearby Laos and Cambodia" actually means.

~~~
cariaso
In case the author doesn't show up, I'll offer

"There were more than 580,000 bombing missions on Laos from 1964 to 1973
during the Vietnam War. That's equivalent to one bombing mission every eight
minutes, 24 hours a day, for nine years. Over two million tons of ordnance was
dropped on the country, with up to 30 per cent failing to explode as
designed."

[http://www.maginternational.org/the-problems/the-uxo-
problem...](http://www.maginternational.org/the-problems/the-uxo-problem-in-
laos-statistics/)

More than 40 years after the war, one-third of the country is still
contaminated by unexploded ordnance — an ongoing cost of war that affects the
Lao people daily.

video at [http://abcnews.go.com/International/americas-secret-war-
laos...](http://abcnews.go.com/International/americas-secret-war-laos-
uncovered/story?id=41968017)

also a worthwhile visit
[http://www.cambodialandminemuseum.org/](http://www.cambodialandminemuseum.org/)

There may be many other violations, but I think that's a credible start.

~~~
tome
> also a worthwhile visit
> [http://www.cambodialandminemuseum.org/](http://www.cambodialandminemuseum.org/)

That doesn't appear to be about Laos though?

~~~
cariaso
True, but the comment I'm replying to says

I'd be interested to hear the author explain what "regular violations of
nearby Laos and Cambodia" actually means.

The same bombing campaign hit both countries similarly. Laos seems to have
been slightly worse off, but the concept applies to both countries. The
information at the museum in Cambodia will broadly inform the Laos situation.
Besides if there is a similar resource in Laos I'm unaware of it.

~~~
tome
Oh, I assumed the museum would be more about the Khmer Rouge. In fact
Wikipedia says

> The landmines in Cambodia were placed by different governments and factions
> (including the Lon Nol, Khmer Rouge, the Heng Samrin and Hun Sen regimes, as
> well as the Coalition Government of Democratic Kampuchea who, with
> international support retained the UN seat throughout much of the 1980s)
> that clashed during the Civil War in Cambodia in the 1970s and 1980s

[https://news.ycombinator.com/item?id=14873083](https://news.ycombinator.com/item?id=14873083)

So it's not clear to me that has anything to do with the US presence in
Vietnam.

~~~
cariaso
I believe you are correct about the Khmer Rouge period being the source of the
bulk of the Cambodian problem, however the museum's collection was quite
comprehensive. It's been too long since I visited (and it seems they have
since been forced to relocate) for me to be certain of what if any of the
collection covers US secret war period, but I'm certain that I saw American
made mines in their collection.

My visit to this museum sticks with me to this day, and my desire to promote
it is perhaps out of place on this specific topic.

I stand by all of my other links as being directly relevant.

------
wcr3
ah yes, "the vietnam of computer science." a classic. never forget. can't wait
for "the holocaust of programming." heard good things about "ethnic cleansing
and compiler theory" too.

keep us posted.

~~~
hueving
Don't forget the "9/11 of algorithmic complexity".

------
sbierwagen

      and the most memorable image of the war, that of streams 
      of fleeing people seeking space on the Huey helicopter 
      perched on the roof of the embassy.
    

Common misconception. The roof in question was that of an apartment building a
kilometre away from the embassy:
[https://en.wikipedia.org/wiki/22_Gia_Long_Street](https://en.wikipedia.org/wiki/22_Gia_Long_Street)

------
gleenn
Interesting article but I feel like the metaphor is a little shallow. There
are plenty of troublesome topics in computer science that could be compared to
Vietnam in the same way, it just feels a little excessive to compare those
things to war.

I did end up getting sucked into reading a lot of history about the actual
war, turns out TFA should probably be split into two, one about the tech
aspect and one about the pure history. The history section was well written.

------
andreasgonewild
A classic, the information about Vietnam isn't really relevant but I still
find it interesting. Ran into this post back when I was busy implementing
ORM's in umpteen different languages myself, and I remember that it motivated
me to keep looking for better ways. Lately, I got the chance to sidestep the
whole issue and implement my own persistence from the ground up in Snackis
([https://github.com/andreas-gone-
wild/snackis/tree/master/src...](https://github.com/andreas-gone-
wild/snackis/tree/master/src/snackis/db)). It is still based on tables and
records, but having them available as first class objects helps bridge the gap
considerably.

------
est
I think the problem with ORM these days is leaky abstraction.

Sometimes we have RDBMS but more the times we have Redis and shit. You can't
organize all sources of data under the same umbrella and it's painful.

------
sgt101
One two year spell with Hibernate was the end of all flirtations with ORM at
our gaff. "No transparent persistence shall be the sum of transparent
persistence."

------
Zigurd
I like Android's Cursor and Adapter classes that skirt ORM, connecting query
results to Android's support for the observer pattern.

Most pubsub frameworks fail to do any better. Mostly because people don't
realize how useful Cursor is.

------
graycat
At one time, I was in that object, relational, etc. stuff. Some people wanted
all that stuff combined into some one, unified thingy.

My conclusion: The whole was a mess. Better just to leave the separate pieces
separate.

One of the pieces was, sure, relational data base.

Then there was the international work on CMIS/P -- IIRC common management
informaiton system/protocol. This work seemed to want to model the world and
everything in it, but really the goal was how do define and specify data for
real time computer and network system management.

This work was _object oriented_ and, thereby, open to a lot of confusion:
Really, what the work was talking about was just some data, say, describing a
printer. So, there be fields with data -- character strings, numbers, arrays,
etc. All it was was just data; that is, there was no associated code; no
subroutines or functions to call; no applications programmer interfaces (API).
The _object_ part was that the definition of data from/for printer A could
draw from, _inherit_ from, the definition from printer B, etc.

The next part was something we called Resource Object Data Model (RODM). So,
the idea was that in real time management of server farms and networks, there
could be several different programs trying to manage different aspects of the
work, communicating with the same computer or network node, and causing
conflicts. So the idea was to have a system, RODM, to present to all the
programs trying to manage a _single view_ of the servers and networks to be
managed, a single view that would handle locking, exclusive access, cache data
from the servers and networks, etc. So, RODM was a hierarchy, say, something
like a file system hierarchy. At the leaves were _objects_ that described
parts of the servers or networks. The objects were _active_ in the sense that
they could run their own, if you will _threads_ of execution, set timers,
respond to timers, send and receive messages with other objects, the servers,
the networks, programs doing the management, etc. All the hierarchy and
objects were _dynamic_ in the sense, much like in a file system, they could be
created, changed, and deleted all during real time operations. RODM had some
curious, tricky stuff: Could reserve an address space just for data. An
address space for code could jump into another address space for code and
execute code there. Etc.

One role for RODM was for programs to do system management based on AI (expert
systems) to have RODM to talk to as _model_ of the servers and networks being
managed.

It flopped.

I contributed a little: Part of such management is detecting and correcting
problems in real time. Some of the problems are ones never seen before. So, I
worked up how to detect those problems, with known, adjustable false alarm
rate, etc. So, that was to be a much better approach to anomaly and early
problem detection than we could expect just from the usually intended uses of
expert systems.

But, really, as for the OP, it was all too complicated.

------
rosser
I've said for years that using an ORM is ultimately a piece of tech debt.

Same point, far less inflammatory.

------
plinkplonk
Interesting how "The Vietnam of ..." assumes the US viewpoint as the default.

From the Vietnamese viewpoint, the war could (for example) be seen as underdog
patriots resisting waves of invaders possessing an overwhelming material and
technical superiority and utterly defeating them through sheer willpower and
sacrifice, thus gaining a nation of their own.

Which would make a paper titled "The Vietnam(War) of Computer Science" a
description of some kind of breakthrough in CS, attained after a tremendous
struggle.

So yes, dumb analogy. The paper would read as well without the bullshit title.

~~~
SiVal
You mistakenly assume that all Vietnamese were on the same side in the war.
Millions of Vietnamese lost that war to domestic forces who would never allow
free speech, free elections, etc., armed by foreigners (Soviets) who never
allowed free speech, free elections, etc.

The Vietnamese who cut my hair here in Silicon Valley possess nothing remotely
resembling what you naively call "the Vietnamese viewpoint."

~~~
plinkplonk
"You mistakenly assume that all Vietnamese were on the same side in the war."

Lol, I don't assume anything of the kind.

But when you talk of a war at high level, you identify the viewpoints by
generic terms.

"The Confederates thought that England and France would come to their aid" is
valid, even when there were people in the Confederacy whose beliefs were the
opposite.

Likewise the Royalists who shifted to/were exiled to London after American
Independence would call the victorious Americans rebels and traitors to the
Crown and Mother England.

You don't have to have every single American in the War of Independence to
anti-British to talk about "the Americans had soured on 'taxation without
representation' ", or demand that every single Briton be anti- American to say
"From the British point of view the war appeared to be stalled."

It is understood that these usages refer to distinct sides in a war, even in
the presence of factions who may fight for 'the other side'.

Likewise with the Algerians who left for France. And the Afghans who fought
along US troops who are leaving for the USA.(make that 'trying to leave' in
the age of Trump).

The Vietnamese who cut your hair in Silicon Valley are by definition no longer
Vietnamese citizens. They are Americans and have nothing to do with how the
war is viewed by the majority of the Vietnamese living in Vietnam.

Many Americans were against the Vietnam war too. But there still was an
American war effort, an American strategy and so on.

With your level of hair splitting, you couldn't generalize about anything
ever, because you could always dig up some unlikely exception. Which would
makes history books ... interesting ... to read and write. Every sentence
would have to be prefixed by 'Most of ', 'by and large, ' and so on.

There is no absolute view point on anything in History. There will always be
dissenters.

Well duh.

All of which has nothing to do with the point about the perils of naming CS
papers from specific political viewpoints, and how shifting these viewpoints
would change the import of such names.

~~~
abraae
> You don't have to have every single American in the War of Independence to
> anti-British to talk about "the Americans had soured on 'taxation without
> representation' ", or demand that every single Briton be anti- American to
> say "From the British point of view the war appeared to be stalled."

> It is understood that these usages refer to distinct sides in a war, even in
> the presence of factions who may fight for 'the other side'.

Well stated, but in this case, a civil war with North Vietnamese on one side
and South on the other, your statement does not read well:

> From the Vietnamese viewpoint, the war could (for example) be seen as
> underdog patriots resisting waves of invaders

Had you said, from the North Vietnamese viewpoint, fair enough.

------
TOGoS
Why is everybody's nickname $g?

~~~
Terr_
Perhaps some JS script design to add Google or Wikipedia links that is
malfunctioning?

