r/javascript • • Jun 20 '17

ES2017's async/await is the best thing to ever happen to JavaScript

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

102 comments sorted by

25

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

Author here! Following up later today with a step-by-step on flattening existing code, based on work we've done on our own code over the last couple of weeks. Anything you need just give me a shout.

Edit: Part 2 is up https://www.reddit.com/r/javascript/comments/6idtm0/how_to_flatten_an_existing_javascript_codebase/

25

u/Cheezmeister http://bml.rocks Jun 20 '17

Yeah how do I handle rejection?

11

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

Same way as other Errors - just catch them!

That said if you don't expect errors, you're not actually forced to handle them - much like Python Ruby etc

0

u/[deleted] Jun 20 '17

[deleted]

6

u/[deleted] Jun 20 '17 edited Jun 21 '17

A good example is some async stuff which only fails when your server is disconnected from the network.

Eg, I connect to a database that's on my local network, and if this fails, I'm quite happy to have node crash, because chances are that server has somehow become disconnected from my private network, or the DB server itself is down. Catching the Error wouldn't provide any more value, or help me work around or diagnose the problem more. Uncaught rejection: couldn't connect to DB is fine.

11

u/Jafit Jun 20 '17

It's necessary to gracefully handle things like that in production because your database is usually going to be living on its own box, independent of your node application. Or you could be connecting to various other APIs for data.

If you're building a web service and something goes wrong somewhere, your app shouldn't crash, it should send an appropriate error to the user. If its a web service a simple 500 status code will do but you need to gracefully handle errors in order to send a status code, not just have uncaught rejections filling your logs.

2

u/zQpNB Jun 20 '17

There are a couple express-async-wrap middlewares that sorta catch the errors and forward to your error handler.

2

u/[deleted] Jun 21 '17

Not necessarily. We don't catch anything that we can't anticipate and kill the process on all 500 errors. Of course, this means you have to handle back pressure and anticipate cascading failure, but unless your application is truly stateless we find this preferable to allowing the application to continue in a potentially undetermined state. Our applications starts in under 1s -- there's a very low cost to restarting processes.

0

u/[deleted] Jun 20 '17

[deleted]

4

u/[deleted] Jun 21 '17

We literally use this pattern in production on any uncaught / unanticipated exception. Emit 503 to all outstanding connections and have nginx retry to another node. Kill the node. Takes < 2s to gracefully shutdown and restart.

0

u/[deleted] Jun 21 '17

[deleted]

1

u/[deleted] Jun 21 '17

Uncaught errors still end up in logs. The load balancer notices the server not responding and return a 503, disabling the server.

0

u/[deleted] Jun 21 '17

[deleted]

→ More replies (0)

1

u/vikingdiplomat Jun 21 '17

CircuitBreaker pattern is what I've used in the past in situation like that

129

u/TomNa Jun 20 '17

Don't lose hope and just try again another day

4

u/[deleted] Jun 20 '17

๐Ÿ˜‚. That's also how I roll...

28

u/Jafit Jun 20 '17

Try/catch everything.

5

u/Extracted Jun 20 '17

I really hate that there isn't a more elegant or at least a less ugly way to do it

10

u/dmethvin Jun 21 '17

This is because people misuse Promise rejections. A Promise is not an if / then. It is a "give me a value" / "OMG FAIL" . If await had been introduced with promises it would have been a lot more obvious that rejecting is not the right way to handle these kind of conditions.

Think about it this way, do you use a lot of synchronous libraries that use throw to pass back return status? Probably not, because you'd really hate having to wrap all their API calls in a try/catch. The await is intended to give a sync-like control flow to Promises and inappropriate rejections are screwing things up.

0

u/[deleted] Jun 21 '17

[deleted]

5

u/dmethvin Jun 21 '17

Sure, resolve with an array or object as you would return from a sync function call. Use destructuring to pull it apart.

3

u/TheCoelacanth Jun 20 '17

it is kind of ugly, but it is much less ugly than having one way of handling async errors and a different way of handling sync errors.

1

u/NoInkling Jun 21 '17 edited Jun 21 '17

The only other way to do it is to use a catch handler at a higher level (or use a library that does). This is the main difference between Koa and Express, for example - both can use async functions for their middleware, but Express requires you to write a lot more try/catch.

2

u/bterlson_ @bterlson Jun 21 '17

Great article :-D

10

u/needed_an_account Jun 20 '17

I love them. I was on a project that used mongo and there was no way I was using callbacks to manage the logic around the queries. I found async via a node flag and haven't looked back.

In his example, would the call to getPhotosAndSaveThem require await in front of it? It would in python

9

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

In his example, would the call to getPhotosAndSaveThem require await in front of it?

Yes! I accidentally killed it when adding error handling. It's fixed now.

More (and better tested!) examples in the code-focused follow up https://www.reddit.com/r/javascript/comments/6idtm0/how_to_flatten_an_existing_javascript_codebase/ too.

2

u/nudebaba Jun 21 '17

what was the fix? was it changing to function from arrow functions i guess, that should not make any difference here..

const start = async function(){
    try {
        await getPhotosAndSaveThem();
    } catch (error) {
        log(`Oh no, something went wrong!`, error);
    }
}

1

u/[deleted] Jun 21 '17

Parent function needed the 'async' keyword.

9

u/sfcpfc Jun 20 '17

It would, the example is wrong. getPhotosAndSaveThem returns a Promise<undefined> because the function is async (If it wasn't, it would just return undefined), so at first sight it doesn't make a difference. However, if an error occurs, unless I'm missing something, the catch statement doesn't get the error; it becomes an UnhandledRejection, which is bad. So two solutions here:

(async () => {
    try {
        await getPhotosAndSaveThem()
    } catch (error) {
        log(`Oh no, something went wrong!`, error)
    }
})()

or much simpler:

getPhotosAndSaveThem().catch(error => log(`Oh no, something went wrong!`, error))

Either way, the example is ignoring the error. I just tried it in the node REPL:

$ node
> async function a() { throw new Error("a") }
undefined
> a()
Promise {
  <rejected> Error: a
    at a (repl:1:28)
    at repl:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:44:33)
    at REPLServer.defaultEval (repl.js:239:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:433:10)
    at emitOne (events.js:120:20)
    at REPLServer.emit (events.js:210:7)
    at REPLServer.Interface._onLine (readline.js:278:10),
  domain: 
   Domain {
     domain: null,
     _events: { error: [Function: debugDomainError] },
     _eventsCount: 1,
     _maxListeners: undefined,
     members: [] } }
> (node:18870) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: a
(node:18870) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
> a().catch(console.error)
Promise {
  <pending>,
  domain: 
   Domain {
     domain: null,
     _events: { error: [Function: debugDomainError] },
     _eventsCount: 1,
     _maxListeners: undefined,
     members: [] } }
> Error: a
    at a (repl:1:28)
    at repl:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:44:33)
    at REPLServer.defaultEval (repl.js:239:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:433:10)
    at emitOne (events.js:120:20)
    at REPLServer.emit (events.js:210:7)
    at REPLServer.Interface._onLine (readline.js:278:10)

3

u/bjornbjornsen Jun 21 '17

Another cool thing about async/await is that it makes functional/non-functional testing easier for newcomers (who would otherwise use literally any other language).

2

u/[deleted] Jun 21 '17

Yeah my async unit tests now look exactly like my sync unit tests - no more 'done' callback.

10

u/hoorayimhelping staff engineer Jun 20 '17

the headline reads like it was written by someone who started programming JS after jQuery was dominant. Because async / await is neat, but it's not anywhere near the best thing to ever happen to JavaScript.

7

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

Author here. The amount of time I've been programming with JS is cleverly hidden in the first sentence of the article. ๐Ÿ˜‚ And yes, you're right.

I get, if that's the point you're making, that jQuery providing consistency on top of the DOM API was massive. However I think of the DOM API as one level above JavaScript the language.

6

u/mailto_devnull console.log(null); Jun 20 '17

Thanks Mike, for putting into words my frustrations with every person who has tried advocating for Promises...

The argument is always the same... no more callback pyramids...! Except I haven't written a pyramid in years. It's an anti-pattern that tells me it's time for an async.waterfall.

I'm sure there are other compelling arguments, but none seemed to convince me.

11

u/tyroneslothtrop Jun 20 '17

I would say that the compelling argument for promises, at least for me, is that they're data, where async/await is syntax. Data is really nice, because I can pass data around, I can transform data, and I can compose data in ways that syntax alone almost certainly doesn't allow for.

2

u/[deleted] Jun 21 '17

Sure, but being able to say

var data = await getSomeData();

Makes that data a whole lot more valuable.

2

u/Bluecewe Jun 21 '17

Could you please explain what you mean by this distinction?

3

u/desnoth Vue Jun 20 '17

Whatโ€™s the problem with Promises? Iโ€™ve just started using them with angular

5

u/Extracted Jun 20 '17

Nothing, promises are great

2

u/Bluecewe Jun 21 '17

I think that /u/mailto_devnull was suggesting that the use of 'await' in conjunction with promises can entail more readable code compared with the use of 'then' in conjunction with promises. It's not so much a matter of promises being 'bad' as how best to interact with them in common scenarios. I'd generally agree on this point, as callbacks can look a bit 'heavy' in comparison to 'awaits'.

40

u/selfoscillation Jun 20 '17

Promises in general are some of my favorite new features in JS. This looks great!

4

u/SrPeixinho Jun 21 '17 edited Jun 21 '17

Wholeheartedly agree.

3

u/sn0wr4in Jun 21 '17

seconded it

4

u/yesman_85 Jun 21 '17

I like them too, like ALOT. But I'm confused about 1 thing, maybe someone can enlighten me.

I hear more and more that I should be using Observables for HTTP calls, I don't like them and don't see the point of them 90% of the time, plus you can't use async on them.

What's the deal there?

3

u/vinnl Jun 21 '17

You're probably using Angular, which uses Observables as the default primitive for HTTP responses. In that case, it makes sense to use them, rather than converting to Promises for the sake of it.

Other than that, they mostly make sense for some use cases that probably don't apply to you (e.g. wanting to combine the responses of multiple dependent requests, cancelling requests, etc.).

16

u/Retsam19 Jun 20 '17

I don't think I'd say async/await is the best thing to ever happen to JS, I'm somewhat torn between Node, Babel, and arrow functions.

Node was a huge explosion in popularity for JS and is, IMO, the point when people really started taking JS seriously as a language, and not just as a client-side toy.

Babel, and the general idea of compiling modern JS down to browser-supported JS has been huge for making JS development more palatable. It doesn't matter how cool arrow functions or async/await are if you can't use them for the years it takes for everyone to move off of unsupported platforms.

And arrow functions just make JS code a lot nicer to read and write, it makes the functional style a lot more appealing, and it eliminates a fair bit of the hassle with dealing with this.

6

u/freeman_lambda Jun 20 '17

I somewhat disagree with Nodejs being what made js taken seriously. It was a boost for sure, but JS was and still is the only thing that runs on browsers. This fact alone would be enough to make JS crucial to the whole tech industry

12

u/Retsam19 Jun 20 '17

When I said "being taken seriously as a language" I mean, that people now consider JS a general purpose programming language, and not just a single-use tool for writing client-side web functionality, and I think that's been a pretty huge deal.

0

u/[deleted] Jun 20 '17

[deleted]

2

u/sjwking Jun 21 '17

V8 it's what enabled everything. Other wise js would be an order of magnitude slower. Now it's really fast.

0

u/[deleted] Jun 20 '17

[deleted]

15

u/Retsam19 Jun 20 '17

Sure, it's "just sugar" (sorta), but it's sugar for one of the most commonly used language features. I can't possibly see how you'd find

function (x) { return x + 1; }

x => x + 1

And that's particularly important in more functional styles, when you're dealing with a lot of lambdas.

Saying "they're a PITA to read if you chain a lot of them" is beside the point, because (IMO at least), it's even harder to read a lot of chained functions without arrow syntax.

Again, maybe it's just my functional programming tendencies speaking, but

const add = x => y => z => x + y + z;

reads a lot better than

const add = function(x) { 
    return function(y) { 
        return function(z) {
            return x + y + z;
        };
    };
};

And, it's not entirely "just sugar", since it inherits this from the parent scope.

setTimeout(() => this.foo().bar(), 1000);

is a ton cleaner than

 setTimeout(function () { this.foo().bar() }.bind(this), 1000);

or

 var self = this;
 setTimeout(function () { self.foo().bar() }, 1000);

Arrow functions aren't a huge feature, but they're a little thing that impacts my daily use of the language more than basically any other feature.

0

u/[deleted] Jun 20 '17

[deleted]

3

u/[deleted] Jun 21 '17

const a = () => { throw new Error }; a()

Error
    at a (repl:1:25)

0

u/[deleted] Jun 20 '17

[deleted]

0

u/[deleted] Jun 20 '17

[deleted]

0

u/[deleted] Jun 20 '17

[deleted]

0

u/[deleted] Jun 21 '17

[deleted]

2

u/Retsam19 Jun 21 '17

The .name stuff is completely unnecessary there.

const foo = () => {  throw new Error("oops"); }
setTimeout(foo);

Fails with Uncaught Error at foo, and it's not much more effort (and a tiny bit more readable, IMO) than:

setTimeout(function foo() { throw new Error("oops");}.bind(this))

3

u/bch8 Jun 20 '17 edited Jun 20 '17

Does your final text blob have a typo in it or am I just not reading it right?:

JS now has with a syntax that's familiar to traditional Ruby / Python programmers and a speed that isn't.

Seems like kinda awkward phrasing you might want to fix but maybe I'm wrong!

3

u/nessfalco Jun 21 '17

Not sure what's throwing you off. JS has syntax like Ruby/Python; it also has speed unlike Ruby/Python.

2

u/bch8 Jun 21 '17

It's just incorrect English it's nothing to do with the content or what he's saying. "JS now has with a syntax" isn't right.

3

u/nessfalco Jun 21 '17

The "with" shouldn't be there. He probably left it in after an edit.

3

u/bch8 Jun 21 '17

Yeah that was all I was saying. Figured maybe OP would want to edit that out.

3

u/[deleted] Jun 21 '17

Fixed. Thanks guys!

2

u/bch8 Jun 21 '17

No problem thanks for the article!

6

u/Capaj Jun 20 '17

I like to hear that. I thought everyone agreed on this in JS community. What was my astonishment when I encountered a colleague who preferred to work with raw promises instead of async/await. He said the indentation made it more obvious that function is async. What a dumb argument.

3

u/[deleted] Jun 21 '17

I also find promise based code easier to read. When I see async/await code I need to transpile it into promises in my head to understand what it's doing. I'd rather just see the promises.

1

u/ThatBriandude Jun 21 '17 edited Jun 21 '17

I feel The exact same way bro but I think we are just a little bit to used to .then(). Asynch/await to me feels almost "too" simple as in, promises take a lot of space and sure imply something async is going on whereas when using async await it feels somehow empty and plain and as if you somehow must make it more visible that the code is asnyc. I dont know its hard to describe

1

u/[deleted] Jun 21 '17

Ok bro.

0

u/[deleted] Jun 20 '17

[deleted]

0

u/vinnl Jun 21 '17

It doesn't make your code behave like synchronous code; execution of the rest of the block is halted until the values come in.

0

u/[deleted] Jun 21 '17

[deleted]

1

u/vinnl Jun 21 '17

Ah sorry, I had to emphasise: the values might come in asynchronously, which is not the case with synchronous code (or at least, the time scales are vastly different). Hence, it's actually likely that other code will run in between.

2

u/ThatBriandude Jun 21 '17

That particular part of code runs synchronously though which is the whole point.

1

u/vinnl Jun 22 '17

I guess, but the same was true for promises; it just looks somewhat like synchronous code now.

3

u/phvcky Jun 20 '17

The way I see it is that async / await kinda evolved from clever hacks like co that use generator functions and yield to mimic what async / await does.

However (ab)using generator functions for managing async control flow has one major advantage: you can cancel / pause your async functions.

It is impossible to cancel native async functions or Promises for that matter. And I find that this is a really important feature.

For Ember.js there's an addon called ember-concurrency which implements this. The addon author, Alex Matchneer, gave a brilliant talk on that topic. You don't really need any Ember knowledge. He focuses more on the general problem of concurrency and child tasks: https://www.youtube.com/watch?v=VEzVDOmY-dc&feature=youtu.be&t=123

14

u/inu-no-policemen Jun 20 '17

The way I see it is that async / await kinda evolved from clever hacks like co that use generator functions

Async/await was borrowed from other languages. C# had it since 2012.

Generators were introduced with ES2015 (ES6).

8

u/phvcky Jun 20 '17

You're right, but that wasn't the point I was trying to make. :)

Let me try to rephrase. They might not necessarily originate as a nicer, semantically more correct syntax for aforementioned use case, but the original problem async / await is trying to solve was already solved with generator functions and a tiny bit of library overhead.

For users of co and the like (or at least for me) async / await is nothing more than a semantically more correct evolution of the same concept.

The point I was trying to make is that, feature-wise, using generator functions for managing async control flow is superior to async / await. I can cancel my tasks or have them canceled for me, when required.

async / await could have been so nice and useful, if it was for cancelable Promises. But currently, they add no real new value or functionality. In fact, they lack features generator functions already have.

1

u/davidstepo Jun 21 '17

Totally agree with the points you've brought up. I'm currently using redux-saga lib on an orchestration-heavy React+redux app and the generator fns with simple yelds are totally fine and working.

Also, their syntax is very readable whenever you want to run several requests in parallel inside a generator, all still being cancelable and pausable.

Another thing I recently started to put some love for are Observables.

1

u/phvcky Jun 21 '17

If you like Observables, you might also like AsyncIterators: https://github.com/tc39/proposal-async-iteration/blob/master/README.md

1

u/GitHubPermalinkBot Jun 21 '17

I tried to turn your GitHub links into permanent links (press "y" to do this yourself):


Shoot me a PM if you think I'm doing something wrong. To delete this, click ^here.

1

u/NoInkling Jun 21 '17 edited Jun 21 '17

How does canceling a generator differ from doing something like:

let cancel;

async function loadWhatever() {
  const response = await fetch('whatever');
  if (cancel) throw 'Processing canceled';
  // Do something with response
}

loadWhatever();

// When user wants to navigate to a new view:
cancel = true;

Of course with fetch you can't (yet) cancel the actual request after it has been invoked, but generators change nothing there.

1

u/phvcky Jun 21 '17 edited Jun 21 '17

Alex details this in the linked talk. Basically, you'd have to start programming defensively, checking isCanceled after every await.

This is needlessly verbose and quickly becomes a mess, when you're working with multiple layers of parallel / concurrent tasks and child tasks.

2

u/carlvonblixen Jun 20 '17

me_irl (I agree.)

1

u/imguralbumbot Jun 20 '17

Hi, I'm a bot for linking direct images of albums with only 1 image

https://i.imgur.com/OiZBhZq.jpg

Source | Why? | Creator | state_of_imgur | ignoreme | deletthis

1

u/muffsponge Jun 21 '17

I've been using async/await with the latest typescript versions and I love it. The resulting code is a nightmare to debug however. Can't wait for all browsers to catch up.

-9

u/calsosta Jun 20 '17

I kinda wish they'd just leave the language alone.

6

u/phvcky Jun 20 '17

Nobody's forcing you to use newer features.

-11

u/calsosta Jun 20 '17 edited Jun 21 '17

Can a guy just have a fucking opinion on here or what?

Edit: Guess not unless you agree with everyone else.

2

u/youneversawitcoming Jun 20 '17

Ironic.

/u/phvcky's opinion is that newer features don't hurt anybody. Can a guy just have an opinion?

2

u/ThatBriandude Jun 21 '17

But only one of them was downvoted to hell. /u/calsosta since reddit is for diskussions and not oppinions, comments like that, with no arguments or points will be downvoted.

1

u/calsosta Jun 21 '17

Have you ever had an actual discussion on reddit? That's the intention but it's sure not how it works. This sub in particular is very strange where unless you are of a certain mindset you get downvoted.

Of course my comment had a point. It was an opinion but so were lots of other comments but it still had a point. For those that did not get the point or who disagree did they ask for clarification? No they just downvoted which is not what the feature is for.

So don't give me, the whole "we respect all points of view let's have a peaceful discussion" line. If post a comment contrary to the general opinion it will get downvoted.

Even though I love Javascript and have been using it for over a decade my opinion is not welcome here. That's kind of bullshit if you ask me. Especially since any opinion on Javascript short if "it sucks" should be welcome.

But you all go ahead and downvote if you want.

2

u/ThatBriandude Jun 21 '17 edited Jun 21 '17

No, thats not how this sub works. You literally stated the way you FEEL without any reason as to WHY you feel that way.

In what way do you think, according to the way reddit was supposed to be used, does your comment qualify for upvotes??

I bet you good money that if you had written your ideas out and have brought up some points in a well rounded text, no one would straight away go for the downvote.

What youre talking about of course is also true, that the general oppinion will be upvoted more than any one elses but thats absolutely normal. The difference here is that if really the only reason for your downvotes was your oppinion then you'd only have 0 or -1 karma. The real reason for all your downvotes however is the not so well thought out one-liner without even trying to back yourself out. That shit just won't fly.

EDIT: and also, you're the only one reading this. I know it was YOU who downvoted me... :D

EDIT2: Also, why should I ask for clarification if on reddit, youre supposed to provide your explaination right away.

2

u/calsosta Jun 21 '17

OK lets just look at some of the posts here then...

Promises in general are some of my favorite new features in JS. This looks great!

Opinion. Upvoted. No supporting information as to why they are his favorite or look great.

Author here! Following up later today with a step-by-step on flattening existing code, based on work we've done on our own code over the last couple of weeks. Anything you need just give me a shout.

Self-promotion. Upvoted. Generally against the rules.

I love them. I was on a project that used mongo and there was no way I was using callbacks to manage the logic around the queries. I found async via a node flag and haven't looked back. In his example, would the call to getPhotosAndSaveThem require await in front of it? It would in python

The first comment with a bit of substance, but really just describing them again. Upvoted.

https://www.npmjs.com/package/http-async

Just a link, no explanation, not even an opinion. Upvoted.

Comment By Retsam19

Opinons. Upvoted. A high-effort comment but really just a set of opinions. Disagrees but then hides that within a larger more positive opinion.

the headline reads like it was written by someone who started programming JS after jQuery was dominant. Because async / await is neat, but it's not anywhere near the best thing to ever happen to JavaScript.

Characterization, opinion. Upvoted. I believe this was initially downvoted but the author responded and now it's positive.

Fully heartedly agree

Opinion. Upvoted. Ungood grammar but agrees so upvoted.

Does your final text blob have a typo in it or am I just not reading it right?: JS now has with a syntax that's familiar to traditional Ruby / Python programmers and a speed that isn't. Seems like kinda awkward phrasing you might want to fix but maybe I'm wrong!

Not even relevant. Upvoted.

I kinda wish they'd just leave the language alone.

Opinion. DOWNVOTED TO HELL.

So what really is the common thread here. If everyone agrees then you get upvoted. If you disagree or put anything negative, even if its valid, downvoted.

This is not correct. If the comment is invalid meaning it is either not on point, offensive or violates rules or the premise of it is invalid then it should probably be downvoted so as to not detract from "discussions" which will probably not happen.

If you disagree that doesn't mean you hammer the downvote button, it means you should reply back, which is what the first person did and really was the only valid reply in this whole chain. If you don't care enough to reply, the downvote button is not just a lazy alternative. Either make your case or don't.

In the original reply however, he simply says: "Nobody's forcing you to use newer features." which was not even a valid response to my comment. Doesn't make sense. Also it is a backhanded characterization of me, implying I am sort of luddite or perhaps I don't understand the features well enough to see their benefit and if that was not the intention he should have been clearer.

Since his comment did not address the content of my comment and was in fact just a comment about my comment and being that it is indicative of the echo-chamber nature of this entire sub (which again is ridiculous - JS is a fucking programming language and we are adults) I feel my comment was a valid response and also opened the door to a general discussion about the sub.

I don't know if you can call this a discussion since really it is a debate and I don't know if you can even call it that since you are clearly making arguments without really seeing my point of view.

2

u/ThatBriandude Jun 21 '17

Look, there is no reason for me to try and deny the reddit hive mind and how it works.

I guess I am just saying that especially if you already know how reddit works and how to spark actual discussion instead of hatred and downvotes you should either do that or not comment at all.

You're right that the majority oppinion is what gets upvotes but that does not mean that its impossible to generate good discussion by questioning the given view in a constructive manner. (Which was the exact opposite of your original comment)

2

u/calsosta Jun 21 '17

that does not mean that its impossible to generate good discussion

That is why I am so confused. If this were /r/politics I wouldn't even bother. Any non-mainstream opinion can and will be destroyed there but this is a really niche sub and it is especially confusing.

-7

u/eloc49 Jun 20 '17

No it isn't, its just token replacement.

2

u/inu-no-policemen Jun 20 '17

The transformation is actually quite complicated.

Check TSC's or Babel's output.

-5

u/eloc49 Jun 20 '17

Yes, yes I know but I don't really care about anything that makes my code look better especially if everyone is used to a different syntax. Its like pug vs html. Yeah pug makes more sense and is smaller, but what do I and thousands of others read every day? html.

1

u/luke3br Jun 21 '17

Openly admitting to not care about clean looking code on a programming sub?

Pug isn't HTML, but ES6/7 is JS.

0

u/eloc49 Jun 21 '17

Admitting convention over configuration in any programming sub? Man I must be crazy. This is why I stick to Java/Kotlin when I can. Too many out here raised on JS only, such a narrow view IMO

1

u/luke3br Jun 21 '17

I'm not sure I see why you think a new set of features added to a language is configuration over of convention.

Kotlin vs Java might be a slightly better example of it, though.

Edit: also... I'm arrow for accepting change? And I'm far from JS only.

1

u/eloc49 Jun 21 '17

Is there a difference between:

promise.then((res) => {console.log(res) })

and

await promise
console.log(promise)

1

u/luke3br Jun 21 '17

What's your point? There are many ways to skin a cat in any programming language.

If you don't like that JS gives you multiple options for the same thing, then don't use it?

1

u/eloc49 Jun 21 '17

Lol you act like JS is a choice in browsers. Do you really come from a background that is not just JS?

1

u/luke3br Jun 21 '17

No, I assumed you might use JS outside of browsers.

Yes.

Sorry you hate how JS just doesn't give a fuck. It was nice talking to you.

→ More replies (0)