Page 1 of 3

Ruby

Posted: Wed Jan 11, 2012 5:13 pm
by Phantom
Ok pepe!! Ruby is coming... Ruby like Python, is a very powerfull language. Whitout shame... ask me, and... we can discuss about it. I recommend you Python and Ruby... the future in the present.

Re: Ruby

Posted: Thu Jan 12, 2012 1:27 am
by jelara
I have heard a lot of great things about Ruby, and to learn it has been on my "to do" list for a while now.

But of course, for contest programming I still recommend you guys C++: nothing compares to the speed of this language (you know, because there is no VM running it). Those extra seconds can mean the difference between an AC and a TLE (and I speak from experience here :lol:).

But yes, Ruby is coming. We will continue working to add to our judge as many languages as possible.

Ruby

Posted: Sat Jan 14, 2012 5:30 pm
by Phantom
My opinion is the same. C and C++ are very fast, that don’t have discussion. But… in C and C++ you have to implement almost everything. Itch! That is a problem… and big! For example, in Ruby for the big powers of 3 you most only write:
puts 3**gets.to_i
In Pthon:
print 3**input()
-->The numbers in Python and Ruby are very big. In this languages aren’t the problems of the numbers of 32 and 64 bits.
-->In Python and Ruby you don’t need write the type of a variable, the language recognize it in execution time. This is a powerful and interesting tool, because that made dynamic the variables. If you want, I'll explain you this philosophy deeper.
For example… in C,C++,C#,Java,… you would write:
int pepe = 56;
In Python and Ruby you only write:
pepe=56
Moreover, you can write after:
pepe=”friend”
And now pepe isn’t a integer, is a string.
-->In Python and Ruby you can return different things in a same method:
In Ruby:
def Something(bool)
return bool ? 56 : "pepe is my friend"
end
In Python:
def Something(bool):
return 56 if bool else “pepe is my friend”
-->I thing I have stop here because I excite easy with the facilities of this languages. We will see in a next class. :D

Re: Ruby

Posted: Tue May 15, 2012 9:06 pm
by Robbin
People tell me that Ruby is a strong language..
can you tell me something about it?

Re: Ruby

Posted: Fri May 18, 2012 1:25 am
by Robbin
well, that's it:
what's the principal structure on a ruby program?

Re: Ruby

Posted: Wed May 23, 2012 7:54 pm
by Phantom
Jajajaja In my opinion, Ruby is a strong language for the same reason that Python is a strong language. If you understand why Python is a strong language, you understand why Ruby is a strong language. In my opinion Python and Ruby is almost the same, with the difference that one recognize for indentation and the other, no (have another big differences, but I said that for you can have an idea in the similarity).
Can you be more specific when you say “structure”? Because I understand by “structure” many things.

Re: Ruby

Posted: Wed May 23, 2012 8:47 pm
by Robbin
a simple program, the basic program, hello world!!, for example
and the declaration of a function..
I gotta go..

Re: Ruby

Posted: Sun Jun 03, 2012 11:32 pm
by Phantom
Here your example…:

def printHelloWorld()
--puts "Hello World!!"
end

printHelloWorld()


I put the “Hello World” in a function, because you want the declaration of a function.
In Ruby are a “print” too, but “print” is like a “printf(“Hello World”);” in C++ (without the ‘\n’ at the end). You see?? Is almost like Python. :)

Re: Ruby

Posted: Tue Jun 05, 2012 7:07 pm
by Robbin
I see.. so I don´t have to write the ":" when I declare a function, rigth??

And, how can I read variables from the keyboard in ruby??
It´s interesting..

Re: Ruby

Posted: Wed Jun 06, 2012 10:45 pm
by Phantom
In the previous post I wrote how you can read variables from the keyboard in ruby, but, fine, I´ll repat it.

In Ruby you read with "gets" and the string have methods to convert to "int" or to other types:
For example, to convert a string to int:
pepe = "45"
pepe = pepe.to_i
#Now pepe is equal to 45(interger)

For this reason, you can write:
pepe = gets.to_i

See it!!!
"to_i" is a function. I have not commit an error in write "pepe.to_i" and not "pepe.to_i()". In Ruby the parenthesis is optional.