Python/Ruby vs. Ruby/Python
-
This is off topic. I'm posting this so that those who want to join the debate will have a place to do so. Hopefully, we'll not have the topic raised elsewhere.
I have a pet Python named Monty. Monty promises to give Tim Toady a big hug if he ever meets him. (No, you do not want a big hug from Monty.) You can figure out where I stand.
On the other hand, I know some experienced, productive code weavers who love Tim Toady. Fine. (But don't bring it up around Monty.)
Python's suites (four-space indented code blocks) are great. They enforce good code writing. Ruby's if/unless pairing, and especially suffixing, are great. Python's lambda functions and Ruby's blocks are no match for the elegant simplicity of JavaScript's functional programming.
Python lacks the implicit "this" of C++ and Java. It's a pain. Not being able to wrap your code in a module without changing all your
def func()
todef self.func()
is a Ruby pain. And what was Matz thinking when he decided that the programmer, not the language, had to write explicit type coercions?("foo"+23) == "foo23"
in most of the languages I know.And I find the processing of code in the order it appears in the file is utterly lame. Even JavaScript has sense enough to eat all the declarative code before it starts running imperative code. Matz? Guido? This is 2010!
-
@martinrinehart said:
This is off topic. I'm posting this so that those who want to join the debate will have a place to do so. Hopefully, we'll not have the topic raised elsewhere.
Well Martin you had to know i could not resist a thread with Python in the title, no more than a dog can resist chasing his tail, it's just too damn interesting.
@martinrinehart said:
I have a pet Python named Monty. Monty promises to give Tim Toady a big hug if he ever meets him. (No, you do not want a big hug from Monty.) You can figure out where I stand.
Another example of Martin's comedic genius, pure gold!
@martinrinehart said:
Python's suites (four-space indented code blocks) are great. They enforce good code writing. Ruby's if/unless pairing, and especially suffixing, are great.
i love Ruby's one line statements "if condition then statement else statement end". Reminds me of Python list comprehensions. We have something similar now in 3.0
@martinrinehart said:
Python lacks the implicit "this" of C++ and Java.
i'm still out on this one. On one hand (like Guido argues) you see the path of self, but i could live without it.
@martinrinehart said:
And I find the processing of code in the order it appears in the file is utterly lame. Even JavaScript has sense enough to eat all the declarative code before it starts running imperative code. Matz? Guido? This is 2010!
I don't see how that matters but i won't disagree on such a small thing. So Martin, can i surmise your rant as...
@unknownuser said:
"The best language today would incorporate everything that is good in Python, Ruby, and Javascript into one beautiful 21st centry language".
If so i agree, when do we start building this thing? And what the heck are we going to call it? hmm, scratches head, how bout "Full Monty"?
-
@jessejames said:
@martinrinehart said:
when do we start building this thing?
http://www.MartinRinehart.com/posters/decaf.html
Got a lexer running, tho it's blocks are delimited, not indented. Begun a parser. I only pick on this a bit at a time. (In Python, of course.)
The declaratives (func defs, classes, etc.) should be processed first so the user can decide that the mainline would best come first or last or where it makes sense. Language design shouldn't dictate source code structure. When I wrote Java, for example, I had one special place for
main()
. It was important that it always resided in its special place as it was typically test code, commented out when the class was finished. Once commented out, the IDE couldn't see it. -
@martinrinehart said:
Got a lexer running, tho it's blocks are delimited, not indented. Begun a parser. I only pick on this a bit at a time. (In Python, of course.)
Can you show me some code, i like to look over specs only after i see the code in action, specifically the simplistic syntactic elegance of the language in particular. Python is a hard act to follow in this category.
My idea of the perfect language is Pythons core seasoned lightly with some Ruby, and maybe a very small pinch of Java. . But i am open to new ideas also.
@martinrinehart said:
Language design shouldn't dictate source code structure. When I wrote Java, for example, I had one special place for
main()
. It was important that it always resided in its special place as it was typically test code, commented out when the class was finished. Once commented out, the IDE couldn't see it.You do know about using Python's...
If __name__ == '__main__'; # block here
...construct to insert tests where ever you like? It's typically used at the end of a script for running tests. It will only run the test when the module is ran directly, not when it is imported, so no need to comment out!
@martinrinehart said:
When I wrote Java, for example, I had one special place for
main()
.Where is that exactly?
-
Don't think I want to dust off Decaf until I've got time to go after it. I forget where I put my mains in Java. There's tons of my Java on my site: http://www.MartinRinehart.com , including the original Decaf tokenizer.
There's a whole new vocabulary (words, not tokens; phrases, not expressions; sentences, not statements; etc.) that I'll need to document before anyone could realize that I wasn't just babbling.
See "The Project", my site, for more.
Advertisement