Database construction in Ruby

C

Christopher Small

Background:

I'm interested in building a database for my company so that we can
store information on accounts, work orders, production records,
experimental data, etc. My programming experience started with
Mathematica, was followed by LaTeX, then by Matlab, then Maple, then
Labview and most recently, I've started learning Ruby. I really like
Ruby as a functional language, though I haven't gotten my feet too wet
with languages of that sort of ilk yet. I haven't been programming with
it (or any of the other) for very long, but I've found that with my
mathematics background I've been able to pick up all of these languages
very quickly, and feel quite confident that (with some work, to be sure)
I can build a database and GUI which will meet our companies needs for
an easy to use and highly flexible database.


Questions:

Having not had much experience in the sort of languages which would be
suitable for such an endeavor, I don't know what the pros vs. cons of
using Ruby to develop such a program would be. My impression is that
with Ruby's rich class structure and flexibility it would be a good
language to use. What I don't know is if there are things that I need to
consider before getting too far down along this path. For instance, I've
read that the linguistic structure of Ruby was created with the
programmer in mind, not the computer. Does that mean that a ruby program
of the sort in question might be too fricken slow to deal with all the
info? I know that MATLAB is famed for it's array handling - is there a
way that embedded C compilations of matlab programs may be able to drive
an array based storage and retrieval scheme with more speed than Ruby
alone? Are there other problems that I haven't thought about? Have
others made programs like this with Ruby? Were they successful?

The other concern of mine is making the GUI. Labview has a pretty simple
drag and drop style GUI development structure - that's all I've used on
that front. I tried working with visual basic once, but didn't get very
far, mostly because for what we were doing Labview was easier and
someone at my work was able to teach it to me (Incidentally, I've ben
learning Ruby for fun on my own time). As I understand it, there are a
few options for getting a Ruby-GUI. Ideally, this would be runnable on
either windows or mac (at work we use win but I run a mac on my
computer). I've downloaded Shoes, but haven't really used it at all yet.
It doesn't seem to be tailored for designing complex GUIs. As I
understand Cocoa is a great way to go if you want to run on macs - is
there a way to get a Cocoa script to run on PCs? How do programs like
iTunes work on PCs? In general, what would the best (or at least some
good) multi-platform language(s) be for embedding Ruby within a GUI?


Any and all help/comments/suggestions are welcome! Thanks.
 
P

Phillip Gawlowski

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Christopher Small wrote:
| Background:
|
| I'm interested in building a database for my company so that we can
| store information on accounts, work orders, production records,
| experimental data, etc. My programming experience started with
| Mathematica, was followed by LaTeX, then by Matlab, then Maple, then
| Labview and most recently, I've started learning Ruby. I really like
| Ruby as a functional language, though I haven't gotten my feet too wet
| with languages of that sort of ilk yet. I haven't been programming with
| it (or any of the other) for very long, but I've found that with my
| mathematics background I've been able to pick up all of these languages
| very quickly, and feel quite confident that (with some work, to be sure)
| I can build a database and GUI which will meet our companies needs for
| an easy to use and highly flexible database.

A question of my own:

Do you plan to write the database engine from scratch, instead of using,
say, MySQL, Oracle or DB2?

That said, Kirbybase is a pure Ruby database, so it is certainly
possible to write databases in Ruby.

|
| Questions:
|
| Having not had much experience in the sort of languages which would be
| suitable for such an endeavor, I don't know what the pros vs. cons of
| using Ruby to develop such a program would be. My impression is that
| with Ruby's rich class structure and flexibility it would be a good
| language to use. What I don't know is if there are things that I need to
| consider before getting too far down along this path. For instance, I've
| read that the linguistic structure of Ruby was created with the
| programmer in mind, not the computer. Does that mean that a ruby program
| of the sort in question might be too fricken slow to deal with all the
| info?

That depends. For realtime calculation Ruby is too slow (as are all
interpreted languages), but you may gain speed by using JRuby and it's
JIT compiler for Ruby.

In most cases, a Ruby program is fast enough (and you gain productivity
as developer, which is usually a good trade off, especially given the
abundance of computing power nowadays).

Without profiling and benchmarking your cases, it is hard to say if Ruby
is fast enough for your needs or too slow.

On the other hand, Ruby in combination with Rails is scales very well by
now, even though ActiveRecord can be really slow (which, in most cases,
doesn't matter, and you can tweak a lot by dropping down to SQL, for
example).

| I know that MATLAB is famed for it's array handling - is there a
| way that embedded C compilations of matlab programs may be able to drive
| an array based storage and retrieval scheme with more speed than Ruby
| alone? Are there other problems that I haven't thought about? Have
| others made programs like this with Ruby? Were they successful?

You could farm out computationally heavy operations to C with normal
Ruby, or to Java with JRuby.

| The other concern of mine is making the GUI. Labview has a pretty simple
| drag and drop style GUI development structure - that's all I've used on
| that front. I tried working with visual basic once, but didn't get very
| far, mostly because for what we were doing Labview was easier and
| someone at my work was able to teach it to me (Incidentally, I've ben
| learning Ruby for fun on my own time). As I understand it, there are a
| few options for getting a Ruby-GUI. Ideally, this would be runnable on
| either windows or mac (at work we use win but I run a mac on my
| computer). I've downloaded Shoes, but haven't really used it at all yet.
| It doesn't seem to be tailored for designing complex GUIs. As I
| understand Cocoa is a great way to go if you want to run on macs - is
| there a way to get a Cocoa script to run on PCs? How do programs like
| iTunes work on PCs? In general, what would the best (or at least some
| good) multi-platform language(s) be for embedding Ruby within a GUI?

Apple has ported its GUI toolkit to Windows. And iTunes or QuickTime and
Safari look out of place, but as far as I know, there is no port of the
Cocoa toolkit to Windows. However, there are a number of crossplatform
GUI toolkits, like GTK+ (with a drag & drop GUI designer usable for Ruby
applications) with Ruby-GNOME2, wxRuby which uses the wxWidgets toolkit,
which give a native look on different platforms, QtRuby (though the Qt
toolkit has odd licensing, but that doesn't matter unless you want to
sell your application to others), and JRuby can use the Swing toolkit
for Java at least (and Monkeybars makes it unnecessary to touch Java, if
you don't want to to create GUIs), where the Netbeans IDE comes with
good Ruby support, as well as a very good GUI designer.

Last but not least, there is the Fox GUI toolkit, too (which recently
got a book published aimed at people who haven't created a GUI
application yet, too).

- --
Phillip Gawlowski
Twitter: twitter.com/cynicalryan

~ - You know you've been hacking too long when...
...you find yourself trying to CTRL-S the credits rolling on the TV screen.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgLJGgACgkQbtAgaoJTgL+ENACfdFfYhoJOEyQXH74RLVJTwHvr
j1YAoJFjrNuIUM4tqyo8vu6CpyHLhIfm
=sv4J
-----END PGP SIGNATURE-----
 
C

Christopher Dicely

I think Ruby is a fine language for what you are proposing. The things I think
you need to do are (1) choose an existing database system to use as the storage
backend (PostgreSQL is a good open source option), (2) choose a Ruby database/
ORM library (ActiveRecord, part of Rails but usable outside of it, is
pretty popular;
I'm personally fond of Sequel), and (3) choose a Ruby GUI toolkit (FXRuby would
be my choice; there is a good book out which covers it well, its
cross-platform, and
it should do what you need.)

I wouldn't try to do the storage layer from scratch: its a big and
critical task,
and unless there is some reason the existing solutions don't work for you, not a
risk that it is necessary or probaby worthwhile to take on.
 
T

Todd Benson

I think Ruby is a fine language for what you are proposing. The things I think
you need to do are (1) choose an existing database system to use as the storage
backend (PostgreSQL is a good open source option), (2) choose a Ruby database/
ORM library (ActiveRecord, part of Rails but usable outside of it, is
pretty popular;
I'm personally fond of Sequel), and (3) choose a Ruby GUI toolkit (FXRuby would
be my choice; there is a good book out which covers it well, its
cross-platform, and
it should do what you need.)

and (4) make sure you don't distort what is supposed to be good data
from the database (that would be like performing what seems like Ruby
magic on the data, but not ending up with a sound result).

Todd
 
C

Chris Lowis

Last but not least, there is the Fox GUI toolkit, too (which recently
got a book published aimed at people who haven't created a GUI
application yet, too).

Also, depending on your application, a web-based GUI developed using
Rails for example, might be sufficient. At least this way you don't
have to worry about updating the application on the users' machines,
and it (partly) solves the cross-platform issue.

Chris
 
C

Coey Minear

My first recommendation would be to go out and buy the book 'Mastering
Data Modeling' by John Carlis and Joseph Maguire
(http://www.informit.com/store/product.aspx?isbn=020170045X). Read it
and use the tools and techniques to map out your data model for the
database FIRST. The book is extremely easy to read, with lots of
examples and stories about using the techniques described. It will
really help you understand your company's data and what's important to
be stored.

(Full disclosure: John Carlis taught my Master's database course, and
I freely admit that I "drank the Kool-aid". So yes I am a bit
partial, but his opinions on data modeling do make sense.)

Next, as others have suggested, consider Ruby On Rails for the "GUI".
Everyone has a web browser so you don't have to worry about deploying
the GUI. Also, Rails provides tools that make accessing the data very
easy, so you don't have to spend time writing that database
interaction code.

Probably the biggest issue will be resolving the conflict between what
'Mastering' and Rails use for conventions: singular vs. plural
entity/table names and natural vs. just-use-integer sequence primary
keys being the two biggest. My advice would be to just use Rails'
conventions when you get to the implementation stage. The point with
the techniques in 'Mastering' is that you get a good understanding of
your data before you start writing a bunch of code that assumes
something that will change drastically later.

Coey


Christopher said:
Background:

I'm interested in building a database for my company so that we can
store information on accounts, work orders, production records,
experimental data, etc. My programming experience started with
Mathematica, was followed by LaTeX, then by Matlab, then Maple, then
Labview and most recently, I've started learning Ruby. I really like
Ruby as a functional language, though I haven't gotten my feet too wet
with languages of that sort of ilk yet. I haven't been programming with
it (or any of the other) for very long, but I've found that with my
mathematics background I've been able to pick up all of these languages
very quickly, and feel quite confident that (with some work, to be sure)
I can build a database and GUI which will meet our companies needs for
an easy to use and highly flexible database.


Questions:

Having not had much experience in the sort of languages which would be
suitable for such an endeavor, I don't know what the pros vs. cons of
using Ruby to develop such a program would be. My impression is that
with Ruby's rich class structure and flexibility it would be a good
language to use. What I don't know is if there are things that I need to
consider before getting too far down along this path. For instance, I've
read that the linguistic structure of Ruby was created with the
programmer in mind, not the computer. Does that mean that a ruby program
of the sort in question might be too fricken slow to deal with all the
info? I know that MATLAB is famed for it's array handling - is there a
way that embedded C compilations of matlab programs may be able to drive
an array based storage and retrieval scheme with more speed than Ruby
alone? Are there other problems that I haven't thought about? Have
others made programs like this with Ruby? Were they successful?

The other concern of mine is making the GUI. Labview has a pretty simple
drag and drop style GUI development structure - that's all I've used on
that front. I tried working with visual basic once, but didn't get very
far, mostly because for what we were doing Labview was easier and
someone at my work was able to teach it to me (Incidentally, I've ben
learning Ruby for fun on my own time). As I understand it, there are a
few options for getting a Ruby-GUI. Ideally, this would be runnable on
either windows or mac (at work we use win but I run a mac on my
computer). I've downloaded Shoes, but haven't really used it at all yet.
It doesn't seem to be tailored for designing complex GUIs. As I
understand Cocoa is a great way to go if you want to run on macs - is
there a way to get a Cocoa script to run on PCs? How do programs like
iTunes work on PCs? In general, what would the best (or at least some
good) multi-platform language(s) be for embedding Ruby within a GUI?


Any and all help/comments/suggestions are welcome! Thanks.

--
Coey Minear
Senior Test Engineer
(651) 628-2831
(e-mail address removed)

Secure Computing(R)
Your trusted source for enterprise security(TM)
http://www.securecomputing.com
NASDAQ: SCUR


*** The information contained in this email message may be privileged,
confidential and protected from disclosure. If you are not the intended
recipient, any review, dissemination, distribution or copying is
strictly prohibited. If you have received this email message in error,
please notify the sender by reply email and delete the message and any
attachments. ***
 
T

Todd Benson

Probably the biggest issue will be resolving the conflict between what
'Mastering' and Rails use for conventions: singular vs. plural
entity/table names and natural vs. just-use-integer sequence primary
keys being the two biggest. My advice would be to just use Rails'
conventions when you get to the implementation stage. The point with
the techniques in 'Mastering' is that you get a good understanding of
your data before you start writing a bunch of code that assumes
something that will change drastically later.

Coey

I should mention that you can use your own table names in Rails, you
can have your own primary key, and you can fake your _multiple_
natural keys with the 'unique' constraint. But it takes a little more
work, and is a little more problematic when fleshing out bugs.

It can be done though. I wrote a small IT support db for Rails called
icanhazfix with table names like 'happiez' instead of 'users' with key
'kitteh', and 'naybrhud' instead of 'groups' with key 'famfam'.

Todd
 
M

Martin Vales

I have finished my first application in Ruby successfully. I work in an
engineering company working in critical applications. (DXF files of 250
megas, images of 1 giga proccesed thanks to imagemagick-rmagick, etc,
pdfs with pdf::writer...)
In the past I used Scilab (similar to matlab), but we now have the
library GSL for ruby.

My recommendation is that you use SQlite as a database and ruby-gnome
like graphical interfaces.


In windows we can create a single executable using these technologies.

http://www.erikveen.dds.nl/rubyscript2exe/

You have 0 dependencies, because you have in the EXE the GTK libraries
and the QLite library in a easy way.
That depends. For realtime calculation Ruby is too slow (as are all
interpreted languages), but you may gain speed by using JRuby and it's
JIT compiler for Ruby.


Jruby i don´t think was more quick because in implemented in JAVA nor in
C. jruby is like jython nor based in the virtual machine.
I have try use ruby.NET (CLR) and ironruby (DLR), but i haven´t could...
I hope parrotcode people save the world!!!
http://www.parrotcode.org/

For me ruby used in a standard way (interpreted) is very suitable for
little engineering applications and tests.

Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top