Live data from Hacker News

Hyperpolyglot: PHP, Perl, Python, Ruby

hyperpolyglot.org

11–20 of 58 posts

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#11
post #2

That these languages are so similar a table like this is possible leads one to think those programmers who consider themselves "polyglot" by programming in a subset of these aren't really "polyglot" at all.

Go to http://hyperpolyglot.org/ directly.

Included there:

    Scripting Languages:         PHP, Perl, Python, Ruby
    Embeddable Languages:        Tcl, Lua, JavaScript, Io
    Shell Languages:             Bash, Zsh, AppleScript, PowerShell
    C Style Languages:           C, C++, Objective C, Java, C#
    Pascal Style Languages:      Pascal, Ada, PL/SQL, SQL/PSM
    Lisp Dialects:               Common Lisp, Scheme, Clojure, Emacs Lisp
    Type Inference Languages:    Standard ML, OCaml, Scala, Haskell
    Declarative Languages:       Prolog, Erlang, Oz
    Concatenative Languages:     Forth, PostScript, Factor
    Computer Algebra Software:   Mathematica, Sage, Maxima
    Numerical Analysis Software: MATLAB, R

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#12

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.

The Python bits do not seem to be written by a Python programmer, at least things like the above and this "package management" entry make little sense:

  $ python
  >>> help('modules')
  download pkg with matching python version
  $ tar xf libxml2-python-2.6.0.tar.gz
  $ cd libxml2-python-2.6.0
  $ sudo python setup.py install	
That's just bizarre.

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#13
Neat table, one thing about PHP's member variables compared to Python/Ruby seems inaccurate though. In the example "define class", the member variable $value is declared private and then accessed through a getter and a setter, while the corresponding Python and Ruby examples use a public variable and hence look cleaner. The equivalent PHP version should be more along the lines of:

  class Int {
    function __construct($int = 0) {
      $this->value = $int;
    }
  }
instead of the ridiculously verbose thing they posted there.

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#15
post #7

I think this shows that much of the time, the choice of open source scripting language isn't going to make or break a project. Ditto for well-maintained web frameworks. http://www.slideshare.net/joestump/starting-your-startup/65

Well it may not make or break a start-up but it definitely help push it one direction or the other

As much as I love Perl, if I want local partners I'd better choose Ruby

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#17
Some of the PHP stuff, as others have noted with Python, etc., is misleading or outdated.

Backticks work:

    echo `ls`;
Constants can be declared globally:

    const PI = 3.14;
Anonymous functions can be declared without create_function:

    $f = function($x) { return $x*$x; }
I'm sure there are more. That said, I love these sorts of side-by-side comparisons.

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#18

Some of the PHP stuff, as others have noted with Python, etc., is misleading or outdated. Backticks work: echo `ls`; Constants can be declared globally: const PI = 3.14; Anonymous functions can be declared without create_function: $f = function($x) { return $x*$x; } I'm sure there are more. That said, I love these sorts of side-by-side comparisons.

There is a lot of non-idiomatic Ruby as well

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#19
post #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.

You can't create 'idiomatic polyglots'. You just hack things together until they sorta work, for more than few languages this basically involves large strings and lots of backslashes, or base64 or something like that. (Writing a polyglot that does something more clever is obviously much better style, but it's incredibly hard.)

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#20
post #19
post #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.

You can't create 'idiomatic polyglots'. You just hack things together until they sorta work, for more than few languages this basically involves large strings and lots of backslashes, or base64 or something like that. (Writing a polyglot that does something more clever is obviously much better style, but it's incredibly hard.)

"Polyglot" in this case is referring to a person who can write in multiple languages, not a program written in multiple languages.
Post reply on HN