Why Ruby over Python?

G

gregarican

For me it's not so much the shelling out as it is invoking some Ruby
methods that deal with files, directories, etc. or trying to use a
setup.rb Ruby routine that is trying to parse through the Windows
directory structure. Unfortunately some Ruby projects are still
maintained with a Linux focus and the support for Windows is lacking. I
have tried to manually "rig" fixes so that they can work with my
Windows platform but after an hour or so of futile effort I just switch
over to a Python alternative that does the same thing. Examples are
LDAP, Qt, and a few others. This was about a year ago so things might
have improved since then. YMMV...
 
M

M. Edward (Ed) Borasky

Francis said:
That's really interesting. Are these big companies that have given up on
major projects?
The one instance I'm most familiar with was a Linux/Apache/PHP project
using a legacy database. They were using Java for some essential
functionality but the real guts of the app was PHP. They pulled Java out
and moved the functionality somewhere else, but I don't recall where.
In my experience, the only thing that compares to Java in its desire
to be
the only major application running on a server is Oracle (which seems
to eat
as much shared memory as it get its paws on). We sell an appliance
product
and have always resisted installing a JVM on it, despite the value it
would
bring, because of the memory issue.
Yeah ... last time I looked the minimum JVM was 32 MB, and I'm not sure
that would support more than one thread.
 
M

Mark Volkmann

Interesting. Someone there said that Python is more like Java
and Ruby is more like Smalltalk. I've never written any
Smalltalk, but I know some Lisp. IMO, Ruby and Python are both
somewhere between Lisp and Java, Python closer to Java, Ruby
closer to Lisp.

I have learned many programming languages in the last two years
and the ones I like most are Ruby, Lisp and Haskell. There is one
thing these three languages have in common: It's easy and natural
to construct domain specific languages in them, allowing you
to write code that expresses more directly the problem at hand.

Consider Rake/Rant syntax:

task :a do
...
end

task :b => :a do
...
end

I haven't done much with Rake yet, but fortunately I knew that => is
used to indicate that one task depends on another. I wonder how many
people who didn't know Rake would guess that.
Or a well known (in the Haskell community) DSL in Haskell
is Parsec; an example from the Haskell wiki:

parseInput = do
dirs <- many dirAndSize
eof
return dirs

data Dir = Dir {dir_size::Integer, dir_name::String} deriving Show

dirAndSize = do
size <- many1 digit
spaces
dir_name <- anyChar `manyTill` newline
return (Dir (read size) dir_name)

And this? I don't know Haskell, but I thought if it's a good language
for creating DSLs then I'd at least have a good guess at what the code
does. Unfortunately I don't have a guess here. I think that's a bad
sign. Call me stupid if you'd like.
Of course, Lisp is *the* language for DSL construction.

I'd like to see a DSL example in LISP.
 
S

Steve Martin

Mat said:
That 'while' was the inspiration I needed. I was also trying to play
on the "Thank Matz day" idea and do something a little useful.

for i in "Matz" do
print "Thank you #{i}, ruby rocks."
end while :happiness

-Mat

I had to add my own, > cat haiku.rb:

since = "Ruby is king"
puts "Perl and Python way down"
raise "Matz up" if 'agreed'

Yea, it throws a runtime error, but I liked the poetry.
 
M

Mat Schaffer

I had to add my own, > cat haiku.rb:

since = "Ruby is king"
puts "Perl and Python way down"
raise "Matz up" if 'agreed'

Yea, it throws a runtime error, but I liked the poetry.

Looks like 6 syllables in the last line to me. You forgot to throw
it through Test::Unit::Haiku :)

Feel free to put it on: http://wiki.rubygarden.org/Ruby/page/show/
RubyHaiku
once you get that last line tweaked.

-Mat
 
B

brad tilley

unknown said:
Besides ROR, can you give me a reason why perfer ruby instead of
python?

This may be a trivial reason to most people, but it makes a huge
difference to me. I find it _much_ easier to turn .rb scripts into
standalone .exe executbales on Windows. I've used Python's py2exe and it
works OK, but Ruby's rubyscript2exe is far better and far easier to use.

I wish Ruby had more Win32 native libraries (like Python), but I can use
win32API and win32ole for most purposes. And, Ruby is catching up with
better library support.

Also, I've written a lot of py code and ruby code, and I can say that I
like them both, but in general ruby is more flexible and thus more
enjoyable for me personally.
 
J

j c theriot

Admin -

having trouble unsubscribing from this list,
where/how do I send unsubscribe message?

Thanks

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 
J

John Gabriele

Admin -

having trouble unsubscribing from this list,
where/how do I send unsubscribe message?

Thanks

If you have a question, send e-mail with the body
"help" (without quotes) to the address (e-mail address removed);
help=<mailto:[email protected]?body=help>
 
D

David Mullet

brad said:
This may be a trivial reason to most people, but it makes a huge
difference to me. I find it _much_ easier to turn .rb scripts into
standalone .exe executbales on Windows. I've used Python's py2exe and it
works OK, but Ruby's rubyscript2exe is far better and far easier to use.

I absolutely agree! Erik Veenstra's done a fantastic job developing,
maintaining, documenting, and supporting Tar2Rubyscript and
Rubyscript2Exe, and that's a major reason why I am developing more apps
in Ruby than in Python (with which I have more experience).

Mully
 
B

bitdoger2

newbie asks: is it true that python does NOT support containers simply
like ruby does?
ie.
a=[]<< an array container
a<<[0,1,2]
a<<{"me"=>"i think","you"=>"you think"}
and then use .each iterater to process this container....
 
G

gregarican

Python indeed doesn't have an #each method to iterate over a container
class and pass the elements into a block as is the case with Ruby. I
think this is because Ruby borrowed from Smalltalk with the do, block,
each, etc. aspects of the language. And Python did not.

There is a next( ) method in Python that will advance to the next
element of a container class. Here's a reference -->
http://docs.python.org/lib/typeiter.html. From there you could _sort
of_ create your own block using Python lambdas to mimic things to a
point...

newbie asks: is it true that python does NOT support containers simply
like ruby does?
ie.
a=[]<< an array container
a<<[0,1,2]
a<<{"me"=>"i think","you"=>"you think"}
and then use .each iterater to process this container....
Besides ROR, can you give me a reason why perfer ruby instead of
python?

seems to many users, they are very similar in nature...

such as

1. non C or Java style syntax
2. focus on codes readability, not like Perl
3. ..
 
M

Marcelo

I don't know what you mean "simply". Here goes the code:

a = []
a += [1, 2, 3]
# if you would append the list instead of three numbers,
# it would be a.append([1, 2, 3])
a.append({"me": "i think", "you": "you think"})

for i in a:
print i

That's all.

Marcelo


newbie asks: is it true that python does NOT support containers simply
like ruby does?
ie.
a=[]<< an array container
a<<[0,1,2]
a<<{"me"=>"i think","you"=>"you think"}
and then use .each iterater to process this container....
Besides ROR, can you give me a reason why perfer ruby instead of
python?

seems to many users, they are very similar in nature...

such as

1. non C or Java style syntax
2. focus on codes readability, not like Perl
3. ..
 
S

Stefan Lang

I haven't done much with Rake yet, but fortunately I knew that =>
is used to indicate that one task depends on another. I wonder how
many people who didn't know Rake would guess that.

You have to learn *any* syntax/API. Important is that it's
easy to remember and that you don't have to write unnecessary
code each time you define a task. In Python this would
probably be done like this:

def fun_a():
...

task("a", fun_a)

def fun_b():
...

task("b", "a", fun_b)

Having to define the separate functions fun_a and fun_b
is an unnecessary burden for the programmer. Having to
invent those function names gets tiresome. And I don't
see how that would be any clearer than the Ruby version.
And this? I don't know Haskell, but I thought if it's a good
language for creating DSLs then I'd at least have a good guess at
what the code does. Unfortunately I don't have a guess here. I
think that's a bad sign. Call me stupid if you'd like.

Perhaps it wasn't so a good idea to drop these examples
in without any explanation :(

The parseInput function parses lines like this:

65572 /home/adept/photos/raw-to-burn/dir1

This example is from
http://haskell.org/haskellwiki/Hitchhikers_Guide_to_the_Haskell

The important point here is again that if you know basic
Haskell, Parsec provides an easy way to define parsers.
There is no bookkeeping for the Haskell compiler.
Parsec was used for Pugs, the first Perl 6 compiler. So
it seems to work for harder tasks too.
I'd like to see a DSL example in LISP.

Taken from "Practical Common Lisp",
http://www.gigamonkeys.com/book/practical-building-a-unit-test-framework.html

Usage of a small unit test framework:

;; Define a test case for the "+" function
(deftest test-+ ()
(check
(= (+ 1 2) 3)
(= (+ 1 2 3) 6)
(= (+ -1 -3) -4)))

;; Another test case for "*"
(deftest test-* ()
(check
(= (* 2 2) 4)
(= (* 3 5) 15)))

;; Test suite for arithmetic functions
(deftest test-arithmetic ()
(combine-results
(test-+)
(test-*)))

;; run the test suite
(test-arithmetic)
pass ... (TEST-ARITHMETIC TEST-+): (= (+ 1 2) 3)
pass ... (TEST-ARITHMETIC TEST-+): (= (+ 1 2 3) 6)
pass ... (TEST-ARITHMETIC TEST-+): (= (+ -1 -3) -4)
pass ... (TEST-ARITHMETIC TEST-*): (= (* 2 2) 4)
pass ... (TEST-ARITHMETIC TEST-*): (= (* 3 5) 15)
T

That "T" in the last lines means that all tests have passsed.
"deftest", "check" and "combine-results" are user defined macros.
The whole "framework" is defined in 26 lines of code.
For my needs, I would tweak it so that the test code is printed
only for tests that failed.

Currently I have to write a Java webapp at work. Writing Java and
loads of XML when you know Lisp and Ruby really hurts.
If Java would provide something like Lisp's macros or some of
Ruby's features (anonymous closures, defining own attr_* methods,
higher order functions, etc.), I'm sure we could reduce the code
size of the project to a quarter or less of the current size.
The same goes for the XML code. Those XML DSLs have a serious
problem. When a certain pattern occurs often in the project and
the framework hasn't a builtin way to factor it out, you're out
of luck. Type it out each time.

In an Rantfile/Rakefile I have the full power of Ruby at hand.
I simply Won't Repeat Myself.
 
G

gregarican

QOTD +1!!!!
Also, try running Python and typing quit. Then try exit.

Then run irb, and try quit, exit and Ctrl D.

That's my favorite example of the difference between the Ruby Way and
the Python Way.


mathew
 
V

vasudevram

I guess Disney qualifies as a reasonably-large company.

I saw on the Python Success Stories site (or somewhere else, its a
while back), that Disney uses Python heavily. There are also a good
many other success stories of companies using Python, don't know how
many of those are big. Univ. of St. Andrews, Scotland, and Astra-Zeneca
(a pharma company) are two others I remember being in that list. The
site was down just now when I checked, not sure if its down permanently
or temporarily - http://www.pythonology.org/success. Try the Google
cache.

Is there any such site for Ruby (a Ruby Success Stories site)? If not,
might be a good idea to start one. I'd be happy to try to find stories
to contribute, since I do a good amount of this sort of searching as
part of my work.

Anyway, it would be a good thing in general, IMO, for the Ruby
community, to have a Ruby Success Stories site. I think Ruby is a great
language and, while I'm sure there are a lot of people promoting it,
this additional way could help (if its not there already - I don't know
as of now). Increasing the visibility and credibility of Ruby to the
corporate world may be a good thing - it would encourage them to use it
more, implying potentially more jobs for Rubyists, whether as employees
or contractors/consultants.

Update: I tried the Google cache for "Python Success Stories".
According to it, these (large) companies use Python:

AstraZeneca
Philips
Honeywell
Industrial Light and Magic (company that created visual effects for
Star Wars)
The New York Stock Exchange
The Space Shuttle (I know, not a company, but big:)
US Navy
US Dept. of Agriculture
Boston.com


Vasudev
-------------------------------------------------------------------
Vasudev Ram
Software consulting and training
Biz site: http://www.dancingbison.com
PDF conversion toolkit:
http://sourceforge.net/projects/xtopdf
-------------------------------------------------------------------
 
D

dblack

Hi --

Anyway, it would be a good thing in general, IMO, for the Ruby
community, to have a Ruby Success Stories site. I think Ruby is a great
language and, while I'm sure there are a lot of people promoting it,
this additional way could help (if its not there already - I don't know
as of now). Increasing the visibility and credibility of Ruby to the
corporate world may be a good thing - it would encourage them to use it
more, implying potentially more jobs for Rubyists, whether as employees
or contractors/consultants.

Google for "Ruby success stories" and you'll quickly find:

http://wiki.rubygarden.org/Ruby/page/show/RealWorldRuby


David

--
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
http://www.manning.com/black => RUBY FOR RAILS (reviewed on
Slashdot, 7/12/2006!)
http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log
(e-mail address removed) => me
 
V

vasudevram

Hi,

Thanks! That's a fair-sized and interesting list.

Vasudev

Hi --

Anyway, it would be a good thing in general, IMO, for the Ruby
community, to have a Ruby Success Stories site. I think Ruby is a great
language and, while I'm sure there are a lot of people promoting it,
this additional way could help (if its not there already - I don't know
as of now). Increasing the visibility and credibility of Ruby to the
corporate world may be a good thing - it would encourage them to use it
more, implying potentially more jobs for Rubyists, whether as employees
or contractors/consultants.

Google for "Ruby success stories" and you'll quickly find:

http://wiki.rubygarden.org/Ruby/page/show/RealWorldRuby


David

--
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
http://www.manning.com/black => RUBY FOR RAILS (reviewed on
Slashdot, 7/12/2006!)
http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log
(e-mail address removed) => me
 
J

Josselin

Hi,

Thanks! That's a fair-sized and interesting list.

Vasudev

Hi --

Anyway, it would be a good thing in general, IMO, for the Ruby
community, to have a Ruby Success Stories site. I think Ruby is a great
language and, while I'm sure there are a lot of people promoting it,
this additional way could help (if its not there already - I don't know
as of now). Increasing the visibility and credibility of Ruby to the
corporate world may be a good thing - it would encourage them to use it
more, implying potentially more jobs for Rubyists, whether as employees
or contractors/consultants.

Google for "Ruby success stories" and you'll quickly find:

http://wiki.rubygarden.org/Ruby/page/show/RealWorldRuby


David

--
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
http://www.manning.com/black => RUBY FOR RAILS (reviewed on
Slashdot, 7/12/2006!)
http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log
(e-mail address removed) => me

btw 'Ajax is seen'... [quoted] Ajax cannot be compared to Python,
Ruby or Java...
it's not a language....
 
V

vasudevram

Josselin said:

btw 'Ajax is seen'... [quoted] Ajax cannot be compared to Python,
Ruby or Java...
it's not a language....


Just FYI - that bit (about Ajax) was not stated by me but by the person
to whom I was replying (Gianfranco, I think). I'm aware that Ajax is
not a language ... :)

The mistake is probably due to all the quoted/earlier messages - makes
for messy and difficult reading ...

- Vasudev
http://www.dancingbison.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top