Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I am preparing a presentation about Python for my company, and would like to show Python's awesomeness to developers using Java or Ruby ! I guess it will be very simple to write shorter and cleaner looking stuff than in Java, however I've never coded in Ruby (well only a few stuff with rails, but I don't know the language) !

PLEASE NOTE : This topic IS NOT about which language is the best. I just want to convince people that don't know Python at all, or even -for some- think that it is weird, that it is worthy of interest as well (as much as Ruby, Java, etc... are). And for this, I need input from people that know Ruby (or Java) and Python ...

I'm looking for an easy to understand code snippet or application that would shows where Python shines.

I was thinking of a couple of list comprehensions, because I think it is really great. Some operator overriding, because that looks dead simple in Python, maybe some metaclass programming, and/or why not a doctest/sphinx example ...

Any other/better suggestions ?

PS : the people are backend web developers

share|improve this question
the question could just as well be, "How do I covert someone to my religion who is part of a fanatical cult religion." –  Jarrod Roberson Apr 25 '11 at 16:43
I don't know that you will wow Ruby programmers much (equally succinct language with some more standard stuff too like visibility scope) but whipping out LOC comparisons that are reasonably readable for standard programming things might be useful. Things like Sieve of Erathenese, Towers of Hanoi, and etc stuff we did in school. List comprehensions are definitely a good place to start though. They woo'd me some. PS: Highlight instant feedback like REPL and fact you don't spend 10 minutes compiling smallish projects. –  Rig Oct 19 '12 at 13:19
I kind of agree with Rig on Ruby developers here. Coming from Ruby to Python was actually kind of underwhelming. Though the enforced whitespace grew on me (more specifically, the lack of explicit end statements eliminated a lot of otherwise useless lines - maybe focus on that?). A lot of the functional things I like in Ruby don't go so well in Python. Oh, except function pointers. Python makes it really easy to point a variable to a function (somevar = function_name # No () At the end) –  KChaloux Oct 19 '12 at 13:35
IMO, if you're worried about impressing people you're doing it wrong. –  Joel Etherton Oct 19 '12 at 15:59
Just getting a complex web app to run on all flavors of not-Apple in less than 5-minutes per-platform should impress a Rails dev but probably won't or it wouldn't be such a PITA to run Rails apps on not-Apple in the first place. To impress Java devs you could show them something that makes it possible to make Python work a lot more like Java so they don't have to absorb too much "new crap." Don't bother with the up and running in 5 minutes thing though. They haven't cared for that for a loooonnnnggg time. –  Erik Reppen Jun 14 '13 at 4:31

8 Answers 8

The concept of generators is something which is quite awesome in Python which I miss in the other languages (or at least I have a couple of drawbacks on their substitutes).

You may take any example from these great presentations [1, 2] and it'll even impress Python people.

share|improve this answer
+1 for generators! –  Alexander Battisti Apr 25 '11 at 13:56
Wow ... this coroutine stuff is amazing !!! I didn't know at all it existed !!! –  sebpiq Apr 25 '11 at 14:14
+1 for Dave Beazley's generator's example, just for the task-oriented way it approaches the topic. –  ncoghlan Apr 25 '11 at 16:31

A good swaggering should at least include:

  • Duck Typing
  • Pythonic for loops ('for each in seq:' instead of 'for i in range(0, len(seq)):')
  • List Comprehensions / Generator Expressions
  • Generator Functions
  • itertools
  • Functions as First Class Objects
  • Higher Order Functions (decorators, functools)
  • Metaclasses
  • Batteres Included (std lib)
  • import this
  • numpy / scipy
share|improve this answer
errr. Python's duck typing is not impressive for Ruby people. Neither does the for-each loops as Java and Ruby supports it. Ruby metaclass is more powerful IMHO. –  Joshua Partogi Apr 25 '11 at 15:22
At a language level, Ruby/Python are pretty similar. Python's strength in that contest is 3rd party library support for tasks that aren't specifically web-related, but how significant that is will depend on the environment. –  ncoghlan Apr 25 '11 at 16:36

As an ex-Ruby (and Java) programmer I found Python's SciPy and NumPy libraries very impressive.

I second the idea of showing list comprehensions, but I fear the Ruby crowd might not be impressed by Python metaclass programming.

share|improve this answer
Ruby is essentially meta programming anyways. The Java people will look at it and silently scream in horror (like I did). –  Josh K Apr 25 '11 at 13:58
Thanks that's very good to know ! –  sebpiq Apr 25 '11 at 14:06

Build something (anything) from scratch at the python prompt.

It creates a compelling "story arc" from requirements to a completed script. It's helpful if it does something useful.

Avoid anything that looks like building a web site because the Ruby folks will compare your web demo head to head and feature to feature with Rails. And they'll always find one small thing that Rails does better than Django and that nuanced item with derail your presentation.

Pick something like log filtering. Or transforming a CSV file. Or using urllib2 to get something from the web and parse it.

Start with the Python >>> prompt and step through it, building up a script as you go.

Run the script as your closing flourish.

share|improve this answer
Sounds good ... I'll try to find a good scenario, making good use of standard lib + cool exotic Python syntax (like generators) –  sebpiq Apr 25 '11 at 14:57
@sebpiq: Don't build too much into it. The value of Python is really about solving hard problems cheaply and quickly. –  S.Lott Apr 25 '11 at 14:58
@S.Lott: "solving hard problems cheaply and quickly" Yep ! That's why I believe it is important to show that there is a great std-lib that gives you many things at your finger-tips. But maybe you are right in the sense that I should keep it simple, with mostly basic syntax. –  sebpiq Apr 25 '11 at 15:09
@sebpiq: A few fancy things to show how your simple solution gets even simpler with a nice list comprehension can be helpful. It shows how you not only solved it well, but you can improve on that with small, easy-to-understand changes. –  S.Lott Apr 25 '11 at 15:14
@S.Lott : Just finding the balance :) –  sebpiq Apr 25 '11 at 15:21

One concrete feature to consider demonstrating is the ability to abstract out repetitive exception handling using the with statement and @contextlib.contextmanager.

Ruby can provide similar convenience through appropriate use of blocks, but Java doesn't have anything at all along these lines (short of adopting full-blown aspect-oriented programming)

share|improve this answer
Java 7 will have a weird-looking try block for this. –  R. Martinho Fernandes Apr 25 '11 at 17:03
Ah, interesting to know! Still, for now it is something Python can offer than Java doesn't yet have. –  ncoghlan Apr 26 '11 at 3:21

a few weeks ago some friends of me started a small project. We had to choose between java and python. I used two key benefits to convince them of python:

  • Lists. Python is famous for its incredible support for lists. In my opinion the fact that python is referred to as "working pseudocode" is because its list are so great. Show them the ease of creating a list, the treat of iterating with for and, lo and behold: LIST COMPREHENSIONS, they will love them

  • Functions as "first class passengers". Especially java programmers will be yellow with envy at the prospect of parsing functions as parameters and lambda expressions. The sorted() function for lists is simply fantastic. In java you would have to create a function with an interface as a parameter and a custom class that implements the interface for any sorting algorithm.

Im afraid that your ruby colleages will probably remeain unmoved by this. After all python and ruby resemble each other in many aspects. Personally i would prefer python but thats a religious decision. Python or ruby is just a matter of taste. If you have to choose between them i would recommend a democratic vote. Youll be productive with both choices and this way you can avoid bad blood.

share|improve this answer

I think you are looking at this from a wrong angle.

Language feature debates are esoterical

The presence of a language feature or the absence of another is not what makes a language useful. And even when your take a single feature, people might actually disagree on whether it is in fact an advantage or not. Personally - without wanting to argue, let alone claim I am right - I think the lack of static typing is a design flaw. I also think the static type system Java has serious design flaws. Same applies to operator overloading:

I saw `cout' being shifted "Hello world" times to the left and stopped right there.
— Steve Gonedes

There are countless religious wars fought about whether a language feature is good or bad. And in the end, there's probably no such thing as a good or bad feature. A feature can be well executed and compose well with all other language features. That's what makes a language elegant. Please note that elegant still doesn't mean useful, which is why I think you're looking at this from the wrong end.

Talk is cheap - code is code

To convince your counterpart, you will actually need to implement working solutions for a sufficiently realistic problem from the domain at hand. So will they. And than you will have to choose sensible metrics to compare both solutions. As for "Python vs Ruby", my guess as an outsider (I don't particularly care for either) is really, that you won't find much of a difference. There's claims that Django is faster than Rails. If you can actually prove that and if that speed difference is important, you might have a solid argument at hand. Other than that, I don't think any of you will be able to establish superiority of one language over the other. It'll just come down to a matter of taste.

Now as for comparing Python to Java, I think you should be able to plausibly demonstrate higher productivity with Python. But that's really for you to accomplish.

Either way, when comparing toolchains (which is what this is about in the end), any side of the argument must provide hard evidence on how their toolchain makes real life problems easier. Use that evidence to either prove that one toolchain is superior or toss a coin if all else fails. You either win by getting your way or win by getting a chance to learn something new.

share|improve this answer

To evangelize to Java users, find some reasonably sized Java code and rewrite it using Jython. This gives python syntax using the Java libraries, and can show how Python can be both more terse and more clear than Java.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.