From: Mark Volkmann Date: 2006-07-12T06:50:32+09:00 Subject: Re: Why Ruby over Python? On 7/11/06, Stefan Lang wrote: > On Tuesday 11 July 2006 17:00, jmdeschamps@gmail.com wrote: > > Doug H wrote: > > > howachen@gmail.com wrote: > > > > 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. .. > > > > > > Go ask this same question over on comp.lang.python and you'll see > > > why you might prefer ruby. > > > > Funny you ask: > > http://groups.google.ca/group/comp.lang.python/tree/browse_frm/thre > >ad/40d8d11e12cb00ba/12306d4d9b0ce50c?rnum=11&q=ruby+or+python&_done= > >%2Fgroup%2Fcomp.lang.python%2Fbrowse_frm%2Fthread%2F40d8d11e12cb00ba > >%2F7256adbbc7f79afe%3Fq%3Druby+or+python%26rnum%3D1%26#doc_74bfb0743 > >eff1367 > > 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. > Python, and more so Java do not allow you to construct a DSL. > Thus in Python and Java, on the syntax level you are always > limited to the few constructs the language provides: Defining > classes and methods, constructing objects, calling methods, > arithmetic expressions, branches via if/else, switch/case. > This gets more limiting the bigger a project grows. Java people > compensate this via huge frameworks that interpret XML files. > > Ruby's design is also more coherent than Python's. One example > where Python really f****d up are properties. Python's properties > are an ugly mess, just IMO. > > If you already know Java/C#/C++, you'll gain much more in > learning Ruby than Python. > > -- > Stefan -- R. Mark Volkmann Object Computing, Inc.