# Ruby Online

**URL:** <https://www.ruby-forum.com/t/ruby-online/117786>\
**Category:** Ruby\
**Created:** [October 20, 2007, 6:47am UTC](https://www.ruby-forum.com/t/ruby-online/117786 "2007-10-20T06:47:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![superfly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/48db29/32.png) [@superfly](https://www.ruby-forum.com/u/superfly)\
**Post date:** [October 20, 2007, 6:47am UTC](https://www.ruby-forum.com/t/ruby-online/117786/1 "2007-10-20T06:47:30Z")

</div>

I have a code that I would just like to place on a webpage. Do I NEED  
ruby on rails to do that? Can I just copy the code I have paste it in  
some special HTML code and it’ll work?

All this program does is puts out words. It does not need user input or  
anything like that.

---

<div class="post-metadata">

**Author:** ![superfly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/48db29/32.png) [@superfly](https://www.ruby-forum.com/u/superfly)\
**Post date:** [October 20, 2007, 7:35am UTC](https://www.ruby-forum.com/t/ruby-online/117786/2 "2007-10-20T07:35:56Z")

</div>

Quoth Tj Superfly:

> I have a code that I would just like to place on a webpage. Do I NEED  
> ruby on rails to do that? Can I just copy the code I have paste it in  
> some special HTML code and it’ll work?
> 
> All this program does is puts out words. It does not need user input or  
> anything like that.

Take a look at ERuby, and/or CGI.

HTH,

---

<div class="post-metadata">

**Author:** ![superfly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/48db29/32.png) [@superfly](https://www.ruby-forum.com/u/superfly)\
**Post date:** [October 20, 2007, 8:38am UTC](https://www.ruby-forum.com/t/ruby-online/117786/3 "2007-10-20T08:38:42Z")

</div>

Tj Superfly wrote:

> I have a code that I would just like to place on a webpage. Do I NEED  
> ruby on rails to do that? Can I just copy the code I have paste it in  
> some special HTML code and it’ll work?

html is for displaying text. If you want to display your code, you can  
do that. hml doesn’t execute anything.

---

<div class="post-metadata">

**Author:** ![superfly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/48db29/32.png) [@superfly](https://www.ruby-forum.com/u/superfly)\
**Post date:** [October 20, 2007, 8:51am UTC](https://www.ruby-forum.com/t/ruby-online/117786/4 "2007-10-20T08:51:12Z")

</div>

7stud – wrote:

> html is for displaying text. If you want to display your code, you can  
> do that. html doesn’t execute anything.

On second thought, html does have and tags that allow  
you to execute some java code, and of course browsers understand  
javascript and flash. So, there might be a way to execute some Ruby  
code employing some advanced techniques.

---

<div class="post-metadata">

**Author:** ![superfly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/48db29/32.png) [@superfly](https://www.ruby-forum.com/u/superfly)\
**Post date:** [October 20, 2007, 7:26pm UTC](https://www.ruby-forum.com/t/ruby-online/117786/5 "2007-10-20T19:26:15Z")

</div>

Yea, thanks. I basically just want to be able to go to a website and  
it’ll automatically run the program when the page is loaded and then  
give me the information I need.

I’m still hunting.

---

<div class="post-metadata">

**Author:** ![superfly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/48db29/32.png) [@superfly](https://www.ruby-forum.com/u/superfly)\
**Post date:** [October 20, 2007, 8:02pm UTC](https://www.ruby-forum.com/t/ruby-online/117786/6 "2007-10-20T20:02:57Z")

</div>

On Sun, Oct 21, 2007 at 02:26:14AM +0900, Tj Superfly wrote:

> Yea, thanks. I basically just want to be able to go to a website and  
> it’ll automatically run the program when the page is loaded and then  
> give me the information I need.
> 
> I’m still hunting.

Look into eruby implementations. If you’re on a webhosting account that  
includes Rails support, it should also provide Ruby support. With Ruby  
support, you can stick an eruby executable in the cgi-bin and use that  
to  
execute inline Ruby code in your markup. More details of how this is  
used can be found in the free, online edition of the Pickaxe book:

[Programming Ruby: The Pragmatic Programmer's Guide](http://www.ruby-doc.org/docs/ProgrammingRuby/html/web.html)

Scroll down to the part that mentions “Embedding Ruby in HTML” for some  
details. If this looks like the solution you want, ask for more  
specifics about how to get eruby running, if you don’t figure it out for  
yourself through Google. If you’re interested in using Ruby CGI  
scripts,  
that page should help a bit with that as well.

I use eruby for some web development myself. It’s pretty easy to get  
along with.

---

<div class="post-metadata">

**Author:** ![superfly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/48db29/32.png) [@superfly](https://www.ruby-forum.com/u/superfly)\
**Post date:** [October 20, 2007, 8:43pm UTC](https://www.ruby-forum.com/t/ruby-online/117786/7 "2007-10-20T20:43:06Z")

</div>

Basically, it’s a simple program like this:

list = []

number = rand(list.length)

puts list[number]

I obviously have things in my array, but that’s the extent of the  
program. Just to randomly put out something from my array.

So no, I’m not even trying to create a website, I’m just looking for a  
way to put programs on the web for anyone to access and run.

---

<div class="post-metadata">

**Author:** ![superfly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/48db29/32.png) [@superfly](https://www.ruby-forum.com/u/superfly)\
**Post date:** [October 20, 2007, 8:31pm UTC](https://www.ruby-forum.com/t/ruby-online/117786/8 "2007-10-20T20:31:36Z")

</div>

On Oct 20, 2007, at 12:26 PM, Tj Superfly wrote:

> Yea, thanks. I basically just want to be able to go to a website and  
> it’ll automatically run the program when the page is loaded and then  
> give me the information I need.
> 
> I’m still hunting.
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

that’s pretty vague still.  
You want to run a program in the client (web browser) or on the  
server (host of the web site)?  
You want a dynamically generated site ( parts of the site)?  
If so, there are some things to learn.  
Not terribly difficult, but you will have to learn to do some things.  
You will need more specific details of what you want to do.

For dynamic sites, you could write the program in just about any  
language, though some are not very practical.  
Interpreted languages are most popular for this sort of thing, such  
as Perl, PHP, Python and Ruby, but you could do it in C, C++, Java,  
SmallTalk, or almost anything.  
Some will be easier to use than others.  
Nobody writes everything, it’s not practical. Libraries are used.  
Some libraries are more extensive than others. Some libraries are  
more coherently focused on web development than others. Some  
libraries are more focused into a system of development and are  
called ‘frameworks’.

Rails is a web development framework (or system) written in Ruby.  
There are others, such as IOWA and Merb and Camping, all done in Ruby.  
Maypole is a framwork in Perl. Symfony and Cake are PHP frameworks.  
Seaside is a Smalltalk framework. Plone and Django o are Python  
frameworks. Struts is a Java framework. All of these are examples of  
web development frameworks.

Each language has libraries of functions/methods/constants/etc… for  
things like web development or image processing or file manipulation.  
Examples are Ruby DBI, or Perl DBI, which are similar libraries in  
those languages for interfacing with a database.

Frameworks make use of existing libraries for a language and  
generally add additional libraries that are (often) specific to that  
framework and language. Frameworks also include a design methodology  
that ties all of those things together with the goal of creating  
writing software quickly and hopefully not having to recreate the  
same things again and again, focusing on creating common things  
easily (an example is the concept of CRUD applications, Create,  
Retrieve, Update, Destroy data, most applications are CRUD apps that  
do those things with some kind of data store, usually a database like  
MySQL, Oracle, or SQLite, but possibly a text file, or even many  
files in the operating system.)

Now for web site development, you have some choices. PHP is a  
language that was originally designed around web site development. It  
has a lot of libraries and functions that are geared toward web  
development. Therefore, it has become quite popular. However, it  
hasn’t had a lot of free, open-source frameworks available and  
popular. Most often people have developed their own proprietary  
frameworks with PHP.

Python, Perl, and Ruby have all been more general in nature from the  
beginning. These languages also have libraries that are geared toward  
things like web development, but these languages also have libraries  
geared toward doing other things as well.

Rails has been the killer-app for Ruby. It just happens to be a very  
well designed web development framework that has inspired more than a  
few frameworks in other languages as well. (symfony and cake borrow  
many ideas from Rails)  
Those frameworks are great if you use PHP, but they’re missing some  
things. Many of the things that make Rails successful and popular are  
because of the Ruby language itself. Ruby tends to facilitate good  
design and readability.

Each language has its own strengths. Perl has traditionally been the  
king of processing text and has some incredibly extensive libraries.  
Perl was the original CGI scripting language because of its text  
processing abilities and the fact that web servers were originally  
managed by systems administrators who also used Perl for lots of  
system admin tasks.

Python has similar qualities of Perl and Ruby. Some people simply  
prefer Python over Ruby or vice versa.

Your choice of language, libraries and frameworks should be based on  
personal taste and practical needs and capabilities.  
If you’re starting out, you can’t go wrong. If you already know a  
programming language you might want to go with web development in the  
same or a similar language.

That said, Ruby is not tough to learn and has a great community, and  
I’d say the same for Python. Perl can be a little tougher to learn  
because it is a little more cryptic, but it also has a great  
community. PHP is not tough to learn, but it is a lot less graceful  
than Ruby, Perl or Python. The PHP community is not always so kind.  
There are lots of jobs with PHP, but there is a lot of really badly  
designed software in PHP that is in use in companies too.

From personal experience, I can assure you, maintaining or working  
with other people’s code can be a pain. Open source and free software  
is wonderful, but has a (usually well-deserved) reputation for being  
messy and confusing. Ruby (and Python) tends to be really clean and  
fairly easy to read and maintain. PHP is usually a good example of  
mess. Perl is just very easy to make things very cryptic.

You might do well to browse a bookstore on some of these frameworks.
