Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What language is this?
#11
(02-20-2010, 06:43 PM)trilobyte- Wrote: Ruby > Python. I've never really gotten into programming, but I found Ruby so easy that I ended up starting to learn it. Smile And @ Anon, it's not like it's not advanced or anything. You can do some pretty amazing stuff with it, especially learnings rails too. Ruby + Rails = Easiest Blog Software ever.

Not really sure about Ruby but imo Python is the easiest to learn and it has short clear syntax which is just fantastic for sharing/reading snippets. As far as how advanced Python can be when you get into topics such as the internet all I have to say is:
Google, Youtube
As for the example on the site:
Code:
say = "I love Ruby"
puts say
say['love'] = "*love*"
puts say.upcase
5.times { puts say }
Python:
Code:
say = 'I love Python'
print say
say.replace('love', '*love*')
print say.upper() * 5
Not only is the python code one line shorter, it looks pretty Smile
[Image: izsyo6.jpg]


Reply
#12
Python might be shorter but Ruby is more descriptive. For example Python just has a "* 5" as for Ruby "5.times". Ruby is easier to memorize and understand as a beginner ;).
Reply
#13
I honestly think '*' is pretty descriptive considering it is the multiplication operator in just about every language I can think of( besides Ruby), and Python is shorter which means less work for you and less pain on the eyes of readers. Challenge: Create a program that add's all the numbers under 1000 that are multiples of 3 or 5. Here is the python script:
Code:
reduce(lambda x,y : x+y, [x for x in xrange(1000) if x % 3 == 0 or x % 5 == 0])
Now create the ruby script and let's see the difference.
Credits:
http://www.supportforums.net/showthread.php?tid=988
[Image: izsyo6.jpg]


Reply
#14
Is there a Ruby program as Visual Basic or write in notepad?
Reply
#15
(02-20-2010, 10:39 PM)uber1337 Wrote:
Code:
reduce(lambda x,y : x+y, [x for x in xrange(1000) if x % 3 == 0 or x % 5 == 0])

We can do it like that too, by packing everything together.
Code:
x=0;(0..1000).each{|f|(f%3==0||f%5==0)?x+=f : nil}

or we could do this:

Code:
#!/usr/bin/env ruby
def calculate()
  tmp = 0
  (0..1000).each do |number|
    if (number % 3 == 0 || number % 5 == 0) then
      tmp += number
    end
  end
puts number
end
calculate()

-------------------------------------------------------------------------------------

(02-20-2010, 10:39 PM)uber1337 Wrote: I honestly think '*' is pretty descriptive considering it is the multiplication operator in just about every language I can think of( besides Ruby)

Code:
irb(main):001:0>  5 * 5
=> 25
irb(main):009:0> print " a " * 3
a  a  a
=> nil

You can multiply using "*" in Ruby

------------------------------------------------------------------

Good code is code that you can read.
Or maybe I'm just retarded and my code doesn't work. :O
Reply
#16
(02-20-2010, 10:39 PM)uber1337 Wrote: You can multiply using "*" in Ruby

Good, thank you for pointing that out.

(02-23-2010, 03:16 AM)Wolskie Wrote: We can do it like that too, by packing everything together.
Code:
x=0;(0..1000).each{|f|(f%3==0||f%5==0)?x+=f : nil}

or we could do this:

Code:
#!/usr/bin/env ruby
def calculate()
  tmp = 0
  (0..1000).each do |number|
    if (number % 3 == 0 || number % 5 == 0) then
      tmp += number
    end
  end
puts number
end
calculate()
Oh yeah I forgot that ruby was the optimal language for ugly one liners Smile forgot who I was messing with Tongue. As someone over at HF put it:
Python is SO readable. A lot of Rubyists are obsessed with the 'Ruby Way', which usually consists of single-line, multi-layered functional code, making it unmaintainable.
Don't get me wrong I love one liners, but
Code:
x=0;(0..1000).each{|f|(f%3==0||f%5==0)?x+=f : nil}

Looks very hard to digest.
[Image: izsyo6.jpg]


Reply
#17
Lets settle this here, and agree on: "A Programming language is only what you make to to be". Right? If you don't like it then it's not for you. Smile
Reply
#18
(02-23-2010, 09:54 PM)Wolskie Wrote: Lets settle this here, and agree on: "A Programming language is only what you make to to be". Right? If you don't like it then it's not for you. Smile

Yeah I didn't want to start a language war, especially against one I know little to nothing about. Just try all the languages and choose the one you can understand and have fun with.
[Image: izsyo6.jpg]


Reply
#19
(02-23-2010, 09:54 PM)Wolskie Wrote: Lets settle this here, and agree on: "A Programming language is only what you make to to be". Right? If you don't like it then it's not for you. Smile
No, Python > Ruby still. This the only place you can argue about Python and Ruby:

GOOOOO GREEN!!!!!
Do what thou wilt shall be the whole of the Law. Love is the law, love under will.
.::The Rights of Man::.
Reply
#20
(02-26-2010, 09:13 PM)Μαύρο Wrote: No, Python > Ruby still. This the only place you can argue about Python and Ruby:

GOOOOO GREEN!!!!!
http://www.wikivs.com/wiki/Python_vs_Ruby
sums a lot of it up. I think python is the better language and I personally love the python philosophy:
Code:
import this
I also hate ruby's syntax, "puts", "do", the fact that you need to "end" things, it just sounds juvenile to me.
Here is a great video of a guy that has coded in both and tackles the good and bad of both languages:
http://vimeo.com/9471538
[Image: izsyo6.jpg]


Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)