
Hyperpolyglot - tosh
http://hyperpolyglot.org
======
rweichler
Lua conditional expressions look like this:

    
    
        x > 0 and x or -x
    

It says _none_ in the reference, which is wrong, so I'm posting it here in
hopes the author might fix it.

Edit:

Found a bunch more things they got wrong.

    
    
        * Bit operations: It says "none", but it's present in Lua 5.3 and LuaJIT.
        * Hex literals are prefixed with 0x
        * String capitalization is used with string.upper, but it says "none".
        * Arrays as function arguments is table.unpack(t), or just unpack(t), depending on the Lua version.
        * Iterate over range is for i=1,100 do --[[ code here ]] end
        * The dictionary size example uses a loop, when you simply could have used #d
        * Sort by values is table.sort
        * Command line options are ...
    

... Anyway, I have to go. There are way more errors in this, with regards to
Lua anyway. I wouldn't use this reference.

~~~
azdle
It looks like they take contributions:
[https://github.com/clarkgrubb/hyperpolyglot](https://github.com/clarkgrubb/hyperpolyglot)

------
UweSchmidt
Can we have an IDE that let's us use our favourite syntax with other
languages, please? Auto-correct, suggest syntax, advise on proper usage/best
practice/pitfalls in target language.

We already have autocomplete, stubs, and smart guessing which library I might
need to include. People probably repeat the same typical mistakes thousands of
times each day as they transition between languages. So just allow us to use
fundamental programming concepts and take care of the details for me!

If we were able to use our _syntax_ of choice, and "reformat" existing code to
our preference, we would probably all be much more inclined to move on to
newer _languages_ and thus advancing the field much faster.

"Looks like you're coming from VBA, remember in this language arrays start at
0..."

~~~
hardwaresofton
Theoretically this seems possible with Haxe
([http://haxe.org/manual/introduction-what-is-
haxe.html](http://haxe.org/manual/introduction-what-is-haxe.html)). It seems
possible to write something that went from Python -> Haxe -> Java?

Right now all I know for sure is that Haxe offers Haxe -> Python in sourcecode
(though an AST would be better, probably), and Haxe offers Haxe -> C++...

Generally, it might make more sense to go from AST to AST then back to source
code or something, if you didn't need to see the source code after.

I personally appreciate that different languages have different syntax. In
some languages it doesn't matter (because they're so close anyway), but across
large gulfs there are non-negligible differences in productivity, IMO. If I
need to write lots of regexes and do some small scripting or write something
no one will understand later, perl's syntax might shine there, it would be bad
(I think) to get into the habit of writing in one syntax or with one syntax
when there are better syntaxes that might cut down on writing time for the
job... Of course, there is the benefit of cutting down unnecessary writing by
using perl INSTEAD of something like Java by using this idea...

~~~
hardwaresofton
*AST -> AST -> vm/interpreter bytecode/machine code

------
bbrks
I've been writing Go for the last 18 months, and seeing it dissected side-by-
side with C [0] is causing some epiphanies that I wouldn't normally get to see
in day-to-day programming.

Excellent resource.

[http://hyperpolyglot.org/c](http://hyperpolyglot.org/c)

~~~
pitaj
> capitalized top-level identifiers are exported

I saw this and thought that it's just weird and confusing. Why would someone
make case-sensitivity a syntax for exports?

~~~
tedunangst
One less keyword in the language, and you can tell at the call site whether
it's an internal function.

------
Lemmih
Quite a few errors for Haskell. 'n <\- return 3' is NOT a way to create a
mutable reference. Silly things like that are scattered all around.

~~~
junke
I agree. The Lisp dialect page for example, has:

\- inaccuracies (e.g. word separator in CL depends on current readtable),
which is understandable given the very terse format

\- missing cases (e.g. no compiler for CL?)

\- and factually wrong elements (identifiers are case sensitive, but upcased
while reading by default; they can starting with numbers, like 1+, etc.).

Fortunately there is a way to fix that:
[https://github.com/clarkgrubb/hyperpolyglot/issues](https://github.com/clarkgrubb/hyperpolyglot/issues)

------
rpwilcox
[http://rosettacode.org/wiki/Rosetta_Code](http://rosettacode.org/wiki/Rosetta_Code)
is also an interesting site for similar problems

~~~
placebo
Rosetta Code is cool, but I've long been looking for a "Rosetta stone" type of
tool to show the equivalents of lower level operations in various languages.
Recently I found a good resource for matrix operations
([http://sebastianraschka.com/Articles/2014_matrix_cheatsheet....](http://sebastianraschka.com/Articles/2014_matrix_cheatsheet.html)).
This however covers other topics and languages as well . Another gem to add to
my bookmarks :-)

------
cfv
When looking at scripting languages, there's a couple problems.

What does "no encoding" mean, or "constant by convention"? Can I write
gibberish UTF32 in PHP and it won't care? Can I modify one of this "by
convention" constants without a parsing error?

~~~
rajangdavis
Could be wrong, but constants are all UPPERCASE by convention in a few
different languages, I think that's what that means. I don't think this would
break anything, I think it's supposed to make the code easier to read/nicer
for handing off code to another developer. I don't use Python, but I have seen
it in PHP, Ruby, and Javascript and they don't break there.

PHP handles encoding in a very naughty way. I don't know the origins behind
this, I only know that it will produce text in the wrong format at times.

I have had issues where I would try to get some JSON with Japanese text and it
will produce some janky unicode that doesn't work. There are work arounds for
specifying encoding, but it's contingent upon what version of PHP you are
using (I am stuck on 5.3.2 for a legacy, closed sourced app with a custom PHP
binary).

------
andyfleming
Is this managed by an individual or is it something open-source that can be
contributed to?

Edit: Nevermind. Found
[https://github.com/clarkgrubb/hyperpolyglot](https://github.com/clarkgrubb/hyperpolyglot)

------
kmfrk
I remember a similar site with someone who set it up as a "learn a language in
a jiffy" where it was set up sequentially instead of a cheat sheet. Had
languages like Python and Ruby, can't remember the rest.

I haven't been able to find it, but it was a really useful resource, and I
wish I could remember what the name was.

~~~
Arnot
That might have been
[https://learnxinyminutes.com](https://learnxinyminutes.com). It's pretty
useful as a quick reference if you're switching languages a lot.

~~~
kmfrk
That's an awesome site, but it's not the one I failed to remember. That one
had a few pages for each language showing you lists and the like.

Will bookmark this, though.

------
WikiPaperGuy
I use this quite often and find it really helpful, thankyou to the founder if
you're listening.

It'd be even better if it was wiki-editable so that people can make
improvements without having to use git. It would also be great if the language
functions used (like strpos) linked to official documentation.

~~~
dvfjsdhgfv
This. I've found a few minor glitches and would've already submitted them
while reading if there was a faster way to do it.

------
gravypod
Some of this is incorrect like the PHP bit about "expression interpolation".
Here is an example:

    
    
       <?php
               $hello_world = 10;
               $two = "two";
               echo "hello_world = $hello_world\n";
               echo "two[1] = {$two[1]}\n";

~~~
andyfleming
It is a strange example, but it looks correct. What's wrong with it?

Also, you can always open up a PR on
[https://github.com/clarkgrubb/hyperpolyglot](https://github.com/clarkgrubb/hyperpolyglot)

------
simplify
Would be good to add some concatenative languages to that list :)

[http://evincarofautumn.blogspot.com/2012/02/why-
concatenativ...](http://evincarofautumn.blogspot.com/2012/02/why-
concatenative-programming-matters.html)

~~~
tom_mellior
There is a "Forth, PostScript" section.

------
mattashii
I find it interesting they essentially say 'node.js is a scripting language'.
I dont get that. As far as I know, Node.js is a js interpreter with extra
system api bindings. How would that make Node.js the language?

------
dvfjsdhgfv
Kudos to the author for compiling these. One note: Maxima can do fast Fourier
transform, too (with fft and inverse_fft).

------
keefe
this is a good idea, creative commons so it's ok to scrape I think...

I'm interested in using nodejs to replace bash scripting, I loathe doing any
kind of logic in bash and I just want to excise it. No maven or gradle for
build tools. I'll revisit later.

Good domain name as well, easy to memorize, good job.

------
simonlc
Math.min.apply(Math, [1, 2, 3]) Math.max.apply(Math, [1, 2, 3])

Could just be:

Math.max(...[1, 2, 3])

~~~
hk__2
The JS code is written in ES5 so this syntax is not available.

~~~
gingerrr
There are several other examples which show both ES6 and ES5 syntax, there is
no reason the better ES6 syntax couldn't be shown here as well.

------
spinlock
This is such a great project :+1: for putting it together

