Exploring Active Record 266
An anonymous reader writes "Everyone knows that no programming language is a perfect fit for every job. This article launches a 'new series by Bruce Tate that looks at ways other languages solve major problems and what those solutions mean to Java developers. He first explores Active Record, the persistence engine behind Ruby on Rails.'"
Comment removed (Score:5, Insightful)
Re:In a comparison, Ruby suffers for one big reaso (Score:5, Interesting)
Re:In a comparison, Ruby suffers for one big reaso (Score:2)
Re:In a comparison, Ruby suffers for one big reaso (Score:2)
It is... (Score:2)
Re:In a comparison, Ruby suffers for one big reaso (Score:2)
Re:In a comparison, Ruby suffers for one big reaso (Score:2)
Re:In a comparison, Ruby suffers for one big reaso (Score:3, Informative)
Java has support for Unicode 4 since Java 5 [sun.com], released september 2004.
UTF32? (Score:2)
Re:In a comparison, Ruby suffers for one big reaso (Score:3, Insightful)
Okay, I won't, but can you tell me why I would need more than 16 bits to store a single character ? Why the hell do we need so many characters in the world ? Are there so many ways to say "Hello" that we need millions of characters to communicate with our neighbors ? I'm not saying everyone should speak english (I'm french myself), but eventually the various dialects will condense into more portable languages.
Of course. For example, we don't need to runic characters in real life, however if you wanted
Re:In a comparison, Ruby suffers for one big reaso (Score:3, Interesting)
Re:In a comparison, Ruby suffers for one big reaso (Score:5, Interesting)
Yes, Ruby and it's author have an interesting attitude to string representation in general and Unicode in particular. It's partly what inspired me to write this:
Psychology of Unicode in Japan [jbrowse.com]
It's really been a very interesting struggle between people's psychological and I.T. needs -- a struggle that's pretty well over now, but has left behind things like Ruby's way of doing things.
Re:In a comparison, Ruby suffers for one big reaso (Score:2)
Re:In a comparison, Ruby suffers for one big reaso (Score:5, Insightful)
Re:In a comparison, Ruby suffers for one big reaso (Score:2)
Anyone else Railed-out? (Score:4, Interesting)
I've volunteered to create a recipe-wiki-site-thing for a friend, and coming from a background in C and SQL there was just too steep a curve to map a procedural train of thought and pre-planned SQL onto the Rails way of doing things. I already created the database schema, wrote all the SQL to get the information I want, have a lot of HTML written for the general template, and was looking at abandoning much of it for controllers, models, automagic foreign key relationships, automagic methods popping out of thin air.. I wanted more control I guess.
So I've done most of the site in PHP instead. Direct, to the point, fast enough (though I'm thinking about a rewrite in C for a pure CGI/FastCGI binary), a minimum of automagic hand-holding - just start each page with sanity checking, authorization, the SQL the page needs and nothing more, and then format the output. No wondering how many hundred methods have been created that I don't know about, what happens when a record is deleted/updated (I'll let the database handle null/ignore/cascade thankyou) or whatever else Rails is doing behind my back.
I'm a C guy - I don't like things being done that I don't explicitly ask for. I want init() functions. I want implicit declarations. Heck I don't even like C++ for fogging-over-functionality with inheritance, virtual functions and overloading.
Ranting aside, I can see how Rails would mesh with a lot of people. But it's definitely not for me, and I guess (hope) a few other nutjobs around here.
Re:Anyone else Railed-out? (Score:2, Insightful)
TBH It just sounds like you don't know what you are doing.
Re:Anyone else Railed-out? (Score:2)
Re:Anyone else Railed-out? (Score:4, Insightful)
One thing I like about ActiveRecord is that it is database agnostic. If I need to, I can move my app from MySQL to Postgres to Oracle with very little effort. The other thing I like is that it provides a clean separation between data storage and business logic. Database programmers seem to hate that approach because it shifts the center of gravity away from the database and toward the web app. This is great for maintainability of application code, but I don't know how well it works for sharing data among multiple apps. I don't know if anyone has gotten ActiveRecord models to support the same level of integration as you can get with multiple apps running off of one database - I think there needs to be more work done to enable that, but I expect to see that work done fairly soon.
The other cool thing about ActiveRecord is the use of metaprogramming, as discussed in the FA. I don't think we'll ever see a Java persistence layer that is as functional and easy to use as ActiveRecord, because the kind of metaprogramming tricks that Ruby enables are so much harder to do in Java.
Re:Anyone else Railed-out? (Score:2, Insightful)
That's all well and good, for a subset of database functionality. ActiveRecord reminds me of wxWidgets - smoke and mirrors, bloat and lowest common denominator functionality. But don't get me wrong, for a great many jobs it's adequate and there for the taking.
The other thing I like is that it provides a clean separation between data storage and
Re:Anyone else Railed-out? (Score:5, Insightful)
Inexperience and ignorance. And it sounds as if it applies to you and to this situation. I don't see how you can rant against "bloated" technologies you never bothered to learn. Without that knowledge, you don't understand everything that's happening behind the scenes and, since that scares you, you stick with the subset of the developmentatl universe you do know, no matter how appropriate, or inappropriate, it may be to the problem at hand.
I strongly suspect that once you've moved on to other victims, the next developer the guy hires will take one look at your carefully-crafted optimum solution, shudder, and then rewrite the whole thing.
Re:Anyone else Railed-out? (Score:2)
you have the java inherent setters and getters, which blow up your code (although the usually are generated, no one normally codes them by hand
something like a query over a method is not possible you still have to go over the persistence api
Re:Anyone else Railed-out? (Score:3, Interesting)
You can move your app, but how much effort is there in moving your data model? For serious apps, quite a bit. Oracle has seriously different types of columns and restrictions on columns from Postgres or MySQL, and if you want to use really efficient SQL, you have to use SQL that is hard to port (MySQL has only recently got subselects, for example).
Th
Re:Anyone else Railed-out? (Score:2)
SQLServer->Oracle, SQLServer->DB2, DB2->Oracle, etc. doesn't happen all that much. If only more databases supported DOMAINs, i.e., CREATE DOMAIN UserID as integer.
DeZign for Databases is pretty good at slurping in a database schema from one platform, and after changing the target platform, converting the schema to the desired database system.
As far as "hard to port" SQL, unless you're using MySQL or old versions of databsae apps, t
Re:Anyone else Railed-out? (Score:2)
That is easy to say until you are dealing with tens of thousands of lines of legacy SQL.
And it all depends on how much trigger/stored proc code you have to migrate. Tables/Views are pretty simple to move.
Not really - just look at the range of different column types in PostgreSQL or Oracle - converting is no
Re:Anyone else Railed-out? (Score:3, Insightful)
Re:Anyone else Railed-out? (Score:2, Informative)
90% of the time, when you call an init() function, you're going to call a free() function too. Let C++ do the grunt work for you. Use the RAII pattern [hackcraft.net].
Put your init() code in the constructor and your free() code in the destructor. That way you won't forget to call free().
Heck I don't even like C++ for fogging-over-functionality with inheritance, virtual functions and overloading.
You don't have to use those C++ features if you don't want to. You can program in C-style in C++ if
Re:Anyone else Railed-out? (Score:2)
Don't repeat yourself:
http://c2.com/cgi/wiki?DontRepeatYourself [c2.com]
k2r
Re:Anyone else Railed-out? (Score:5, Insightful)
I'm an 'SQL' guy myself and I'm not convinced by ORM tools - or at least the way they're being hyped as a solution for having to understand the DB (Newsflash : SQL is supposed to be an abstract query language so that the developer doesn't need to understand the DB - and look how that worked - answer : Mostly it does, but when it goes wrong you're dealing with a black box). I also think that the view of many Java (and Ruby) developers that a DB provides 'persistence' is wrong. It's a failure to understand relational theory - which at least, unlike most object modelling techniques, has a firm mathematical foundation. It's also a failure to use the tools provided to you (and when Bruce Tate complains about Java productivity, this tendency of Java developers might be part of the problem - it's 'not invented here' syndrome).
You could have used Ruby rather than PHP (a comparison I'd like to see) and I also think that there is much to be said for the MVC structure compared to shoving everything into each page.
It feels a bit clunky in the current paradigm (pages generated on the server and refreshed to the client, client events sent to server) but it works very well as a design, and I can see it becoming more important again as browser apps support more dynamic features - getting back more towards a client-server architecture with the model on the server, view on the client. (Or more likely a local model for performance and some form of background syncing).
Re:Anyone else Railed-out? (Score:2)
I've seen one or two... here [slashdot.org] for instance. I've yet to try it myself, but I'm looking forward to it... when things have calmed down a bit on my current project. I've been a bit turned off by the constant one-sided evangelizing by some of the enthusiasts though.
Re:Anyone else Railed-out? (Score:2)
Hehe... yes, speaking of fanatic evangelists, no one has even gotten close to beat the Lisp people. I don't know, maybe it is a FANTASTIC language. it is just... all this smug superiority pisses me off.
Re:Anyone else Railed-out? (Score:2)
And for the record, the Yankees can go screw. Go Tribe!
Re:Anyone else Railed-out? (Score:5, Insightful)
So... you basically wrote the application (minus the controller), and then started thinking about using a different platform? Is it any surprise that you didn't want to switch over to Rails (disclaimer: I'm not a Rails guy. In fact, I work for the competition [djangoproject.com])?
OK. It's not like somebody's holding a gun to your head and saying you have to use a framework. Personally, I see a lot of use cases where a framework makes development a lot simpler and easier to manage, because so much of the tedious overhead of web-app development has already been done for you. Think of the framework in terms of an operating system you're programming for: rather than writing all your own device drivers, routines for drawing stuff on the screen, accepting keyboard/mouse input, etc., you've let someone else solve those problems and you're just using the provided APIs to hook up the logic that's unique to your application. And with a framework, rather than write database drivers, routines for accepting and routing input, etc., you've let someone else solve those problems and you're just using the provided APIs to hook up the logic that's unique to your application. Using a web framework is no different, really, than using any other shared library.
As for all the cruft you complain about, when was the last time you used every single bit of functionality provided by a shared library you linked a C application against? Or is it only bad to draw in automagical functions you won't use when the application isn't being compiled? ;)
Re:Anyone else Railed-out? (Score:2, Insightful)
I think Ruby and Rails are about the right ideas for our current and near future environment -- cheap c
Re:Anyone else Railed-out? (Score:2)
Re:Anyone else Railed-out? (Score:2)
Thats ok, sometimes I like to thinker too and understand how things work at the core level, but when you do that you waste too many time doing things that already has been made, and thats not cool when youre working serious project.
Rails is about speed, is about getting your job done in less time, with less effort.
Re:Anyone else Railed-out? (Score:3, Interesting)
I agree with you, mostly. Rails is a god-awful mess under the hood. The programmers really abuse the language features (especially the ability to re-open objects) to the point where it is nearly impossible to trace through the code to figure out what is really going on.
I tried it, ditched it and refuse to use it anymore. The last straw for me was the lack of respect for backwards compatibility in their version upgrades -- I had gotten halfway through a small a project and then they changed the API dra
Re:Anyone else Railed-out? (Score:3, Insightful)
This is an unfortunate side-effect of working in a pre-1.0 environment, regardless of what it was. I believe the current plan is to not break any APIs until 2.0 hits (and maintain the 1.x branch for security updates once 2.0 hits)
As for the methods they create behind your back, let's just call it what it is: Self Modifying Code. How the heck a
Re:Anyone else Railed-out? (Score:2)
It's nice. Ruby is nice too, I like it. I guess there are 3 things that stand out to me, Rails is still a toy compared to j2ee, I've been doing "opensource" professionally for nearly 10 years and good enough usually isn't good enough. There seems to be a lot of consultant types pushing the rails way and it's because they've never finished anything.
Second, I'm skeptical of religion in technology. Ruby and rails has a ton of religion going on. Enough that it's not just advocacy, it's crossing ov
Re:Anyone else Railed-out? (Score:3, Interesting)
For which, I salute you.
Personally, I'm a big OO guy; for anything beyond a thousand lines of code, I feel the object-oriented approach makes maintenance much, much easier.
But what makes me bat-shit crazy is people who feel like you do but aren't smart or independent enough to b
Re:Anyone else Railed-out? (Score:3, Insightful)
Re:Anyone else Railed-out? (Score:3, Insightful)
Re:Anyone else Railed-out? (Score:3, Insightful)
A background of incompetence? Funnily enough when I picked up PHP, your disaster scenario was what most people seem to do without thinking about it. In my case, the MVC components are
Re:Anyone else Railed-out? (Score:2, Insightful)
If you wanted to, you could turn your HTML templates into RHTML (Ruby HTML). If you PHP really was just acting as a controller, it should be easy to re-write that in Rails, as it uses the same design pattern. As far as custom SQL, it's easy to keep that in Rails (although it's not really the "Rails way"); you can execute arbitrary SQL statements just like in PHP.
Ultimately, I think we all code in what we're comfortable wi
Re:Anyone else Railed-out? (Score:2, Funny)
Re:Anyone else Railed-out? (Score:2, Insightful)
Wrong Mentality (Score:5, Interesting)
A politician giving an address in German instead of French is not more effective as his points will still remain the same. The language isn't the tool, the intention is the tool.
Re:Wrong Mentality (Score:2)
And yes, language is a tool, actually. So is an SDK or a framework. So choose your tools wisely.
language matters a great deal (Score:5, Insightful)
The differences between C++, C#, and VisualBasic are far deeper than syntactic. C#, for example, guarantees fault isolation, while C++ does not. C# has full reflection, while C++ does not. Programmer productivity in different languages can be orders of magnitude different.
Of course, most working programmers have the same superficial view of programming languages as you do and will make the same glib and ill-informed analogies to natural languages that you did. That's why people keep choosing C and C++, believing the differences to other languages to be merely syntactic, and then producing code that crashes, silently mangles data, and has gaping security holes.
Fortunately, the herd mentality is driving even people who don't know what they are doing away from C/C++. Even your own company bills itself as a
Re:language matters a great deal (Score:3, Insightful)
Re:language matters a great deal (Score:4, Interesting)
Thank you for illustrating my point.
Microsoft has, in fact, hired many of the top language designers of the world because they think languages matter.
Microsoft has been pushing hard for a move to managed runtimes.
And Microsoft's severe problems with their previous C/C++ efforts are the reason for that.
So, lots of people at Microsoft have come to the conclusion that languages matter a great deal, and that's why they are investing probably hundreds of millions of dollars in that.
Re:language matters a great deal (Score:3, Informative)
Re:language matters a great deal (Score:5, Informative)
Excuse me? Which studies?
Certainly not this one:
http://page.mi.fu-berlin.de/~prechelt/Biblio/jccp
Nor this one:
http://www.erlang.se/publications/Ulf_Wiger.pdf [erlang.se]
Nor even this one:
http://www.theadvisors.com/langcomparison.htm [theadvisors.com]
And this well-regarded programmer certainly doesn't agree that the choice of language doesn't matter:
http://www.mindview.net/WebLog/log-0025 [mindview.net]
I tell you what -- interview a group of experienced programmers for a prospective project to write a database-backed web application with complex requirements. Tell them that they will be required to program in assembly language because "most studies show that... programmer productivity is generally independent of language chosen." Record their responses and post them to Slashdot.
That's the real trick, isn't it? (Score:3, Insightful)
You're right, that the language itself is not the only thing that matters. Extra libraries to work with makes life much more pleasant.
But what's under the hood of that do_something_with_file_data? In this fairly trivial example, there's not much difference between a do_something_with_file_data in C versus Perl.
Nice code examples deleted 'cause of /. stupid lameness filters inserting random spaces, even when I had spaces nearby. GRRRR! Suffice to say both were functionally equivalent and of about the
Re:Wrong Mentality (Score:2)
See... it's not JUST language, though it doesn't play as major a role as people like to think.
rails (Score:2)
But ActiveRecord is awesome. Most of us build databases that work like objects already.. so an object oriented interface to your database is very easy to use and maintain.
Re:rails (Score:4, Funny)
Not me, though. I never "got" relational database theory and am quite content to give people nightmares with my naive object-biased approach.
Re:rails (Score:2)
RoR also perfectly works with Lighttpd and unless you absolutely have to use Apache, you should have a look at it. Its lightweight, modular and speedy. Since I migrated from Apache, I never looked back.
Uhhh.... (Score:5, Funny)
I program in raw machine code. It's a perfect fit for every job, every time!
Re:Uhhh.... (Score:2, Insightful)
I program in raw machine code. It's a perfect fit for every job, every time!
How's client-side web page scripting working out for you?
Re:Uhhh.... (Score:5, Funny)
Re:Uhhh.... (Score:3, Funny)
Get five tons of sand and then...
Still looking for an IDE (Score:4, Funny)
Here, we simply drag and drop then program the logic behind all those widgets we've dragged onto the form. I also looked for something in relation to Python but could not find anything! I taught VB myself using this method. Current IDEs I have looked at make things confusing. Am I looking for what does not exist? Hope not!
Re:Still looking for an IDE (Score:2, Informative)
If you need a drag'n'drop gui editor, try Eric (pyQT( or BoaConstructor (wxWindows).
Re:Still looking for an IDE (Score:3, Informative)
Re:Still looking for an IDE (Score:5, Funny)
> I taught VB myself using this method.
> Current IDEs I have looked at make things confusing.
Nothing personal but: This explains much of the VB code I had the misfortune to see in my life.
k2r
Re:Still looking for an IDE (Score:2)
Sure it only takes a day to slap controls in a form and bind some controls to a SQL statement but good luck trying to find a bug or refactor when you decide to change a field name.
OK... how SHOULD it be done then? (Score:2)
Apart from its inherent inadequacies compared to 'rea
Re:Still looking for an IDE (Score:2)
No kayaking for once! (Score:4, Funny)
Really a time saver (Score:4, Interesting)
I wrote the first one in Java and the second one with Ruby On Rails, to learn the language and experiment with the framework. The Rails application needed half as much time to be coded than the Java one, despite being totally new to Ruby and to Rails.
The merit goes almost entirely to ActiveRecord and expecially to the validation feature.
Another time saver is Ruby's being interpreted instead of compiled. That saves a few time at every change to the code, even if strong type checking at compile time would have occasionally saved me a lot of time. It's difficult to assess if I gained or lost time.
What I'm looking forward to now is a good ActiveRecord implementation for Java because Rails is great but Ruby's syntax is really appalling. Even Perl (admittedly one of my languages of choice) looks more consistent. On the other side, halving development time is something that tempts me a lot. Java on Rails would be great.
Re:Really a time saver (Score:2)
But your talking java programers here. Look at what the java community has come up with to solve the same problem -- JSP, plus struts, plus JDBC
but that proved inadequate so they stacked the whole mighty ediface of J2EE
on top of it.
That the Java communuty could come up with a simple clean usable
solution for anything is no longe feasable.
If you want to see a Java programmer self-combust just set the following
simple task:
"Define 'bloat' in less than 9000 words".
Re:Really a time saver (Score:2)
Rails rocks (but isn't a silver bullet) (Score:5, Informative)
I've been playing around with Rails and AR quite a bit lately, and it has changed the way I think about programming in many (positive) ways. I come from a heavy Java / J2EE background (do that for a living, serverside systems), and Ruby + Rails is a breath of fresh air. Ruby is simply a wonderful language, there is something very "zen" about it, and Rails is inspired. Sure, it builds on a lot of old concepts, but the brilliance is where it leverages the power of the Ruby language to do things in very efficient and nice ways.
Yes, there is a lot of "black automagic" involved in Rails. It's where the power is, and you can override pretty much everything is you want to. If you're uncomfortable with magic stuff happening behind the scenes and don't want to learn Ruby so you really understand that magic, Rails might not be for you.
I'd claim that pretty much every serious programmer (VB scripters don't count :) should learn Ruby, at least the basics. It might not become your new favorite language (like it has for me), but it will give you a fresh new perspective on how to code stuff.
Ruby does have a few downsides:
(there are probably more, but I'm still only learning the language)
As for Rails, well, again there are downsides. Nothing is perfect.
So: it's not a silver bullet. Nothing is. But for a large majority of the modern-day web app use cases, it's very nice, productive and, well, elegant. It lets you to do quick prototypes and keep your code clean, you don't end up with the insecure and ugly mess most PHP apps end up being.
Re:Rails rocks (but isn't a silver bullet) (Score:2)
Re:Rails rocks (but isn't a silver bullet) (Score:2)
see http://www.fngtps.com/2006/01/encoding-in-rails [fngtps.com]for more.
Re:Rails rocks (but isn't a silver bullet) (Score:2)
Re:Rails rocks (but isn't a silver bullet) (Score:4, Informative)
Well rails is a very good framework + toolset, but like every other enforcing toolset which tries to cover a lot of ground by automating stuff it has a huge problem, follow the road and you are set, if you cannot follow the road you are screwed.
I have seen this complaint lodged many times, and at first I was concerned about it because of this, but I have yet to actually run into it. Rails is flexible enough that all the conventions it uses are overridable, and if you know of any exceptions to this please let me know, because I am still evaluating it. For example: by default AR assumes your primary key column is named id, but you can override that per-table if you like, or globally via environment.rb:
Similarly, while AR expects plural table names, you can override that with the following:
So I don't agree with the (overly stated, IMHO) belief that Rails falls on its face when you move outside its conventions. My experience does not match this.
Re:Rails rocks (but isn't a silver bullet) (Score:4, Informative)
Re:Rails rocks (but isn't a silver bullet) (Score:2)
Have you ever considered how those opcodes are executed? I assure you that in the common case the generated opcodes are not native instructions for your CPU.
If by interpreted you mean, "parsing each line of code as it's needed" and by not interpreted you mean "on startup compiling the code to an intermediate representation that is more efficient", I sup
Now, if he could apply the same wisdom to SQL, etc (Score:3, Insightful)
Re:Now, if he could apply the same wisdom to SQL, (Score:4, Interesting)
It is great to see that developes are finally beginning to see the downsides of Rails!
The thing is, not everyone does think they have to do that! There are perfectly good high-performance ORM systems that do allow you to work with a hierarchy of objects and use rich but portable query languages - examples are Hibernate, JDO and the soon-to-be released JPA (Java Persistence Architecture).
They are as DRY (don't repeat yourself) as Rails, as with quality implementations you can automatically generate schemas from objects, or get object hierarchies generated from schemas, and they don't have to rely on endless configuration files (you can define minimal relational information as annotations in your objects).
Also, unlike Rails, they are extremely portable. You aren't restricted to a subset of SQL to get portability. You can use a full and rich query language (like JDOQL 2.0) and that is automatically translated to high-performance vendor-specific SQL for whatever database you are using. Even if you don't want portability, the ability to do this means you get high-quality SQL largely automatically.
Unlike Rails, they work extremely well with both legacy schemas and schemas that are shared with other applications a developers.
Unlike Rails, some of these APIs (JDO) don't restrict you to relational systems - you can persist just as easily to things like object databases, SOAP services, LDAP, text files, filesystems etc., without changing a single line of code, and all the while using a rich query language!
These products and APIs are available right now, have open source implementations and have been used successfully by a very large number of developers for years.
My view is that they make Rails look primitive.
Re:Now, if he could apply the same wisdom to SQL, (Score:2)
Re:Now, if he could apply the same wisdom to SQL, (Score:2)
Good post, but I would disagree with some points. I don't think Hibernate is the easiest API - I far prefer JDO. Secondly, you don't have to use all that locking or use of lazy objects - you can use it in a very simple manner. The use of those features i
Re:Now, if he could apply the same wisdom to SQL, (Score:2)
Hibernate, KODO JPA, Toplink JPA all OSS based on various licenses. Due to the issues mentioned I will probably move away from Hibernate towards something else.
The main problem with Kodo simply used to be the price which was way t
Re:Now, if he could apply the same wisdom to SQL, (Score:2)
I use a JDO product (Kodo) for very large transactions (hundreds of thousands of records), and it works very well and fast. Hibernate was, according to the developers, not intended for this sort of use - which I interpreted as a coded way of saying 'it is too hard to run write our stuff to run efficiently like that and we aren't bothering'
Hibernate is extremely popular, but, in opinion, far from the best. The Ko
Re:Now, if he could apply the same wisdom to SQL, (Score:3, Interesting)
Re:Now, if he could apply the same wisdom to SQL, (Score:3, Informative)
No, in some cases the portable query language is more featured that the language it wraps. JDOQL implementations can provide rich querying even on systems with no built-in query language (like filesystem storage).
That are highly portable across databases, but themselves are not portable across application layers (do *any* reporting tools support them?
Of course they are. There are reporting tools like JasperReports that can use Hibernate Query L
Re:Hmm... (Score:4, Informative)
Yes. The best place to look is the specifications at the JCP.
JDO 2.0 is
http://www.jcp.org/en/jsr/detail?id=243 [jcp.org]
EJB 3.0 (including JPA) is
http://www.jcp.org/en/jsr/detail?id=220 [jcp.org]
I've heard of hibernate, but not the JPA. Is that going to be part of the standard JRE? I hate having my code rely on goofy 3rd party add-ons.
JPA is going to be a standard part of J2EE, but can be used stand-alone with JRE. There are many vendors providing implementations - Sun, Oracle, JBoss, BEA, JPOX, Versant. A significant number of these are going to be open source (JBoss, Oracle, BEA). Hibernate is also going to provide an implementation of JPA.
i don't like the Active Record pattern (Score:2, Interesting)
accordingly, things i dislike about active record:
1) it seems to mirror tables pretty directly;
2) i don't think the objects you work with in code should know how they are stored - this means they don't inherit or mix-in any database code at all. there should be separate classes that handle this.
this holds for other languages too, of course. python in this case:
Re:i don't like the Active Record pattern (Score:2)
Well, that's how most people tend to code on top of databases. I'm sure you can point to lots of great examples as to how this is bad, so fire away.
2) i don't think the objects you work with in code should know how they are stored - this means they don't inherit or mix-in any database code at all. there should be separate classes that handle this.
Great, because your model objects that use ActiveRecord don't know how they're stored in the database, either, short o
Hooray! He uses Migration! (Score:2)
People just getting in to rails and ruby are not likely to have done more than scratched the surface of what ActiveRecord is capable of. This is a great introductory article, but I'm curious just how far
Re:Hooray! He uses Migration! (Score:2)
People keep talking about this, but be honest: how often does it happen in practice? Not too often.
Re:Now, more buzzword-friendly? (Score:2, Informative)
It also gives you a lot of stuff for free; migrations from one databas
Re:Now, more buzzword-friendly? (Score:2)
Re:Now, more buzzword-friendly? (Score:3, Insightful)
Article: "here is a link to an interesting review of (insert technology here)".
Random guru: "That's nothing! I wrote something similar myself 6 years ago using perl/punchcards/blood from my own hand!"
Elitist Java developer: "Hahaha! You amateurs! How does your pathetic toy deal with redundant HA database clu
My favourite (Score:3, Insightful)
"Hahaha! You amateurs! How does your pathetic toy deal with redundant HA database clusters in a real-time mission-critical enterprise environment with a 5-nines uptime guarantee? Come back when you've grown up!!"
Rails is scalable, but not in an interesting fashion at all. You want more processing power, you run more instances. Where's the fun in that? I love it in Java land, where creating something scalable inevitably means exciting things like building a single JVM that runs on multiple machines, or w
Re:My favourite (Score:2)
No, it doesn't inevitably mean that. You can make an application more scalable by moving from threads and blocking sockets to non-blocking IO channels for instance. What you are talking about is clustering. Those are two possible approaches with Java, but there are plenty m
Re:Now, more buzzword-friendly? (Score:2)
I use Class::MethodMaker. It's nice for declaring member variables but OO is pretty clunky it perl 5, and Perl 6 doesn't seem much better.
What if you don't need to scale out? (Score:3, Interesting)
How many applications out there have more than a few dozen tables? I'd have serious concerns with a system that had a single application, with a single database, comprising of hundreds of tables. In reality such systems are quite rare--for every massive ERP implementation there are hundreds or thousands of smaller applications where Ruby on Rails' Active Record model would work very well.
For TOY applications, it might be f