Re: Scripting language for DBAs

From: Robert Klemme <shortcutter_at_googlemail.com>
Date: Mon, 16 Apr 2012 15:10:55 +0200
Message-ID: <9v2k2vFa0nU1_at_mid.individual.net>



On 16.04.2012 14:33, Mladen Gogala wrote:
> On Mon, 16 Apr 2012 09:26:18 +0200, Robert Klemme wrote:
>
>>> PHP is not bad. Same for javascript.
>>
>> PHP does not even have proper OO, no thank you.
>
> No? How comes? PHP 5.3+ has classes, with all the proper member
> protection, namespaces, inheritance, interfaces and everything else that
> comprises OO. What does it mean that "PHP doesn't have the proper OO"?

I wasn't aware that they added it. Thanks for the education!

> As for the question "why not python", here is a little story: I upgraded
> my home desktop box from F15 to F16, 64bit. As a part of the upgrade, I
> decided to move my CD's into my home directory. When that was done, I
> issued the following command:
>
> perl -i.bak -pe 's|^/misc/|/home/mgogala|;' *.m3u
>
>
> Voila. All my playlists have been fixed immediately. That's the sort of
> stuff that still only Perl can do.

Not true.

sed -i.bak -e 's|^/misc/|/home/mgogala|' *.m3u ruby -i.bak -pe 'sub %r{^/misc/}, "/home/mgogala"' *.m3u

> And OO is not always the answer. OO is
> a great thing, if used properly. Used as a religion, it is debilitating
> and harmful.

I am not using it as a religion. It's just a very nice way to abstract things if you can add functionality to them as well.

> I can write procedural tasks in
> procedural fashion, like displaying an output of a query, mixing in OO
> techniques where I need them. OO was invented to help people collaborate
> on writing large programs, by hiding complexity of the operations on
> objects into the classes and have other programmers. Unfortunately,
> people have also invented agile methodology, so now people are creating
> their own sets of undocumented classes, which nobody understands and is
> making things far less maintainable than a good procedural script.

Well, you can't take a badly written script in an OO language or fashion as argument against OO in general. We all know that it is very possible to write spaghetti code in *any* programming language.

> If I
> have to present an output from a select as an HTML table, why would I
> even want to mix in OO?

Well, if for example, you need to manipulate the query result before writing it to the table then it might come handy if you have a record type with specific methods which receives your records. But there are often several ways to do things. Everybody should use what suits him. If it comes natural to do the HTML formatting in an OO style then do it, if not then don't. Nobody forces you to use OO. I am using OO because I feel very at home with it and it helps me write the code I need in a convenient way. That doesn't mean all my Ruby scripts only contain OO code - of course there is a lot of procedural code as well (actually every method is a procedure). If you don't like OO or do not see the benefit then don't use it. But please do not disqualify it based on bad examples.

Kind regards

        robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
Received on Mon Apr 16 2012 - 08:10:55 CDT

Original text of this message