Thursday 17 November 2011

Grails: Why I think "hello world" should be considered evil

I started in IT in April 1977.
I sat in front of a terminal that year and typed "vi helloworld.c".
It as a simple program being just a few lines of old K&R C.
I was entranced.
It worked.
It printed out "Hello World".
(In those days that was real magic)

But I had deep seated anti-patterns flowing through me and I got the hint that something wasn't right.
Yes, the program worked.
Yes, it did what I told it to.

It wasn't "real" in the sense that it didn't model the "real" world.

By 1985/86 I was responsible for a single program with 1 million lines of K&R C.
Excluding comments.
It still didn't model the "real" world but it did a darn good job of making sense of accounting data and was a serious contender for replacing SQL at the time.
It was HUGE and had a unique database model that we had patents on.
It only had one database.
And I saw that as a problem.

Funny thing is...
Years later...
I see fat books touting this framework or that and see people getting all hot and bothered about them.

For all their verbiage and explanations, they are just the same as that first C program I wrote in 1977.
They are the new "hello world" systems.
Acres of code.
Dependency Injection. Woooo!
Dependency management. Woooo!
AOP. Woooo!
Enterprise...  Woooo!
I know I'm a dinosaur, but seriously?
And all of them treat the landscape or scope of their explanation as GREEN FIELD.
So they all describe in glowing terms about ORMs and finders and what not.
And guess what?
They only have one database.
Just like the 80's.

What colour is the sky in their world?
Not blue obviously.
Because you're not even in brown field territory.
Blackened, burnt, filled with the ruined spectres of testers, moaning project managers, nazi network engineers, multiple architectures, servers, clusters, app servers and and and...
If you want to use Grails or Rails or any other damn framework you have to fit into that view of reality.
And that includes that dreaded word...


Why is that word that word?
I hate that word.
The reality is that when you try to use these wunderkind frameworks with existing systems, everything crashes in a heap.
You have to twist and turn and hack and chop and do a whole pile of things which may include bedding down with the Ops manager to get them to work...
And the basis of it all is that so many of these frameworks assume that it's in a void.
One database.
Dependency injection at boot time.
WooHoo... Not.

Apart from taking all the fun out of programming, this isn't how the world works.

I have a situation with multiple database technologies and servers.
I love Grails and Rails and Groovy and Ruby and... well Java not so much.
But the frameworks are sh*t at handling those "legacy" systems.

I don't want DTOs, but the Tech team likes them.
So I have to be able to have these 35 DTOs pointing at that MySQL cluster with multiple databases/tables/read-write/read-only role based access, another 20 DTOs pointing at that MySQL cluster over there in the same manner, and, oh by the way, I have two MongoDB replica sets which need to be included.
And some of the DTOs are the same across the databases, clusters and collections so annotations won't cut it.
Oh, and I need to have DB_dev, DB_test, DB_stage and DB (for production) for each of them.
Oh and the Test Lead wants all the systems to work in the Test and Stage environments before being deployed.
Oh and the Ops Lead demands that all deployed systems use RESTful interfaces to reset and/or reload all database settings at certain times.
Oh and he wants to be able to "push" database changes using a RESTful interface into your app.

Grails in Action and Definitive Guide and... and... Nope.
Dependency Injection my ass.

Grails is a lovely technology.
I like it.
I have to admit I used Rails earlier and loved that, so I'm slightly biased.

But the ORMs out there are rubbish.
Total rubbish.
You have no choice but to define everything up front in a config file, externalise it in excruciating detail, or whatever.
Or, in Grails, bounce repeatedly through Spring hoops to get the scenario to work HOW THEY WANT IT TO WORK.
Total krap.

So you resort to low level API.
Then the real issues come out.
And you then resort to hacking someone else's code.
And you ask yourself: "WTF?"
Hasn't anyone else had these issues?
So you "google" and lo and behold, yup, others have.
And the answers you get are so complex or complicated or distressed or tired or RTFM or JIRA bug it or SUFFER DUDE that you are just left bewildered.

After 2 1/2 days phaffing about trying to get Grails to do what I needed (not wanted) to do, I had a hissy fit.
Hence this post.
So? I'm impatient - (shrugs).

Hello world?
Get off my lawn!

BTW... I'm going to write my own ORM that handles these scenarios.
Dunno when.
It won't happen overnight.
But it will happen.

No comments:

Post a Comment