Earlier quoted context omitted.
Disagree on "REST syntax". Python could do just as well: Sinatra: get '/hi' do "Hello World!" end Python 2: @get('/hi') def hello(): return "Hello World" Python 3: def hello() -> "/hi": return "Hello World"
Decorators and annotations are very useful in Python, but I still like the terseness of Ruby--no need to define "hello()". Of course, Python wins on a different kind of terseness--no do/end--but that is mostly orthogonal.
What Pythonistas Think of Ruby
151–160 of 247 posts
Re: What Pythonistas Think of Ruby
#152Earlier quoted context omitted.
Python is a dogmatic language. For the language, this is a good thing, helping it stay clean, simple and yet still powerful. But for the community, it breeds rabid fanboys, just like everything else that's dogmatic.
I don't know. Haskell is quite dogmatic in some ways. The people on the Haskell cafe mailing list don't strike me as rabid fanboys.
In less than 10 minutes after posting anything remotely negative about Haskell, I have a horde of angry fanboys telling me how I am an idiot.
Re: What Pythonistas Think of Ruby
#153Earlier quoted context omitted.
You are correct. There is no reason not to just use an inline function that happens to have a name. I think the "lambdas can only be one line" is a newbie python mistake.
Personally, I dislike naming things that I won't use again. It feels like a waste. And then, since I have to name things, I have to come up with a _good_ name. Just a matter of taste, mind you, but it's my reasoning for preferring anonymous functions.
Re: What Pythonistas Think of Ruby
#154Earlier quoted context omitted.
Do you really have to switch from one to another? I learned both languages, love them both, and use them both. There's too much hate in the world of programming languages.
I reuse code a lot. If I write code in Ruby, I can't reuse it in a Python project. Since Python and Ruby occupy the same niche, I will often want to reuse code. (This is less of an issue if I want to use Python and C++. I'll rarely want to reuse linear programming code or a PDE solver in Python, and if I did, I would just wrap the C++. Similarly, I never want to use code I've written for the web in C++.)
Re: What Pythonistas Think of Ruby
#155Earlier quoted context omitted.
You don't have to choose a single option, even for a particular project. I've worked on websites/apps that have integrated 2 or 3 different server-side languages and frameworks. If you have a programmer that says "eww I'm not touching the WordPress part because it's in PHP" they just aren't the kind of programmer I want working on the project. Also, if you have a programmer that goes out an freaking re-implements Wor…
There is a drawback to this, obviously. If your codebase is some scattered mish mash of Python, PHP, Actionscript, Javascript, Java, etc, your ability to reuse code diminishes at the language boundaries. You end up having to write very similar code to deal with the same objects on the client side and the server side in multiple languages, producing more code to maintain overall. Unfortunately because of the nature of…
Instead of thinking of code re-use, we're left with a UNIX style resource re-use. Every component can stand alone, but they all work in conjunction with each other and can be re-arranged to work in different ways.
Re: What Pythonistas Think of Ruby
#156Earlier quoted context omitted.
> As a Pythonista I have no idea what the Ruby snippet is doing. Fair enough. Arguing over beauty is silly anyway, I just wanted to point out that the entire thing is entirely subjective. > The Python 3 version is using a function annotation. Thanks, checking out PEP 3107 now. I've always seen annotations done with the @annotation syntax like the Python 2 snippet has.
> Thanks, checking out PEP 3107 now. I've always seen annotations done with the @annotation syntax like the Python 2 snippet has. The @ syntax is for decorators. Different beast altogether.
I've used decorators to add attributes to function objects in several projects in the past -- you don't have to wrap the original.
Re: What Pythonistas Think of Ruby
#157Earlier quoted context omitted.
I don't think the fights should be vicious, but I think the stakes are fairly high, and even though Ruby and Python are close cousins in the grand scheme of things, they really do represent profoundly different philosophies when you look more closely at the languages. It would be nice if these differences could always be discussed with civility, of course. I use both Ruby and Python enough to appreciate that both lan…
That's just another reason for vicious fights besides small stakes, small differences. Just ask the protestants and the catholics.
However, we can sometimes mistake _subtle_ differences for _small_ ones; but just as there's a substantial difference between the Mac OS and Windows, there's a substantial difference between Catholicism and Calvinism (which was the most successful form of Protestantism) -- the difference between God seeing that you went to Hell, and God sending you there. I could go into much greater detail (I count nine paragraphs in how I'd previously structured this comment), but that's the nutshell of the nutshell.
Re: What Pythonistas Think of Ruby
#158Earlier quoted context omitted.
" ... just a troll post on Python by a Rube (that's what they're called, right?)" Speaking of which ...
It was just a joke, no offense intended. Apologies to any Rubyist who was offended.
Re: What Pythonistas Think of Ruby
#159I am one of those people who accepted the lisp religion of "syntax is evil". I have a descent knowledge of python, and I've read a few ruby tutorials. Neither python nor ruby are lisp. Python is not cool because of generators, list comprehensions, decorators or any other feature. Ruby is not cool because of blocks or monkey patching(im suspicions of anything called MONKEY patching). Ruby and python are cool because o…
Python generators (the ones you can get with "yield") are not just syntax. They can be viewed as a distant relative of continuations or lazy evaluation. Lisp (or lets say Scheme, because Common Lisp is ugly and imperative) does have some nice points. I rather like the syntax. But e.g. strict evaluation by default and lots of side-effects hamper the expressiveness and flexibility of the language.
Re: What Pythonistas Think of Ruby
#160Earlier quoted context omitted.
Yep. `yield` in Ruby is a normal anonymous method call. It pushes a new frame onto the stack. `yield` in Python works more like Ruby's [Generator]( http://ruby-doc.org/stdlib/libdoc/generator/rdoc/classes/Gen... ). It freezes the current stack frame's state and resumes execution somewhere else, returning again to the same place on the next iteration. They're very different things really. More about Python's generator…
So what would yield in Ruby be like in Python? Surely there must be some analogue?
def foo(thing, block):
thing = "cruel " + thing
block(thing) # like `yield thing' or 'block.call' in ruby
def bar(thing):
return "hello " + thing
foo('world', bar)
# or:
foo('world', lambda x: "hello " + x)
Ruby's blocks are really just sugar for passing an anonymous function in the last argument and yield is just sugar for calling that function. The example above in Ruby would be: def foo(thing)
yield thing
end
foo('world') { |thing| "hello " + thing }