Andreas' practical language comparison

Hi all!

It looks like Ruby is missing in “Andreas’ practical language comparison”
(Here’s the page http://www.kochandreas.com/home/language/lang.htm)
I guess it’d be nice if Ruby won an appropriate place in the competition.
Regards,
Georgy

···

Hi all,

i started a little “practical language comparison” - practical
in the sense that i compare how actual distributions and versions
and their libraries (not abstract language specifications) solve small
test cases like the 8 queens problem.

Currently there are contributions for 17 different languages, and
none for Phyton (and Lisp. And Forth. And many others ).
If someone is interested in contributing a few implementations,
please have a look at:

http://www.kochandreas.com/home/language/lang.htm

and mail me your code snippets (or critics) or post them here.

                 thanks a lot,

Partly done. Some shorties there. Any volunteers for GUI stuff?

robert

“Georgy” no.mail@available.net schrieb im Newsbeitrag
news:ChAtc.3293$%f3.67408@twister.southeast.rr.com…

···

Hi all!

It looks like Ruby is missing in “Andreas’ practical language comparison”
(Here’s the page http://www.kochandreas.com/home/language/lang.htm)
I guess it’d be nice if Ruby won an appropriate place in the competition.
Regards,
Georgy

Hi all,

i started a little “practical language comparison” - practical
in the sense that i compare how actual distributions and versions
and their libraries (not abstract language specifications) solve small
test cases like the 8 queens problem.

Currently there are contributions for 17 different languages, and
none for Phyton (and Lisp. And Forth. And many others ).
If someone is interested in contributing a few implementations,
please have a look at:

http://www.kochandreas.com/home/language/lang.htm

and mail me your code snippets (or critics) or post them here.

                 thanks a lot,

I’ll volunteer for some of the GUI stuff…Any specific timeframe we are
working in or no? Also, does it matter if we use Ruby/Tk, Ruby/GTk or the
Ruby/Fx?

Zach

···

-----Original Message-----
From: Robert Klemme [mailto:bob.news@gmx.net]
Sent: Friday, May 28, 2004 1:34 PM
To: ruby-talk ML
Subject: Re: Andreas’ practical language comparison

Partly done. Some shorties there. Any volunteers for GUI stuff?

robert

“Georgy” no.mail@available.net schrieb im Newsbeitrag
news:ChAtc.3293$%f3.67408@twister.southeast.rr.com…

Hi all!

It looks like Ruby is missing in “Andreas’ practical language comparison”
(Here’s the page http://www.kochandreas.com/home/language/lang.htm)
I guess it’d be nice if Ruby won an appropriate place in the competition.
Regards,
Georgy

Hi all,

i started a little “practical language comparison” - practical
in the sense that i compare how actual distributions and versions
and their libraries (not abstract language specifications) solve small
test cases like the 8 queens problem.

Currently there are contributions for 17 different languages, and
none for Phyton (and Lisp. And Forth. And many others ).
If someone is interested in contributing a few implementations,
please have a look at:

http://www.kochandreas.com/home/language/lang.htm

and mail me your code snippets (or critics) or post them here.

                 thanks a lot,

Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.684 / Virus Database: 446 - Release Date: 5/13/2004


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.684 / Virus Database: 446 - Release Date: 5/13/2004

I found time to do “Red Ball” just now, hope no one else was faster. I
think it looks pretty cool in ruby (dunno if it goes even
better). Especially comparing it to the python-version…

···

It looks like Ruby is missing in “Andreas’ practical language
comparison” (Here’s the page
http://www.kochandreas.com/home/language/lang.htm) I guess it’d be
nice if Ruby won an appropriate place in the competition.
Partly done. Some shorties there. Any volunteers for GUI stuff?

Zach Dennis wrote:

I’ll volunteer for some of the GUI stuff…Any specific timeframe we are
working in or no? Also, does it matter if we use Ruby/Tk, Ruby/GTk or the
Ruby/Fx?

Zach

How about wxRuby?

Curt

“Hynek Schlawack” hynek+usenet@hys.in-berlin.de wrote in message news:87oeo6djjk.fsf@squirrel.dyndns.org

I found time to do “Red Ball” just now, hope no one else was faster. I
think it looks pretty cool in ruby (dunno if it goes even
better). Especially comparing it to the python-version…

Hi,
I didn’t understand your sarcasm about Python. If you compare equivalent programs
written on Ruby and Python, they’ll be extremely the same:

#!/bin/env python

We use the Tk-Toolkit

from Tkinter import Tk, Canvas
from random import randint # G-: Okey, okey, I added these two lines
from sys import exit # and removed two 'end’s. Agreed? :slight_smile:

Create a root-widget, a canvas and a hash to store the squares

root = Tk(); root.title( ‘Red Ball’ )

c = Canvas(root, width=320, height=200)
fig = {}

Create the squares with the appropriate colors on random places

for colour in (‘black’, ‘red’):
x = randint(0, 320 - 16)
y = randint(0, 200 - 16)
fig[colour] = c.create_rectangle( x, y, x+15, y+15, fill=colour )

c.pack()

Move the square in the desired direction, exit if we have won

def move_player(x, y):
c.move( fig[‘red’], x, y )
print c.coords(fig[‘red’]), c.coords(fig[‘black’])
if c.coords(fig[‘red’]) == c.coords(fig[‘black’]): exit(0)

Bind the actions to keys

root.bind(“s”, lambda e: move_player(-1, 0) )
root.bind(“d”, lambda e: move_player( 1, 0) )
root.bind(“e”, lambda e: move_player( 0, -1) )
root.bind(“x”, lambda e: move_player( 0, 1) )

Finally give up control to Tk

root.mainloop()

Regards,
Georgy

I believe some little tweaks may make this little more rubyish:
get rid of global variables using a constant, a local, and defining
move_player as a singleton method of the canvas object

#!/bin/env ruby

We use the Tk-Toolkit

require ‘tk’

Create a root-widget, a canvas and a hash to store the squares

root = TkRoot.new { title “Red Ball” }
canvas = TkCanvas.new(root) { width 320; height 200 }
Fig = Hash.new

Create the squares with the appropriate colors on random places

[‘black’, ‘red’].each do | colour |
x = (rand * (320 - 16)).to_i
y = (rand * (200 - 16)).to_i
Fig[colour] = TkcRectangle.new(canvas, x, y, x+15, y+15, ‘fill’ =>
colour)
end

canvas.pack

Move the square in the desired direction, exit if we have won

def canvas.move_player(x, y)
move(Fig[‘red’], x, y)
exit if (coords(Fig[‘red’]) == coords(Fig[‘black’]))
end

Bind the actions to keys

root.bind(“s”) { canvas.move_player(-1, 0) }
root.bind(“d”) { canvas.move_player( 1, 0) }
root.bind(“e”) { canvas.move_player( 0, -1) }
root.bind(“x”) { canvas.move_player( 0, 1) }

Finally give up control to Tk

Tk.mainloop

···

il Sun, 30 May 2004 17:25:03 +0200, Hynek Schlawack hynek+usenet@hys.in-berlin.de ha scritto::

It looks like Ruby is missing in “Andreas’ practical language
comparison” (Here’s the page
http://www.kochandreas.com/home/language/lang.htm) I guess it’d be
nice if Ruby won an appropriate place in the competition.
Partly done. Some shorties there. Any volunteers for GUI stuff?

I found time to do “Red Ball” just now, hope no one else was faster. I
think it looks pretty cool in ruby (dunno if it goes even
better). Especially comparing it to the python-version…

I’ve never used wxRuby. I’ll print off some of it’s documentation before I
leave town( in about 20 minutes ) and try to catch up over the weekend.

Zach

···

-----Original Message-----
From: Curt Hibbs [mailto:curt@hibbs.com]
Sent: Friday, May 28, 2004 3:15 PM
To: ruby-talk ML
Subject: Re: Andreas’ practical language comparison

Zach Dennis wrote:

I’ll volunteer for some of the GUI stuff…Any specific timeframe we are
working in or no? Also, does it matter if we use Ruby/Tk, Ruby/GTk or the
Ruby/Fx?

Zach

How about wxRuby?

Curt


Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.684 / Virus Database: 446 - Release Date: 5/13/2004


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.684 / Virus Database: 446 - Release Date: 5/13/2004

I checked out wxRuby over the extended Holiday(U.S. Holiday) and I started
on the miniSpreadSheet for the comparision.

When I’m done with wxRuby I think I am going to try it with Tk and then with
FXRuby just for kicks. Although I do have a few questions for some spots in
wxRuby if there are any wxRuby gurus out there. I’ll post another topic
though for those.

Zach

···

-----Original Message-----
From: Curt Hibbs [mailto:curt@hibbs.com]
Sent: Friday, May 28, 2004 3:15 PM
To: ruby-talk ML
Subject: Re: Andreas’ practical language comparison

Zach Dennis wrote:

I’ll volunteer for some of the GUI stuff…Any specific timeframe we are
working in or no? Also, does it matter if we use Ruby/Tk, Ruby/GTk or the
Ruby/Fx?

Zach

How about wxRuby?

Curt


Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.684 / Virus Database: 446 - Release Date: 5/13/2004


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.684 / Virus Database: 446 - Release Date: 5/13/2004

Not that I like Tk particularly, but it ships with ruby on Unix and
Windows platform. And not to rely on any external library is a
‘requirement’ of the implementation.

Guillaume.

···

On Fri, 2004-05-28 at 15:20, Zach Dennis wrote:

I’ve never used wxRuby. I’ll print off some of it’s documentation before I
leave town( in about 20 minutes ) and try to catch up over the weekend.

Zach

-----Original Message-----
From: Curt Hibbs [mailto:curt@hibbs.com]
Sent: Friday, May 28, 2004 3:15 PM
To: ruby-talk ML
Subject: Re: Andreas’ practical language comparison

Zach Dennis wrote:

I’ll volunteer for some of the GUI stuff…Any specific timeframe we are
working in or no? Also, does it matter if we use Ruby/Tk, Ruby/GTk or the
Ruby/Fx?

Zach

How about wxRuby?

Curt


Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.684 / Virus Database: 446 - Release Date: 5/13/2004


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.684 / Virus Database: 446 - Release Date: 5/13/2004

Zach Dennis wrote:

I checked out wxRuby over the extended Holiday(U.S. Holiday) and I started
on the miniSpreadSheet for the comparision.

When I’m done with wxRuby I think I am going to try it with Tk
and then with
FXRuby just for kicks. Although I do have a few questions for
some spots in
wxRuby if there are any wxRuby gurus out there. I’ll post another topic
though for those.

The best thing would be to subscribe to the wxRuby Users mailing list:

http://rubyforge.org/mail/?group_id=35

The main developer of wxRuby (Kevin Smith) is pretty good about answering
questions, and he does not read the ruby-talk ML. On the downside, he is
also moving 300km this month so his online time may be spotty. Fortunately
all of the major users of wxRuby (who are also very helpful) are also on the
wxRuby ML.

If you prefer to post here, I will cross post it to the wxRuby ML for you
(although you’ll get faster turnaround without me in the loop).

Curt

And not to rely on any external library is a ‘requirement’
of the implementation.

Well, Ruby lacks any truly native GUI interface by this definition. Tk
bindings will only build if you have the external Tk libraries
installed, at least on Linux.

FXRuby is probably the closest thing to a standard GUI toolkit that
Ruby has, aside from Tk. wxRuby has potential, but it is still a
relatively young project.

— SER

What about ruby-gnome(2) with Gtk(2)? At least the latter is also ported
to Windows.

Bye,
phil

···

On 2004-05-28, SER ser@germane-software.com wrote:

FXRuby is probably the closest thing to a standard GUI toolkit that
Ruby has, aside from Tk. wxRuby has potential, but it is still a
relatively young project.


Please send replies (not followups) to the address set in Reply-To.
Philipp Kern - PK2186-RIPE - http://www.philkern.de