views:

446

answers:

14

Talking about hibernate and others ORMs, the ORMs evangelists talk about SQL like the assembly language for Databases.

I think is soon to assert this, but I guess can be true on a near future, not sure.

UPDATE: The analogy I was referring means SQL is to assembly what ORM is to C/Java/C#. Of course, an exact analogy is not possible. The question is if in the future, with more powerful computers the developers are going to use only ORM (or ORM like) instead of SQL.

A: 

No, no it's not. People that say that have never coded assembly.

Al W
Of course is not the same, but it's a good analogy?
FerranB
not really. But i'll give you one. ORM is a sledge hammer, SQL is a regular hammer. Most of the time...all you need is a hammer, and sometimes you can even use it to pull nails.
Al W
I have coded assembly and have been considering SQL a db assembly language. Why? Because it is the native language for the DB.
Joshua
A: 

No, however you could possibly say SQL is the C of Databases. They are both procedural and imperative, and data oriented instead of object oriented. And as C its easier to model objects and functionality in higher languages but in the end C is the baseline for performance measures.

Robert Gould
Procedural and imperative? Not if you write it correctly. Well written SQL should be declarative and set-based.
Greg Beech
Missing the point..
chadmyers
+16  A: 

Absolutely not.

Assembly language is a very low level language where you instruct the processor exactly what to do, including what registers you want to use etc.

SQL is a very high level language where you describe the semantics of what you want, and then a query optimiser decides how to execute it, so you don't even control what gets executed. It's an extremely powerful and flexible language of which any ORM offers at most a (fairly small) subset.

You'll notice that the .NET framework has introduced LINQ recently which is a way to introduce high level SQL-like constructs into languages like C# and VB. Rather than being like assembler, it's pretty easy to argue that SQL works at a higher level of abstraction than most mainstream programming languages.

Greg Beech
You missed the whole point.
chadmyers
@chadmyers - I don't see an answer from you as to what the point is. Care to elaborate? (note that my answer was written *before* the update to the question, so if you think it doesn't answer the update then I'm happy to elaborate as to why ORM isn't higher level than plain old SQL)
Greg Beech
+2  A: 

No, SQL is itself a high level abstraction layer that is (mostly) database agnostic.

Fergie
A: 

Don't believe that hogwash.

+5  A: 

No, relational algebra is the "assembler code" of database.

SQL is the "C code", readable and close enough to the "hardware" to be able to outperform all those other high level languages, provided you know what you're doing :-).

paxdiablo
+1 SQL is semantically close to relational algegra - the theoretical model behind RDBMS technology. It's specifically designed for the task in hand and is an excellent example of a widely used domain-specific language.
ConcernedOfTunbridgeWells
Except people don't use it like that, they use it to write procedural if/then logic with it which is not what SQL was intended for
chadmyers
A: 

I think no. If ORM is a compelling way to write a program (for the sole purpose of avoiding the "assembly language"), many big database vendors with all their resources would have already provided a non-SQL way to access and store data i.e. using ORM.

SQL is the most elegant and future-proof programming paradigm(declarative) to date. RDBMS vendors can seamlessly plug new functionality to SQL construct. Case in point, pre-MSSQL 2005 you have to loop the data to simulate tree structure access and running total. With MSSQL 2005, without using loops, using the same declarative SQL you can access tree structure data and running total in the most efficient manner.

If we were to put these tree-iterating and running total constructs to ORM, this would incur performance penalty.

SQL is the most important "assembly language" for most programmers. That's why many programmers will still invest on learning these assembly language for the foreseeable time to come.

I think many RDBMS vendors will just augment the SQL syntax rather than introducing ORM-based access to their RDBMS.

Michael Buen
+7  A: 

I have heard a lot of b*s about impedence mismatch between relational and OO over hte years.

My answer has always been that there is indeed a very big impedence mismatch -- between the niave inflexable "everything is an object and only an object" and the wonderfully flexable and sophisticated "data describes real world things; this data can be combined in different as yet unknown ways to produce mathematicaly provable results".

OO is not the only fruit guys.

James Anderson
+1  A: 

If you do only online transaction processing you use only the simple sql statements. Hibernate can generate them for you.

But if you want to do reporting, data analyzing or speedy bulk actions you have to learn SQL, and you often will use the vendor specific SQL extensions. Querying hierarchical data for example is possible when you use vendor specific SQL.

If you want to use SQL properly you have to think in sets, not row-by-row tiny statements. Therefore I say it is the exact opposite of assembler.

tuinstoel
A: 

It is, in the following sense: an ORM provides a high-level, domain-specific API which emits SQL statements, in the same way that a high-level language creates domain-specific APIs and emits machine-language statements.

I.e.:

  • Orm is is a layer above SQL
  • And HLL is a layer above assembly

However, I don't mean to imply that people will stop using SQL and prefer ORMs, in the same way that people have stopped using assembly and prefer HLLs.

ChrisW
An ORM is a way to *map* one idiom onto another of relatively equal status. The fact that you're looking at it from a programmer's view, though, doesn't make SQL subservient. Would you consider German subservient to English because you, an English speaker, know a German translater?
Mark Brittingham
@Mark: using your terminology, is assembly "equal" to a HLL or is it "subservient"? But it is true that I'm looking at it from a programmer's pov.
ChrisW
+2  A: 

SQL shares some traits with assembly language:

  • Coding in SQL directly gives you the opportunity to write very efficient code in a very compact way.
  • Using SQL effectively is a neglected skill by both professional software developers and by college curricula.
  • Because SQL is very compact, refactoring SQL tends to be wearisome and costly.
  • There's a large "base of the pyramid" of software developers who hate SQL with a passion and prefer to use layers of abstraction that mimic their preferred OO programming paradigm, even though these layers limit their effective use of SQL and result in slow, heavyweight applications.

However, unlike assembly, SQL is a high-level, platform-independent language. Also, there is no ANSI/ISO standard for assembly language.

Bill Karwin
Please offer a comment if you downvote an answer.
Bill Karwin
+1  A: 

Let's compare writing parallelized SQL with writing parallelized assembler.

This the way to write a parallelized sql statement in Oracle:

select /*+ parallel (e, 4)  */ deptno,count(*)
from employees e
group by deptno

Now I wish I could tell you how to write parallelized assembler but I strongly doubt it is as easy as adding something like /+ parallel (e,4) /.

tuinstoel
A: 

this will never happen. SQL is really a dsl which assembler is decidedly not. Mapping a relational db to an object model is useful but not the only purpose of dbs, that is there orms are a small part of what databases are used for, and therefore sql will always remain the dialect of choice for dealing with dbs!

klyde
A: 

RPG is the assembly language of databases. :-)

stesch