Live data from Hacker News

Hyperpolyglot: PHP, Perl, Python, Ruby

hyperpolyglot.org

1–10 of 58 posts

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#4
Neat, ridiculously comprehensive table. A few "warnings" I found in the first 10%:

> Python: Statement separator: ; or sometimes newline

More like newline or sometimes ;. When was the last time you saw a Python script with a semicolon?

> Python: Multiline comment: '''comment line\nanother line'''

That's a multiline string.

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#5
x.succ is not the Ruby equivalent of ++$x in PHP (or Perl). x.succ returns x + 1 (by default, on integers) but does not increment x as ++$x does (since numbers are immutable and that's what "x" is giving us in Ruby). The closest match would be x += 1 (shorthand for x = x + 1). I don't see x = x.succ in common usage but that would work too.

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#8

x.succ is not the Ruby equivalent of ++$x in PHP (or Perl). x.succ returns x + 1 (by default, on integers) but does not increment x as ++$x does (since numbers are immutable and that's what "x" is giving us in Ruby). The closest match would be x += 1 (shorthand for x = x + 1). I don't see x = x.succ in common usage but that would work too.

I don't disagree with what you're saying, but it does mention in the comment that x is not mutated.

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#9
post #8

x.succ is not the Ruby equivalent of ++$x in PHP (or Perl). x.succ returns x + 1 (by default, on integers) but does not increment x as ++$x does (since numbers are immutable and that's what "x" is giving us in Ruby). The closest match would be x += 1 (shorthand for x = x + 1). I don't see x = x.succ in common usage but that would work too.

I don't disagree with what you're saying, but it does mention in the comment that x is not mutated.

I totally didn't notice that note but the page doesn't seem to have been updated since then :-)

I still don't see why it doesn't just use the common syntax though that does the same thing. It's intriguing that the Python one has no example for that row. Perhaps they are specifically looking for idiomatic techniques, even if they're not commonly used.

I note that the page is on a wiki so I could fix it, but given it's been there for years, I suspect there's a good reason no-one has already made the change.

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#10
These tables are comprehensive, but the authors don't seem to actually understand the languages' idioms.

Over on the ISWIM-family page the Haskell "command line args" program is ten lines long, when it could be:

  import System
  main = getArgs >>= mapM_ putStrLn
I wish these were written by people who knew the languages.
Post reply on HN