Re: Scripting language for DBAs

From: Noons <wizofoz2k_at_yahoo.com.au>
Date: Tue, 17 Apr 2012 15:15:36 +1000
Message-ID: <jmiu9n$f2n$1_at_dont-email.me>



Robert Klemme wrote,on my timestamp of 16/04/2012 9:18 PM:

> Hmm... First of all Python, Ruby and Perl are general purpose programming
> languages. Perl is extremely strong in text processing but Ruby's regular
> expression engine is not far behind since 1.9.* version of the language. I
> cannot judge Python. What makes you say they were created for the net only /
> mostly?

Because both Python and Ruby are widely used in that context and date mostly from past the .net explosion of the 00s. Perl is an exception, granted.

>
>> OO is useless for any quick database work.
>
> It might depend on the overhead. I find it very convenient to create classes
> with a set of properties on a single line in Ruby:
>
> Person = Struct.new :forename, :surname, :born
>
> You can even add methods easily
>
> Person = Struct.new :forename, :surname, :born do
> def age_days; (Date.today - born).to_i end
> end

 > snippage
> Btw., another feature which makes Ruby code quick to write and easy to read is
> the feature that every method can accept an anonymous callback function which
> helps separating iteration from processing and makes iterations and generally
> visitor like things very concise.
>
> users = [...] # an array
> users.each {|pers| puts pers.surname if pers.age > 18}
>
> Plus, with that block pattern resource cleanup is simple and cannot be forgotten:
>
> File.foreach ".bash_history" do |line|
> puts line[0...10] # first 10 chars
> end # implicit file close, even with exception
>
> http://blog.rubybestpractices.com/posts/rklemme/001-Using_blocks_for_Robustness.html

Interesting. I'll have a second look at Ruby, can think of a couple of areas where that'd be of use.

> OK, 'nuff advertising. ;-)

Nothin' wrong with directed advertising! :-) Received on Tue Apr 17 2012 - 00:15:36 CDT

Original text of this message