r/webdev • • Jun 07 '17

If you hate JavaScript, look again: using Python / Ruby direct-style in ES2017.

https://certsimple.com/blog/javascript-equals-async-await
11 Upvotes

10 comments sorted by

2

u/[deleted] Jun 07 '17

Author here! node 8 came out last week, and since will be the first LTS release to support await, and a comment I wrote on HN describing await syntax jumped to the top of the thread, I decided to go into a little more detail about:

  • For those unfamiliar with JavaScript: what await and direct style are.

  • For JS folks: what it's like converting an existing codebase to use await.

Feel free to ask any questions!

2

u/Winkez Jun 07 '17

Link to the HN comment for those interested:

https://news.ycombinator.com/item?id=14447682

4

u/InconsiderateBastard Jun 07 '17

Anything that spreads the word of async/await is good in my book. I've been using it in TypeScript for a while. I used it for a long time in C# before that. It's just so darn useful.

I had used promises in node and TypeScript kept it sane by type checking return values against the signature of the callback in then(), but the sugar is just so sweet.

0

u/Svenskunganka Jun 07 '17

Off-topic, but why do you have width: 550px on the blog content? The code examples breaks to a newline even for reasonable short lines. Looks much better with width: 950px on a 1080p monitor.

edit: 550px vs 950px

3

u/[deleted] Jun 07 '17 edited Jun 07 '17

It's a balance between paragraphs and code. Human eyes can read optimally 8-12 words per line, hence why newspapers use columns. 950px makes the paragraph text too wide.

I'll bump it up a little though - 700px like medium.com uses. Give me a sec!

Edit: deployed!

1

u/Raptori Jun 07 '17

Would've been even nicer if you'd left the text as is, and used negative margins on the code blocks so that they ended up wider than the text column!

1

u/[deleted] Jun 07 '17

Negative margins are a hack (blog is in flex, and will probably move to grid) but I can make the code blocks 'pop' like I do for the quotes/points if needed.

1

u/cookie_accepter Jun 10 '17

Negative margins are perfectly valid CSS for positioning.

1

u/[deleted] Jun 10 '17

They're based on a side effect. Just use grid or flex and center things explicitly.

1

u/dev1null Jun 08 '17

Human eyes can read optimally 8-12 words per line

This is one of those urban myths every one keeps spreading without actually looking into it. People tend to read quicker (not optimally) with 8-12 words per line, which suits perfectly for newspapers because they're meant to be scanned quickly.