Where do you stand in the Python v. Ruby war?

Where do you stand in the Python v. Ruby war?

Other urls found in this thread:

en.wikipedia.org/wiki/Narcissism_of_small_differences
twitter.com/SFWRedditGifs

as far away as possible

Python.

With " don't care, fucking nerds" crowd.

It's not a war. I am a Rubyist of 10 years, have worked some in Python, and even though I prefer not to use Python (I could even say I don't like it), I don't think there is anything wrong with Python. I can confidently say that any perception of "war" comes from the most small-minded members of both of the language's communities. It is a prime example of the "narcissism of small differences", where two similar communities have to emphasize their differences as loudly as possible in order to assert their identity and importance [0].

Python and Ruby are incredibly similar in the grand scheme of things. They are closer to one another than either one is to: JavaScript, C, Lisp, Haskell, Erlang, Fortran, Java, PHP and so on.

In terms of practical professional use, Ruby's community and ecosystem has better support for what you could broadly call "web development", and Python has an better lean toward numerical computation and scientific libraries. Both have a lot of jobs, and both languages are not Number One Top Dog Best Of The Best in either of those realms. Instead, they are both approachable languages that augment programmer productivity by distancing you from the underlying model of computation in very similar ways. Again, more similar to each other than any other language.

[0] en.wikipedia.org/wiki/Narcissism_of_small_differences

Python
Ruby syntax is unreadable for me

Sorry virgins, I've better things to do.

You should see their grammars in their yacc file.

as far as scripting goes
R is superior to python and ruby

hey knowledgeable user, what are the most notable implementation differences between Ruby and Python? Hashes vs Dicts, Arrays vs. Lists, are they more or less the same?

Have you noticed that Ruby has more support for functional programming techniques or are they almost indistinguishable?

Thank you

> Nu-Male language wars

Sorry, got productive stuff to do.

foreach my $illness (sort keys %medication)
foreach my $pill (keys %{$medication{$illness}}){
foreach my $dosage (keys %{$medication{$illness{$pill}}}){
print "Your recommended dosage for $illness is $dosage of $medication";
}
}
}

>Hashes vs Dicts, Arrays vs. Lists, are they more or less the same?
Ruby Hashes and Python Dicts are basically equivalent. I haven't looked at the Python VM's implementation of Dicts in as much detail as I have with Ruby Hashes, but from what I know they take similar shortcuts wherever possible. The technical computer science concept they represent is a "heterogeneous dictionary".

Arrays vs Lists is similar. Both are as-you-expect blocks of contiguous memory, but growing beyond whatever under-the-hood allocation has been made will force a re-allocation. Python also has the array module as well as NumPy arrays, and Ruby can (when needed) interop quite cleanly with C code. But for 99% of programs you will write, the default implementations for both operate similarly and are "good enough".

def atLeastYouTried()

end


Here's your (You)

>Have you noticed that Ruby has more support for functional programming techniques or are they almost indistinguishable?
My understanding is that the use of more traditionally-functional methods such as map and reduce are viewed as "less Pythonic" than using comprehensions. But you certainly can use either and no one will stop you. Ruby's Enumerable module is pretty badass and offers all sorts useful built-ins when compared to Python's offering, but Ruby has no equivalent to comprehensions. So if the way you think about a problem like data transforms gels better with comprehensions, Python might make you happier. If you prefer more traditional, lispy method names and semantics, Ruby will feel better. Both will get the job done.

The use of Lambdas in Ruby is both more common and easier, but is somewhat confounded by the yet-more-prevalent feature of "Procs" and "Blocks" which are just a lambda with slightly different scoping rules and which "feel right" in some circumstances, but wrong in others. If I had any major gripe with Ruby, it would be the lack of clarity (especially to newcomers!) between what Procs and Lambdas are, and why Blocks exist. The gist is this:
- Lambdas are standard functional closures the way you'd expect.
- Procs are Lambdas where certain language keywords behave differently.
- Blocks are a syntax shortcut for passing a Proc to a method as an argument.

Python also has "functools.partial", which makes the lambda support feel more Pythonic, arguably closer to Ruby, but still doesn't feel quite like it belongs in the language as much as Ruby's functional-isms do.

Again, both have first-class functions (the idea of representing a process as data), and both get the job done. Unless you're in a domain that has better library support for one or the other language, it's more about personal preference.

PHP

I'll close by addressing
>what are the most notable implementation differences between Ruby and Python?
Both are realizing that they are disadvantaged as languages in the continuing march toward parallel/multicore computing, and are tackling it in slightly different ways. It remains to be seen if either or both of these will work out, but these efforts are also quite far from the minds of most people doing work in either language. Both languages still have a GIL (JRuby being an exception) and both have ways around it.

The Python community has finally, by in large, moved on to the 3.X versions of the language, whereas Ruby's big change came in the same year with its 1.9 release but the community embraced it a bit quicker. Inversely, the Python community started facing up to its concurrency challenges sooner (async/await came in 3.5 iirc), and Ruby is only just now putting honest effort into it (via the "guilds" proposal for Ruby 3.0).

First post, best post.

great posts, tyvm user

Python3 is much better than Python2. But Ruby feels more well rounded for me. I can't think of a reason to use Python unless I need a special library (numpy, scipy..) where python excells.


1.) Ruby is more "powerfull"

Ruby is a mixture of Python, JavaScript, Perl, Smalltalk and LISP, but you have only the good parts. It can do EVERYTHING python can do, but not the other way arround. Yes, Ruby can even emulate list comprehensions (but it's not the "ruby way of doing it"):

for i in (2..4) do for j in (i..i**2)
puts "#{i} is #{j}" if i == j
end end


On the other hand you have an better meta programming modell. I can explain you Ruby's methods in half an hour and you can use it. But you will make a lot of mistakes with pythons decorators until you got them.


2.) Ruby is better enigneered.

People always talking about Python being "beginner friendly", but that's not my perception. Go ahead, try to make a simple I/O in Python.. "What, you don't know how byte-encoding works or what UTF-8 is? Too bad, I wont' print that shit.."

Ruby is just smarter in the details, most of the time it just gets what you wants and does all the magic in the background.

Also you have a couple of other goodies, for example "dead code elimination". Not that it matters that much, but it's nice. The interaction with C is even smoother than in Python (even though python is OK here).

Furthermore Ruby's object model is just top notch. Simple and powerfull. Everything is an object, if you want something from an object, ask it to do it:

"two words".split.join.length


"string, split your components" --> returns array
"array, join your components" --> returns string
"string, what's your length?" --> returns number

In Python you often put the arguments into functions - but not always. It's inconsistent and difficult to remember.


3.) Python has more "quirks"

- py2 vs. py3
- "self()" everywhere
- [1,2].sort() returns "nothing"
- (...)

I forgot:

Pythons "tuples" are complicated and add no value, Ruby's approach to use lists/arrays and make them immutable is better.

The fuck is complicated about tuples?

You create one more unnecessary data structure, since it's only an immutable array.

Also picking parentheses as symbol was a really bad choice, there fore you have silly code like this:

>>> empty = ()
>>> singleton = 'hello', # >> len(empty)
0
>>> len(singleton)
1
>>> singleton
('hello',)


Note that "singleton = ('hello') does NOT create a tuple.

It's using the normal mathematical notation for tuples - it couldn't be any easier.
And having a clear separation between mutable and immutable lists is a good thing.

It's not "mathematical notation" to use:
a = 1,

Also a clear seperation is good, but not like this. You might as well add special symbols for sets.. In the end you add overly complicated structures.

then use a = (1,)

single-value tuples are a rare special case
they'd also be ambiguous in normal math

This notation looks better.

I guess it's a matter of personal preferences wether immutable lists need their own struct.

/thread

>A rubyist of 10 years
the average mental age for ruby users, no big deal

...

neither

>GIL
neither

>Python and Ruby are incredibly similar in the grand scheme of things. They are closer to one another than either one is to: JavaScript, C, Lisp, Haskell, Erlang, Fortran, Java, PHP and so on.
I don't know, man. Python seems a lot like a dynamically typed Java to me with the gimped FP features and all.

/thread

>[1,2].sort() returns "nothing"
sorted([1, 2])

Ruby is more convenient to write.
Python is easier to read.

Neither should be used for web development. Python works great for system administration tasks and the major automation platforms are either written in Ruby or support Ruby.
If you want to do web development, use:
PHP
JS
(coming soon) WebAssembly

>JS
For back-end work, please do not use JavaScript. Use something meant for actual concurrency such as Elixir or Go.

There is no war. I've used both, a number of other developers I've known use both. I prefer Ruby, but Python certainly has its merits when you need certain libraries.

>Ruby is a mixture of Python, JavaScript, Perl, Smalltalk and LISP
Where did you get JavaScript from, and why did you put Ruby's most important influencers (Smalltalk, Perl, LISP) at the end?

Please do not recommend PHP to be used for any task.