Google

Google

2275 Followers
Organizing the world's information.
@google
google.com
mountain view
Tools by Google

Decisions 3

Eyas Sharaiha

Software Engineer at Google

One TypeScript / Angular 2 code health recommendation at Google is how to simplify dealing with RxJS Observables. Two common options in Angular are subscribing to an Observable inside of a Component's TypeScript code, versus using something like the AsyncPipe (foo | async) from the template html. We typically recommend the latter for most straightforward use cases (code without side effects, etc.)

I typically review a fair amount of Angular code at work. One thing I typically encourage is using plain Observables in an Angular Component, and using AsyncPipe (foo | async) from the template html to handle subscription, rather than directly subscribing to an observable in a component TS file.

Subscribing in components

Unless you know a subscription you're starting in a component is very finite (e.g. an HTTP request with no retry logic, etc), subscriptions you make in a Component must:

  1. Be closed, stopped, or cancelled when exiting a component (e.g. when navigating away from a page),
  2. Only be opened (subscribed) when a component is actually loaded/visible (i.e. in ngOnInit rather than in a constructor).

AsyncPipe can take care of that for you

Instead of manually implementing component lifecycle hooks, remembering to subscribe and unsubscribe to an Observable, AsyncPipe can do that for you.

I'm sharing a version of this recommendation with some best practices and code samples.

#Typescript #Angular #RXJS #Async #Frontend

25 198.2K

Franklin Yu

Software Engineer at Google

You need to decide whether you want to jump into machine learning; the choice is very different with or without it. If you are sure that ML is required, Python is the best choice since you only need to learn one language. You will need Python for ML anyway. Using another language would require you to break the backend into two repositories, or have one repository with two parts loosely coupled with each other (code smell to me).

About support: what do you mean? If you are talking about documentation and tutorial, they are the same. You won’t regret choosing any one.

As for scalability, cost, and performance: all three are the same. You will already own a team of 10 engineers before you worry about these factors.

4 21.6K

Michael Xin Sun

Software Engineer at Google Inc

Comment from HackerNews (https://news.ycombinator.com/item?id=8998736)

This is how Google Inbox and Google Spreadsheets works. See the slides from my recently produced GWT Create Session (http://t.co/ZvoaHxCoZT). J2ObjC slide deck here (https://docs.google.com/presentation/d/1mW_Plm5jAygELf7qjVK7...) Videos of the conference will be online soon.

Prior to that, some 20% Googlers also produced the PlayN library (https://github.com/threerings/playn) This was taken over by Michael Bayne who added an iOS backend by Bytecode -> IKVM -> Mono conversion. I beleive j2objc and RoboVM backends exist now as well.

The major benefit of the j2objc approach is the avoidance of GC in favor of ARC, the conversion of message-sends into C-method calls when possible, and integration with existing iOS toolchain.

When we started, it seemed like an iffy idea, but after developing a product delivered to millions of users on a high volume site (gmail) that has 70% code sharing, and being able to simultaneously develop, test, and deploy across the platforms reasonably efficiently, a lot of skeptics have become converts to the concept. JUniversal

3 113.8K

Followers 2275

Onur Oktay
Baptiste Boussemart
Aleksandar Velichkov
Rahul Chauhan
Dima Smolskiy
forthejim
Brito Alex
Bill Stathopoulos
Stefanie Bennett
Selçuk Tavukçu
Stephen Shank
Zachary Cangemi
yaowuping
Nilesh  Upadhyay
christopherleuthardt9728
Lukasz Stefaniszyn
Fernando N.P.F
Murtuza Alladin
Praveen Kumar
Arthur Abadjan
Bawang Goh
Abigail Batinga
shekhar macharla
Michael Curtis
Chetan A
vineshg
Humberto Astudillo TuPaginaWeb