Live data from Hacker News

How to write X in both Python 3 and JavaScript

sayazamurai.github.io

51–60 of 84 posts

Re: How to write X in both Python 3 and JavaScript

#51

How to write using X in both languages: Python: https://github.com/python-xlib/python-xlib Node.js: https://github.com/sidorares/node-x11

Haha, I also expected this.

Now I'm kind of glad you responded in kind because I'd seen python-xlib but not the node one. That sounds like a bit of fun and punishment at the same time.

Re: How to write X in both Python 3 and JavaScript

#52

Sort example doesn't take into account Javascript does lexicographical sorting? javascript: someList = [ 40, 2, 1, 3, 7, 99] someList.sort() Array(6) [ 1, 2, 3, 40, 7, 99 ] python: someList = [ 40, 2, 1, 3, 7, 99] sorted(someList) [1, 2, 3, 7, 40, 99]

It depends on whether or not you pass it a basic comparator function, eg:

    someArray.sort((a,b) => a - b);
But yeah the example would have needed this for the less complex example as well to be accurate.

Re: How to write X in both Python 3 and JavaScript

#54

Do people actually use cheat sheets like this? IMO, the first stackoverflow result in google is generally what I'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/search/scroll for the specific thing you're looking for. Also, with Alfred you can google anything even quicker by not having to cmd+ta…

Maybe not as a reference, but it's certainly helpful to browse if you're going from one language to another (I know python and I'm learning Javascript, this probably saved me a few google searches)

Re: How to write X in both Python 3 and JavaScript

#55

Do people actually use cheat sheets like this? IMO, the first stackoverflow result in google is generally what I'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/search/scroll for the specific thing you're looking for. Also, with Alfred you can google anything even quicker by not having to cmd+ta…

In the past I've enjoyed using cheatsheets to get a quick feel for the syntax of a language. It's nice to see a less familiar language next to a more familiar one.

Re: How to write X in both Python 3 and JavaScript

#56

Do people actually use cheat sheets like this? IMO, the first stackoverflow result in google is generally what I'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/search/scroll for the specific thing you're looking for. Also, with Alfred you can google anything even quicker by not having to cmd+ta…

I used a resource similar to this to get started with Javascript almost a decade ago. Reading through the examples start to finish is a decent intro to the basics.

Re: How to write X in both Python 3 and JavaScript

#57

Sort example doesn't take into account Javascript does lexicographical sorting? javascript: someList = [ 40, 2, 1, 3, 7, 99] someList.sort() Array(6) [ 1, 2, 3, 40, 7, 99 ] python: someList = [ 40, 2, 1, 3, 7, 99] sorted(someList) [1, 2, 3, 7, 40, 99]

Oh gosh. TIL.

Edit: I'm actually truly grateful, I'm sure this bit of knowledge saved me some of my hair in the future.

Re: How to write X in both Python 3 and JavaScript

#58

Sort example doesn't take into account Javascript does lexicographical sorting? javascript: someList = [ 40, 2, 1, 3, 7, 99] someList.sort() Array(6) [ 1, 2, 3, 40, 7, 99 ] python: someList = [ 40, 2, 1, 3, 7, 99] sorted(someList) [1, 2, 3, 7, 40, 99]

It depends on whether or not you pass it a basic comparator function, eg: someArray.sort((a,b) => a - b); But yeah the example would have needed this for the less complex example as well to be accurate.

Shouldn't that be `a < b`?

Re: How to write X in both Python 3 and JavaScript

#59
post #31

No mention of http://rosettacode.org , tsk tsk. (specifically: http://rosettacode.org/wiki/Category:Programming_Tasks )

Hehe, I didn't know that but the page reminded me of of the Arch Linux Rosetta Stone page[1] instantly ;-)

[1]: https://wiki.archlinux.org/index.php/Pacman/Rosetta

Post reply on HN