Alex Young
3/8/2007 12:27:00 PM
Before I start: I've done most of what you need to do successfully with
Ruby before, for a little while now, so the news is good :-)
planetthoughtful wrote:
> Hi All,
>
> I'm thinking about learning a new scripting language, and I have a
> couple of questions I'd like to ask the Ruby community to work out if
> Ruby is the language I should be learning.
>
> A little background: most of my usage will be based around writing
> console scripts that connect either to MSSQL (ie SQL Server), MySQL or
> Microsoft Access databases to perform imports / exports / selections
> etc, or it will be around pulling apart text file reports to identify
> valid records etc (and often then importing them into a DB). This will
> all be on a WinXP machine.
I've handled MySQL and Access connectivity before (MySQL much more than
Access), and they're both easy to get working. MySQL has a native
driver, and you can get to Access via ODBC. I assume that MSSQL will be
similarly convenient, but I haven't used it myself.
> I'm currently very conversant with PHP and VBScript and moderately
> conversant with C#.
>
> What I'm looking for:
>
> - A language that installs easily onto a WinXP machine, including any
> libraries required to do the following things listed below as well.
Yes. The One-Click-Installer (if you haven't already found it) takes
care of this.
> - A language with solid and hopefully well-documented libraries for
> connecting to at least MySQL and MSSQL. Being able to connect to
> Microsoft Access via ODBC (or even better, natively) would be an extra
> bonus.
See above.
> - A language with a flexible array or array-like object. One of the
> things I love about PHP is the ease with which an array can be
> populated (eg "MyArray[] = 'a new value';" adds "a new value" as a new
> item to the array MyArray).
Ruby's arrays aren't quite as feature-packed as PHP's arrays, which are
more like mutant hashes with strange super-powers. A Ruby array is
created like this:
arr = ['a', 2.0, Object.new]
and are addressed only by index:
arr[0] = 'b'
and appended to like this:
arr << 'c'
If you want non-numeric keys, we've got hashes, which work like this:
hsh = {'a' => 'foo', 1 => 'bar', Object.new => 'qux'}
addressed (and also assigned to) like this:
hsh['a'] = 'fob'
Unlike PHP's arrays, Ruby's hashes don't preserve order, but there are
libraries around to do that if you need it.
>
> - A language with strong Regular Expression abilities, and string
> manipulation tools / methods.
Yup. Better than PHP's, in my opinion.
> So, would anyone be able to help me work out if Ruby is the language I
> need?
I guess the thing to do would be to find a simple task you need to do,
and actually try it out, and see how it feels - and check back here if
you need help. That's how I got hooked :-)
--
Alex