Forum: Ruby Entry-level help

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Patrick E. (Guest)
on 2007-07-21 09:18
Hellos,

I'm not sure how detailed I should make my situation here.  I had some
long, history-spanning essay on what I'm doing, but that seemed tedious
to read through.  Basically, what it said was:  I'm a pretty big newbie,
both to Ruby and programming in general (just a couple courses in Java
in college a couple years ago), looking to break into the field (and out
of soul-killing tech support).  I'm giving myself projects to keep the
learning interesting (since I have no teachers) but my current one seems
like it could go a number of ways.

I want to write a basic simulation (predator/prey) that has a simple GUI
that I can display using a website, using Ruby for the number crunching,
JS for the application GUI and HTML to handle whatever else on the page
(or something...I hear of terms like XHTML, XML and AJAX thrown around,
but I don't have a firm grasp on them)

I'm just coding in Windows, but would like the simulation to be visible
to any member of the public who visits the website that contains it
(with no user interaction at first, just a display to everyone watching
what's happening).  Is it feasible for this project to use all three
without needing to convert Ruby to JS, or would the project really just
end up being in Javascript and whatever markup language the page would
need?

Thanks for any advice you all can give!
Chad P. (Guest)
on 2007-07-21 10:10
(Received via mailing list)
On Sat, Jul 21, 2007 at 02:18:55PM +0900, Patrick Erinn wrote:
>
> I want to write a basic simulation (predator/prey) that has a simple GUI
> that I can display using a website, using Ruby for the number crunching,
> JS for the application GUI and HTML to handle whatever else on the page
> (or something...I hear of terms like XHTML, XML and AJAX thrown around,
> but I don't have a firm grasp on them)

HTML reached version 4.  Now there's XHTML, and it looks like HTML
itself
is going the way of the dinosaurs (thank goodness).  You can effectively
think of XHTML as HTML 5.  It is, in practice, just a better HTML, and
most of XHTML is strictly compatible with HTML.  The most glaring
difference for the simplest use cases is that in XHTML you must close
all
tags.  Another key difference is that with XHTML it is expected that
presentation details (such as font color, background color, typeface,
margin sizes, and so on) will be handled entirely by CSS rather than by
markup.

XML is a superset of XHTML.  You probably won't need it for what you're
talking about doing.

AJAX is pretty much Web2.0-ese for "JavaScript can be useful now."  It
stands for Asynchronous JavaScript And XML, though in practice it's
really mostly XHTML rather than XML proper.  When someone's using AJAX,
he or she is basically just using JavaScript to allow communication
between server and client to alter the content of the page and shuttle
data to and from the server without having to reload the whole page
every
time something changes.  This is the sort of thing that allows, for
instance, Google Maps to be dragged around inside the page to view
different parts of the map.


>
> I'm just coding in Windows, but would like the simulation to be visible
> to any member of the public who visits the website that contains it
> (with no user interaction at first, just a display to everyone watching
> what's happening).  Is it feasible for this project to use all three
> without needing to convert Ruby to JS, or would the project really just
> end up being in Javascript and whatever markup language the page would
> need?

You can run Ruby on the server to handle all data on that end.
JavaScript is sent to the browser along with (X)HTML (and CSS), where it
can make the interface more "dynamic".

I'm not entirely clear on what exactly you want to accomplish, but I
suspect you'll want to use some language other than JavaScript -- such
as
Ruby -- on the server to handle the heavy lifting, and JavaScript with
XHTML+CSS in the browser to provide the interface for the user.  In
fact,
assuming you're using Ruby on the server, I imagine you'd be using Ruby
to generate at least parts of a page to be sent to the user, including
both markup and JavaScript, and depending on how fancy the interface
gets
you'll probably be using AJAX (with the XMLHttpRequest() JavaScript
object) to communicate with server's Ruby scripts.

If you're talking about something akin to Conway's Game of Life, but
with
a predator/prey simulation as your model instead, you'll have to make
some hard decisions about how much should be handled in the browser and
how much on the server.
This topic is locked and can not be replied to.