TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How to write X in both Python 3 and JavaScript

178 点作者 chibicode超过 6 年前

23 条评论

alyandon超过 6 年前
Sort example doesn&#x27;t take into account Javascript does lexicographical sorting?<p>javascript:<p><pre><code> someList = [ 40, 2, 1, 3, 7, 99] someList.sort() Array(6) [ 1, 2, 3, 40, 7, 99 ] </code></pre> python:<p><pre><code> someList = [ 40, 2, 1, 3, 7, 99] sorted(someList) [1, 2, 3, 7, 40, 99]</code></pre>
评论 #17990564 未加载
评论 #17989006 未加载
评论 #17989321 未加载
评论 #17992744 未加载
评论 #17988069 未加载
评论 #17992567 未加载
ChrisSD超过 6 年前
As someone who is often switching languages, I find these sorts of cheatsheets useful.<p>I know all the syntax in them but I&#x27;ll be damned if I can ever remember which language uses which until I&#x27;ve settled back in to things.
评论 #17992268 未加载
评论 #17988017 未加载
评论 #17990196 未加载
aninteger超过 6 年前
How to write using X in both languages:<p>Python: <a href="https:&#x2F;&#x2F;github.com&#x2F;python-xlib&#x2F;python-xlib" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;python-xlib&#x2F;python-xlib</a><p>Node.js: <a href="https:&#x2F;&#x2F;github.com&#x2F;sidorares&#x2F;node-x11" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;sidorares&#x2F;node-x11</a>
评论 #17987847 未加载
评论 #17987626 未加载
评论 #17988983 未加载
评论 #17987628 未加载
marsrover超过 6 年前
When I read the headline I was expecting the X windowing system. When I clicked the article and saw “junior programmer” I thought this is about to be impressive.<p>Cool site :P
fabiomaia超过 6 年前
Very cool! Reminds me of <a href="http:&#x2F;&#x2F;youmightnotneedjquery.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;youmightnotneedjquery.com&#x2F;</a><p>I particularly enjoyed seeing that you used snake case in Python and camel case in JavaScript. Great attention to detail.
sayazamurai超过 6 年前
Creator here! Let me know if you have any suggestions.
评论 #17988888 未加载
评论 #17987554 未加载
评论 #17987536 未加载
评论 #17988731 未加载
评论 #17987979 未加载
评论 #17988915 未加载
评论 #17987864 未加载
评论 #17987896 未加载
评论 #17987550 未加载
评论 #17987968 未加载
评论 #17987482 未加载
评论 #17987488 未加载
mvilim超过 6 年前
<a href="http:&#x2F;&#x2F;hyperpolyglot.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;hyperpolyglot.org&#x2F;</a> is a great website with a similar idea.
评论 #17987618 未加载
ramses0超过 6 年前
No mention of <a href="http:&#x2F;&#x2F;rosettacode.org" rel="nofollow">http:&#x2F;&#x2F;rosettacode.org</a>, tsk tsk. (specifically: <a href="http:&#x2F;&#x2F;rosettacode.org&#x2F;wiki&#x2F;Category:Programming_Tasks" rel="nofollow">http:&#x2F;&#x2F;rosettacode.org&#x2F;wiki&#x2F;Category:Programming_Tasks</a>)
评论 #17989494 未加载
thomasfedb超过 6 年前
A weird reference imo. Perhaps useful to build as a learning experience but I wouldn&#x27;t expect who needs if&#x2F;else included in a cheat sheet to be ready to learn to languages.
评论 #17987586 未加载
dkonieczek超过 6 年前
Do people actually use cheat sheets like this? IMO, the first stackoverflow result in google is generally what I&#x27;m looking for and quicker - especially for common things and common languages such as the things on this page. Even if you have the page bookmarked, you still need to find&#x2F;search&#x2F;scroll for the specific thing you&#x27;re looking for. Also, with Alfred you can google anything even quicker by not having to cmd+tab to the browser.
评论 #17989252 未加载
评论 #17989270 未加载
评论 #17989293 未加载
feniv超过 6 年前
Reminds me of this OneLang HN post from several months ago - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=16415051" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=16415051</a><p>It&#x27;s an IDE that lets you code simultaneously in several different languages <a href="https:&#x2F;&#x2F;ide.onelang.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ide.onelang.io&#x2F;</a>
tobiasz-cudnik超过 6 年前
Reminds me of PLEAC - Perl Cookbook translated to &gt;10 langs <a href="http:&#x2F;&#x2F;pleac.sourceforge.net" rel="nofollow">http:&#x2F;&#x2F;pleac.sourceforge.net</a>
nayuki超过 6 年前
When I publish code about algorithms and data structures to my web site, I usually offer multiple language versions. Why? Because understanding the computer science theory and math proofs is a big effort. Writing and debugging my first implementation in any language is a big effort. But porting that code to a bunch of languages is comparatively easy and is almost a thoughtless mechanical process.
basilgohar超过 6 年前
I thought this was going to be a polyglot[1] demonstration of writing code for X Windows. However, I was not disappointed in what I found!<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Polyglot_(computing)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Polyglot_(computing)</a>
anticensor超过 6 年前
I expected a Python&#x2F;JS polyglot :)
评论 #17990157 未加载
Too超过 6 年前
Impressive to see almost all JS examples being as short as the python ones. Python is normally valued for being short and concise but modern JS is really catching up here.
aavotins超过 6 年前
I had such high hopes when I opened the arsenal. I anticipated it would an article of how to write code that&#x27;s both JavaScript and Python syntactically correct.
another-cuppa超过 6 年前
What&#x27;s the point of having print or console.log around everything? Just have one box with &quot;print to standard output&quot; and those two at the top.
sheikheddy超过 6 年前
I love it! Reminds me of <a href="https:&#x2F;&#x2F;www.interviewbit.com" rel="nofollow">https:&#x2F;&#x2F;www.interviewbit.com</a>
ingen0s超过 6 年前
Excellent educational tool - will be passing this around to colleagues who need it. Thanks!
评论 #17987664 未加载
评论 #17987603 未加载
undershirt超过 6 年前
this is very good. i had it in my head that there was no &quot;extend&quot; function in JS, and didn&#x27;t realize &quot;push(...array)&quot; was possible. thank you for the super detailed guide
tracker1超过 6 年前
FizzBuzz example isn&#x27;t correct
enitihas超过 6 年前
I was expecting to see a leftpad comparison too :D