Hello folks, You all know i been forced to use Ruby and i am not happy about that. But i thought i would share more compelling evidence of the moronicity of the Ruby language syntax from the perspective of regexp's.
I recently built myself a nice little Ruby script editor because i hate everything else out there. Whist writing the Colorizer i realized (again) just how beautifully elegant Python is and how crufty and asinine Ruby is. Anyhow my point is that by looking at the regexp's you can clearly see that parsing Ruby syntax is BF and Python syntax is elegant! Here are a few examples: Note i used look back assertions for clarity. -------------------- Modules -------------------- Python does not have a module syntax (an thank Guido for that!) because we have a much better system of using the file as a module and not introducing more cruft into our scripts. Anyway if Python *did* have a module syntax it would look better than this crap! Python: N/A Ruby: r'(?<=module )(::)?(\w+(::)?)*' -------------------- Classes -------------------- Python and Ruby class definitions are almost the same except for the module cruft getting in the way again. Python: r'(?<=class )\w+' Ruby: r'(?<=class )(::)?(\w+(::)?)*' --------------------- Defs --------------------- HaHa, you're going to poop yourself when you see this! No introduction needed :-D. Python: r'(?<=def )\w+' Ruby: r'(?<=def )(self\.)?((\w+::\w+)|(\w+\.\w+)|(\w+))([?|!])?' --------------------- Strings --------------------- Single line strings are exactly the same in both languages except in Ruby double quoted strings are backslash interpreted and single quote strings are basically raw. Except Ruby introduces more cruft (as usual) in the form of what i call "lazy man" stings.... >>> a = %w{ one two three} ["one", "two", "three"] >>> s = %{one two three} one two three >>> repat = %r{one two three} /one two three/ ... only good for hand coding! ---------------------- Multi Line Strings ---------------------- Ha. Ruby does not really have multi line strings. Ruby has what they call a "Here Doc". Besides picking the most boneheaded name for such an object they also introduced and even more boneheaded syntax. To define a "Here Doc" (god i hate that name!) you start with double greater than ">>" and immediately follow with an identifier token of you choice (it can be anything your dirty little mind can come up with. >>HEREDOC this is the body of a here doc. Why the hell did they not just use triple quotes like Python did. Now i will need to remember some token to know where' i stopped HEREDOC As you can see it is another example of tacked on functionality that was not carefully considered before hand. Anyway here are the regexp's... Python: r'""".*?"""' Python: r"'''.*?'''" Ruby: r'<<(\w+).*?(\1)' -------------------------- Comments -------------------------- Ruby and Python single line comments are the same. Use the hash char. However Ruby introduces multi line comment blocks delimited by the tokens "=begin" and "=end". Python: r"#.*" Ruby: r"=begin.*?=end" Ruby: r"#.*" ------------------------- Conculsion ------------------------- I just want to take this opportunity to thank Mr. Van Rossum and the Python dev team for creating a truly revolutionary 21st century language that no other language can hold a candle to. Without Python we would be force to use these "other" monstrosities" on a daily basis -- and i just don't think i could bear it! Keep up the good work! -- http://mail.python.org/mailman/listinfo/python-list