Have you tried Ruby?

ggganz

a.k.a. The Scyphozoa
Joined
Jun 25, 2006
Messages
3,485
Location
Sector 5
Very cool programming langruage, get at http://rubyinstaller.rubyforge.org/wiki/wiki.pl. I am learning to use it with Learn to Program by Chris Pine. So far I have written this program:
Hello. What's your name?
ggganz
Hello ggganz. That is a nice name. When were you born?
October 13, 1994
You were born on October 13, 1994? How old does that make you? I am not that good at math. :(
12
You are 12? How does it feel to be that old?
Okay
Okay? Interesting. I have to go. Goodbye!

Pretty cool, huh? I know you can do WAY more, but I have only done about half an hour of this.
 
Very cool programming langruage, get at http://rubyinstaller.rubyforge.org/wiki/wiki.pl. I am learning to use it with Learn to Program by Chris Pine. So far I have written this program:
Hello. What's your name?
ggganz
Hello ggganz. That is a nice name. When were you born?
October 13, 1994
You were born on October 13, 1994? How old does that make you? I am not that good at math. :(
12
You are 12? How does it feel to be that old?
Okay
Okay? Interesting. I have to go. Goodbye!

Pretty cool, huh? I know you can do WAY more, but I have only done about half an hour of this.
I guess you're a brand new programmer. I personally do not know Ruby.
 
Well, like I said, I have not learned much about this. But I have already written a *slightly* interactive program.

Oh, if anyone downloads this, then I forgot to mention two things: 1. Do not use notepad to edit these, instead, right click the file and select edit. It opens SciTE, which is a text editor that highlights Ruby Syntax, if you save it as a Ruby (.rb) file, and 2. To run them you have to open up command prompt, then navigate to the folder where the Ruby files are, then type "ruby" followed by the name of the file.
 
No i won't try Rugby, and i never will. Likewise with Hockey. I for one, prefer to keep my teeth and bones.

oops. Edit: I thought this was in the Sports section. :lol: I didn't know it was about a programming language or something.
 
Doesn't look bad, though I haven't tried it out myself (and due to lack of time, don't think I will anytime soon). Our trainees are basically going bonkers over it, though :)

I'll stick to Java for now :)
 
No i won't try Rugby, and i never will. Likewise with Hockey. I for one, prefer to keep my teeth and bones.

oops. Edit: I thought this was in the Sports section. :lol: I didn't know it was about a programming language or something.
Uh, yeah you did.
EDIT: Here's why you should use Ruby.
Learn to Program by Chris Pine said:
Perhaps the best reason for using Ruby is that Ruby programs tend to
be short. For example, here’s a small program in Java:
public class HelloWorld {
public static void main(String []args) {
System.out.println("Hello World");
}
}
And here’s the same program in Ruby:
puts ' Hello World'
This program, as you might guess from the Ruby version, just writes
Hello World to your screen. It’s not nearly as obvious from looking
at the Java version.
How about this comparison: I’ll write a program to do nothing! Nothing
at all! In Ruby, you don’t need to write anything at all; a completely
blank program will work just fine.
In Java, though, you need all this:
public class DoNothing {
public static void main(String[] args) {
}
}
You need all that just to do nothing, just to say, “Hey, I am a Java
program, and I don’t do anything!” So that’s why we’ll use Ruby. (My
first program was not in Ruby, which is another reason why it was so
painful.)
 
Uh, yeah you did.
EDIT: Here's why you should use Ruby.

Looks more like why you shouldn't use Java to me :lol: Same program in Python:
Code:
print 'Hello World'

I'm not bashing Ruby as I've never tried it but currently I see no reason to shift away from Python.
 
I'll stick to Java for now :)

AGREED!

I am loving Java and every minute, but I don't think I will be switching to Ruby any time soon or at all for that matter. :lol:


Typically if a programming language is easy to use it is more times than not; less powerful. Java is IMO stronger than Ruby and if done right Java can out do anything ruby can do
 
Hm, well, I've actually written a useful program (slightly). It takes all the words you type in, then when you press Enter on a blank line, it gives them back to you in alphabetical order! Here is how simple the code is:
Code:
words=[]
word=gets.chomp
while word!=''
words.push(word)
word=gets.chomp
end
puts words.sort
And you can almost read it in English! It would say:

Code:
words=(make new array)
word=(what you type in, minus the Enter at the end)
while word does not=(nothing)
(push word onto the end of the array of words)
(end the "while" loop)
(put words array, sorted)
:D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D
 
i've heard python and ruby are similar, but I've never actually seen ruby's syntax. Any idea what the differences are?
 
puts "How is it useful?"
You idiot its
Code:
puts 'How is it useful?'
with SINGLE QUOTES!!
i've heard python and ruby are similar, but I've never actually seen ruby's syntax. Any idea what the differences are?

Never really seen Python's syntax, other than Civ4 files, but that's way too complicated for me.
 
Is there any advantage to '' instead of "", other than if you're planning on writing a string with " in it but no ', you would use "" so you don't have to \.

Here's one reason to use Ruby instead of Python: it has a built in string class!!!
Whatever that means.
 
Back
Top Bottom