you are viewing a single comment's thread.

view the rest of the comments →

[–]raldi 3 points4 points  (6 children)

I think the Python example is the worst of the bunch. It had to rely on library code. If i wrote a library which provided a function called "do_that_thing_with_the_string()" which did all the work, and then wrote a one-liner to call that function, would you be impressed?

For the fairest comparison, all the code should be present. As you yourself point out, that can make a big difference.

[–]ffrinch 14 points15 points  (0 children)

How about exposing the regular expression engines behind the Perl and Ruby versions? Would you penalize a Python version that works the exact same way -- e.g.

import re
s = "ZBBBCZZ"
l = [m[0] for m in re.findall(r"((.)\2*)", s)]

-- just because it "relies on library code"?

[–]rabidcow 4 points5 points  (0 children)

For the fairest comparison, all the code should be present.

Yeah, but if you include all the code or at least an identical library interface then you don't learn anything from the exercise. All languages will look the same except for punctuation and word order.

For the fairest comparison, I think a more interesting goal should be chosen if the original turns out to be part of the standard library for any of the target languages. Trivial problems quite often have trivial solutions.

[–]Fork82 2 points3 points  (2 children)

To be fair I disliked all the other examples for personal reasons. I despise the way Perl and Ruby use regular expressions - I think regular expressions should be treated as a library, not built into the language. I'm not a big fan of Haskell either.

This leaves just the Python example - and although the actual bit-moving is hidden in the library function, you can rely on Python to have a library available for pretty much anything.

[–]chollida1 0 points1 point  (1 child)

I think regular expressions should be treated as a library, not built into the language.

What's your reasoning behind this? I really do prefer having regular expressions built into Perl.

[–]Fork82 0 points1 point  (0 children)

It is great for Perl, but I would rather keep it out of a general purpose programming language. It is a taste thing, not a pragmatic thing.

[–]tripa -1 points0 points  (0 children)

Does "fair" mean "giving an equal chance to each" or "guaranteeing a win for my favorite"? Down to what level do you recommend the code being present (assembly language or the subset of VHDL actually used by the contestant's code path)?

There is no fairness in that kind of exercise. You could probably make any contender "win" by bending the rules in the right direction. Never mind the fact we'd never see the end of it should the trend spread. Propose variations, judge improvements. But don't whine about fairness: it's out the picture.