HNHacker News
TopNewBestAskShowJobs

nvivo

213 karma · joined December 15, 2014

submissionscomments
nvivo··on Microsoft Edge gets native ECMAScript 7 async/await support in latest build
About the points you make on your post, once async/await is implemented in browsers, you will be able to await run() directly, causing the exception to be thrown in the console.

The fact that you call a method that returns a promise but don't check this promise may be a little confusing to someone new to the language, but it it's not a flaw in the design.

In c#, any attemp to call a method that returns tasks (promise) without an await or a .continueWith (.then) causes a compiler warning. It's just a matter of time for tooling in the browser to keep up.

nvivo··on Microsoft Edge gets native ECMAScript 7 async/await support in latest build
Promises and observables are related but operate differently, just as a single string relates to an array. Promises represent a single operation, there is nothing wrong with the abstraction itself.

As for the errors, I see what you mean. But at the same time this is an issue with trying to write async operations with sync constructs, something all "old" languages need to do. Async/await is a pattern that does that in languages that can't do it implicitly by requiring an explicit declaration. You don't need to write try/catch with async/await. You will get the exception propagated through the stack automatically.

nvivo··on Microsoft Edge gets native ECMAScript 7 async/await support in latest build
This requires the first method running in the stack to handle the failed promise and rethrow as an exception. It can be done today manually. But with async/await this will be done automatically.
nvivo··on Microsoft Edge gets native ECMAScript 7 async/await support in latest build
Yes. Also, you can read and debug more easily.
nvivo··on Microsoft Edge gets native ECMAScript 7 async/await support in latest build
Almost. In simple terms:

  // this
  var x = await promise;
  callSomething(x);

  // translates as
  promise.then(x => callSomething(x));
Under the hood, the entire "async" function is turned into a state machine instead of creating a lot of callbacks. It's more efficient it can do some optimizations that would be boring to do manually.

For example, if the translation were simply "turn into callbacks", this:

  var p = getJson();
  var x = await p;
  var y = await p;
  var z = await p;
would translate to something like :

  var p = getJson();
  p.then(o => { var x = o; });
  p.then(o => { var y = o; });
  p.then(o => { var z = o; });
but instead, the code runs more like this:

  getJson().then(o => {
    var x = o;
    var y = o;
    var z = o;
  });
I say runs like because the compiled code is more complex than that, it will still call functions, etc. It will also handle exceptions, which would add a lot of boilerplate to this code. But have in mind that because this is generated by the compiler, this code will in most cases be more efficient than anything you try to write by hand.
nvivo··on Microsoft Edge gets native ECMAScript 7 async/await support in latest build
What do you mean by "if you want any other async model you can't use it"? I know you can write whatever code you want, but promises are supposed to be the standard way of signaling completion of asynchronous operations in javascript.

This is the same as saying that "arrow functions only works if you want to represent functions".

Also, promises don't eat errors. It's the code using those promises that forget to handle them.

The async/await fixes that by unwrapping those errors for you. Any errors in an "await expression" will be thrown as exceptions up the stack.

nvivo··on Microsoft Edge gets native ECMAScript 7 async/await support in latest build
> You need to wrap in try/catch if you want to handle the errors.

Of course, the same way you need to add a second callback to a promise handler if you want to handle errors. There is no difference, really. You're just changing the way you write the code.

Also, you're not forced to choose "await or promises". You can use both as you see fit, in the same block:

   async () => { 
      // make 2 requests in parallel
      var p1 = fetchSomething();
      var p2 = fetchAnotherThing();

      // wait for both of them to be done
      await Promise.all(p1, p2);

      // continue when they're both resolved      
      // these "await" only get the values since the promises are resolved
      doSomethingWithTheValues(await p1, await p2);
   }
> But for sync functions we usually let the error terminate the program because if a sync function throws in runtime it means something is wrong in my program, not in networking

This is just the way you're choosing to see the problem. Promises can be used for anything, it's not tied to networking. I usually write promises that will be resolved when a modal window closes or when an application event happens.

It's just a simpler way to write code. The way you use it is up to you.

Also, async/await makes debugging a lot easier. The debugger can understand that the next expression after an "await" is supposed to be in the same function context. No more adding breakpoints to the callback function because only you know how the code is called at runtime. You debug async functions as normal functions.

nvivo··on Microsoft Edge gets native ECMAScript 7 async/await support in latest build
To be fair, all browsers are still missing ES6 features and all of them have newer stuff being implemented.

As for the try catch, you don't NEED to wrap. The sample just shows you can. You can't do:

  try {
      promise.then(() => ...);
  } catch {}
but you can do

  try {
      await promise;
      ...
  } catch {}
async/await is a way to write simpler code the same way you would use a "for" block instead of a "while(iterator.next())" - because it's easier, all the rest is still the same.
nvivo··on Microsoft Edge gets native ECMAScript 7 async/await support in latest build
The parent exaggerated a little. async/await does use promises. In fact, it's built around them.

All async functions return promises, and all await expressions await on promises. Currently on babel implementation with facebooks's regenarator it seems to work on any "thenable", because I got it working with jquery and angular promises.

nvivo··on Why C# Is Not My Favorite Programming Language
Agreed. Basically, he could have gone with almost every modern language there and the result would be the same.
nvivo··on Why Unpaid Internships Should Be Illegal
Unpaid internship is illegal. Well, at least in Brazil it is.
nvivo··on Ask HN: How much do you love C#?
That's exactly the point. Enums are just enumerations, they're not classes. It makes little sense in my opinion to add constructors and variables to enums.

You can do exactly what java calls enums with classes in C#, which in my view are better suited to having constructors and fields. But I agree it's all preferences.

nvivo··on Ask HN: How much do you love C#?
That's funny. Enums are one of the things I believe C# got better than java.
nvivo··on Why You Should Use Timezone Offsets Not Timezone Names
No, if you say CST you specifically mean China Standard Time. Most people in the world would agree.
nvivo··on Why You Should Use Timezone Offsets Not Timezone Names
The reason for Country/City is because the timezone name is a global reference. It may be written in english, but everybody uses. Things like "pacific", "central" and "standard" mean very different things in other places.
nvivo··on Why You Should Use Timezone Offsets Not Timezone Names
Central to where? The other 96% of the world that are not in the US don't agree with your very specific notion of "central".
nvivo··on Why You Should Use Timezone Offsets Not Timezone Names
Storing the offset won't work for future dates due to daylight savings changes.
nvivo··on Stop overanalyzing and become the best version of yourself
How do you stop overanalysing things if this problem itself requires analyzing which things you're overanalysing and which ones really benefit from overthiking? It's an honest question. I know I'm doing it right now and I can't help it.
nvivo··on Where Was Modern Flight Invented? Connecticut Believes It Holds the Answer
There is a fact that part of the world doesn't believe the Wright Brothers invented it in the first place.

In Brazil, Santos Dumont holds this title. French people also seem to give credit to him. Other countries also have their preferences and their own history.

To me, it seems there were so many people trying it that none of them really did it alone. If the title should go to the closest we have to an airplane today, Santos Dumont beats the Wright Brothers. But I'm Brazilian, so I'm biased. Not that I really care about the title...

nvivo··on Why I Choose PostgreSQL Over MySQL/MariaDB
Having used a lot of sql server management studio, I got used it this kind of UI where the focus is writing and executing sql. MySql has Devart Mysql Studio that is similar and got me really productive with mysql.

Is there anything of similar quality to postgres nowadays? I user pgadmin years ago, but it was quite crude in comparison even to Query Analyzer in sql 2000.

nvivo··on Angular 2: Built on TypeScript
I think this is more of an impression because Angular 2.0 is embracing many other things that have nothing to do with Angular, like ES6, web components, typescript.

I notice that with people trying to learn TypeScript, and see that their struggle is with classes, lambdas and modules, not with the type system that is basically the only thing TS adds to ES6.

In the end, if you look at it there is not really much to understand and all the other things you will learn anyway with Ember, React, etc. I believe most of this fear will disappear once its released.

nvivo··on Angular 2: Built on TypeScript
> The main mistake, in my opinion, that Angular 2.0 is making is removing two-way data binding

They talked about it in the ng-conf available on youtube. They are not removing 2-way databinding from Angular, they are just changing the way it works.

nvivo··on StackOverflow Considered Harmful?
I didn't know that. Anyway, this may be the case of Stack Exchange, but the website I had problems with stated the things I said in their agreement.
nvivo··on StackOverflow Considered Harmful?
I had this problem with forums before. As I requested my content to be removed from a site, my account was suspended and they actually reposted some stuff I had deleted, and blocked my account. I lost the right to my content, even though my name was still there. It was just a small dev forum, so it wasn't a big deal.

But it's funny because when you join those sites, they make it clear that any content you may find in their website is not their responsibility, as they are just a place for people to express their opinions, and any texts you find are owned by it's authors. But once you don't want your opinions there anymore, suddenly your texts become their texts and you're a dick for preventing them from making money of your content.

nvivo··on Microsoft is interesting again
Seems pretty clear to me. They will try to provide updates for the product faster and with less or no required user interaction, pretty much like any of their competitors are doing currently.

But I'm 100% sure there is nothing in this sentence saying it will be mandatory, or that non-os applications are included in the updates, or that the user cannot opt out of updates.

Sincerely, I'm not sure what's your point here.

nvivo··on Microsoft Is the New Google, Google Is the Old Microsoft
I've had reboots on amazon with linux, and google cloud was down last night and it's Linux. On amazon my entire region was out for almost an entire day once.

That's the cloud, you will have downtime anywhere.

nvivo··on Microsoft Is the New Google, Google Is the Old Microsoft
As a 12 year .NET developer and linux user I can't express how much I disagree with you. First because saying that nowadays windows apps is more important than asp.net is crazy talk. Most development is web nowadays and will just increase.

Second because what is being open sourced is not "the rest of the framework", but what is needed to build a new framework today, without the dependencies and problems from yesterday. The team announced that in time, even wpf and other windows stuff would be built on top of the new corefx as additional libraries.

The new corefx is not an asp.net only thing. It's just that asp.net is the most demanded and also the least dependent part of the framework to start this change.

There is still a lot of things to be done in order to achieve that, but I'm pretty sure it will happen because once things like collections and linq start evolving on corefx, they won't want to maintain two distinct frameworks.

Take a look at the most discussed topics on github, there is a lot of stuff being discussed there by the core team.

nvivo··on Microsoft Is the New Google, Google Is the Old Microsoft
The compilers for .net were always free and were in every installation of the framework since the first version on 2003. And there were open source IDEs for .NET since the beginning.
nvivo··on Microsoft Is the New Google, Google Is the Old Microsoft
How much has google really open sourced? Think about it. Search engine? Gmail? Ad engine? Maps? Drive? Youtube? Nothing!

Google has a lot of development tools open sourced, almost no products. Android is one for a change, but with Google Play Services, most of what you really use is closed source.

Microsoft has tons of source code out there too, but no windows, no office... For VS I think it's a matter of time. But the point is: should they? What is the advantage?

Apple seems to be doing fine with developers, and how much of it is open source? In fact people like to pay more for apple hardware in order to talk about how free things should be.

nvivo··on Microsoft Is the New Google, Google Is the Old Microsoft
Have you heard about .NET? It's one of the best frameworks out there, very well supported, has been improving steadly for the last years and now that it's open source, I only expect more.

Yes, there are some minor things that other new frameworks do better, but this is normal, any framework needs time to adapt. But in general, there is not a single thing that .NET is not attacking in all the current trends of development.

In fact, a lot of things are being based on .NET, including javascript 7 features like async functions and Netflix's RxJava that is a port of .NET Rx.

I'm not saying it's the absolute best framework out there, but it is pretty good. Saying Microsoft is doing nothing in this area is just crazy.

← PreviousPage 3 of 4Next →