13 ms·
Hyperpolyglot
- cfv 10y agoWhen 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 10y agoCould 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).
- actsasbuffoon 10y ago> Can I modify one of this "by convention" constants without a parsing error? Depends on the language. Python does not enforce constants, so you can modify them freely. JavaScript as of the ES5 spec did not enforce constants, but ES6 does. Ruby mostly enforces constants, but there are certain bits of metaprogramming that will allow you to overwrite a constant if you are determined enough.
- Lemmih 10y agoQuite 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.
- catnaroek 10y agoNor is it a way to achieve anything useful. Might as well just write “let n = 3”. :-p
- junke 10y agoI 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
- bbrks 10y agoI'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
- imagist 10y agoI find it funny that the C code is in a larger font than the Go code.
- lgas 10y agoIt is not for me.
- pitaj 10y ago> 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?
- liveoneggs 10y agoit's also used in erlang and haskell, which happen to also use "_" for "don't care"
- tedunangst 10y agoOne less keyword in the language, and you can tell at the call site whether it's an internal function.
- Jabbles 10y agoIts discussion of stack vs heap is not entirely accurate: // memory allocated on heap: ptr := new(int) *ptr = 7 Depending on how ptr is used, escape analysis may place *ptr on the stack. Also note that the terms stack and heap are not directly comparable between languages anyway.
- 10y ago
- rpwilcox 10y agohttp://rosettacode.org/wiki/Rosetta_Code http://rosettacode.org/wiki/Rosetta_Code is also an interesting site for similar problems
- placebo 10y agoRosetta 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.html http://sebastianraschka.com/Articles/2014_matrix_cheatsheet....). This however covers other topics and languages as well . Another gem to add to my bookmarks :-)
- wx196 10y agoAnd handy http://rosetta.alhur.es/ http://rosetta.alhur.es/
- simonlc 10y agoMath.min.apply(Math, [1, 2, 3]) Math.max.apply(Math, [1, 2, 3]) Could just be: Math.max(...[1, 2, 3])
- kmfrk 10y agoI 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 10y agoThat 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 10y agoThat'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.
- spinlock 10y agoThis is such a great project :+1: for putting it together
- simplify 10y agoWould be good to add some concatenative languages to that list :) http://evincarofautumn.blogspot.com/2012/02/why-concatenative-programming-matters.html http://evincarofautumn.blogspot.com/2012/02/why-concatenativ...
- tom_mellior 10y agoThere is a "Forth, PostScript" section.
- gravypod 10y agoSome 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 10y agoIt 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
- rweichler 10y agoLua 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.
- tyre 10y agoI don't think the author should "fix" this. If these are language features but undocumented, then for all intents and purposes they don't exist.
- rweichler 10y agoWhen I said undocumented, I was saying that it's undocumented in this reference. I'll edit that part out to avoid confusion.
- tedunangst 10y agoAdd closures to the list. Also, I thought it's really strange that scripting languages 1 and 2 have different tables. Even if the tables were complete and accurate, can't compare javascript and lua because the rows are different.
- azdle 10y agoIt looks like they take contributions: https://github.com/clarkgrubb/hyperpolyglot https://github.com/clarkgrubb/hyperpolyglot
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]
- andyfleming 10y agoIs 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
- UweSchmidt 10y agoCan 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..."
- sharpercoder 10y ago...and commit in the syntax of choice of target repo automatically as well.
- hardwaresofton 10y agoTheoretically 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 10y ago
- keefe 10y agothis 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.
- mattashii 10y agoI 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?
- WikiPaperGuy 10y agoI 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 10y agoThis. I've found a few minor glitches and would've already submitted them while reading if there was a faster way to do it.
- dvfjsdhgfv 10y agoKudos to the author for compiling these. One note: Maxima can do fast Fourier transform, too (with fft and inverse_fft).